Macro

zoup

New member
Local time
Today, 06:49
Joined
May 19, 2005
Messages
8
I have a database and in order to get the correct values you need to run a few queries/make tables/delete tables ect. I was wondering if there was a way to code something so that on command click button it would run through all the neccessary steps so people dont have to manually do this. please help!
 
I do this all the time.

For each action query you want to run, make an entry in your macro to do a RunSQL. At the bottom of the macro dialog box, you get to specify the name of the query to be run. Just do a single SQL operation per macro line and remember to exit the macro at the end.

You might wish to test this a couple of times and then use SetWarnings to turn off the "chatter" associated with a macro. Run your action queries, then use SetWarnings again to restore warning level to normal. Always remember to allow warnings once you leave the macro!

Be it herein noted that macro error handling - to put it gently - sucks. So if there is a chance that one or more of your action queries could fail, do this function using a macro to RunCode, has to be public code in a general module, name the FUNCTION ('cause it has to be a function) in the bottom of the macro dialog box. Use VBA to execute the SQL action queries in your desired sequence and do any error checks in between. Or set traps in the code. You can use message boxes in this context to warn of errors.
 

Users who are viewing this thread

Back
Top Bottom