Skip to main content

Ask user to select Two Databases then perform some actions.

Hi,
I have been asked to compare expenditures related to  the same client over two years.
I need to create a DialogBox that prompt the user to select the databases and call them to do some grouping and comparison.
I was trying to get inspiration from Brian's youtube video but I got stuck with a sintax error I can't understand.
I attach the ISS file.
As I am still learning how to code I will go with doubling the test on each of them and use a recorded macro to work with DBjoin, comparison and Analytical Review.
Thank you for your help.

Brian Element Tue, 07/14/2020 - 07:10

Hi Vitopiepoli,

I updated the script so that you can get two files.  I also added comments to the code so you can see what I did.

Brian

VITOPIEPOLI Tue, 07/14/2020 - 07:50

In reply to by Brian Element

Hi Brian,
thank you very much.
I will try now to add the button to run the operation and write the code around it.
As there are 6 or 7 analysis to be done at once, can I call it through another Sub...End Sub that call the relevant functions?
 
Regards.
Vito

Brian Element Tue, 07/14/2020 - 07:57

In reply to by VITOPIEPOLI

Generally I would create a new function or sub for each test or analysis and then just call it from the main sub, much like IDEA does when it creates a script from the IDEA history.

VITOPIEPOLI Tue, 07/14/2020 - 08:03

In reply to by Brian Element

I though the main sub was "dedicated" to the DialogBox.
I will append the calls to the functions there then and use the Ok Button to run the functions.  
Thank you very much for your help.

Brian Element Tue, 07/14/2020 - 09:03

In reply to by VITOPIEPOLI

Nope, the purpose of the main sub is to be the starting point of any script, so the sub is the starting and ending point of your script.  So you could do the following:

Sub Main

    Call menu

    Call Test1

    Call Test2

    Call Test3

End Sub

So really it is the most important part of your script.

Vito Piepoli Tue, 07/14/2020 - 11:16

I have found the workaround.
I call the functions after the OKButton1 section rather than the main sub.
 
Thank you again, you have been very helpful.
 
Regards,

Brian Element Tue, 07/14/2020 - 13:34

In reply to by Vito Piepoli

Actually what you want to do is close the dialog and then run the code.  So find this line:

Case "OKButton1"
      bExitMenu = True


So this will exit the menu and then it will run the items in the sub main function.