Ask user to select Two Databases then perform some actions.

10 posts / 0 new
Last post
VITOPIEPOLI
Offline
Joined: 10/29/2019 - 11:28
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's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

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
Offline
Joined: 10/29/2019 - 11:28

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's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

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
Offline
Joined: 10/29/2019 - 11:28

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's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

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.

VITOPIEPOLI
Offline
Joined: 10/29/2019 - 11:28

I am almost there...I think.
Oddly enough the functions run only after I quit the dialog. When I click OK nothing happens.
Where the mistake is?

Vito Piepoli
Offline
Joined: 08/15/2019 - 15: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's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

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.
VITOPIEPOLI
Offline
Joined: 10/29/2019 - 11:28

This is also a good solution.
Many thanks for your help.
Regards,
 
Vito