Full Version: Creating a button
UtterAccess Discussion Forums > Microsoft® Access > Access Q and A
phong919
Hello all,

I was wondering how i can run all the macros i have within a button i created? Can someone assist me? thank you.
Aquadevel
Phong....,
forget the macro's......just use the wizard to 'create' the button.

Good luck, sad.gif

Aqua
lesmoldovan
Hi,

Love to help but must ask - why would you want to. Surely the macros you have created do all sorts of different things?
freakazeud
Hi,
within VBA you can execute macros with:

DoCmd.RunMacro "MacroName"

However, if you are already using VBA to execute the macros why not just use VBA code right away. You will be much more flexible that way. If you already have a lot of macros then why not convert them to VBA and use that all behind your button?
HTH
Good luck
phong919
Thanks for all the answers. I'm actually looking at somebody's else db. I wasn't sure why it was done like that. I figure i don't want to click on each macro to run it. I just want to click on a button and call all those macros at once. Does that make sense?
Steve Schapel
Normally, when you click a button, you would only want one macro to execute. Can you give an example of where you would want more than one macro to execute from the same button? Probably if that's the case you need to combine all the macros into one macro that includes all the actions of the existing ones.

By the way, in order to run a macro from a command button, you just enter the name of the macro in the button's On Click event property.
lesmoldovan
I can only try to amplify the message from freakazeud.

You will find a great deal of resistance to Access macros from long term users of Access. The reasons are clealy and forcefully stated in this article which is found at the beginning of the Macros forum. When you plan to call macros from VBA it is a double whammy and I am sure that freakazeud had a rise in blood pressure even though he replied to you in his usual calm and succinct manner.

From your last post I can only assume that the macros in your db are run periodically and in sequence to achieve some task, and that you wish to further automate by running them all from a single button click. If so then the suggestion from freakazeud will do. In the button Click event procedure put:

DoCmd.RunMacro "FirstMacroName"
DoCmd.RunMacro "SecondMacroName"
DoCmd.RunMacro "ThirdMacroName"
...
...

and try to find time to convert the macros to VBA.

I truly hope this helps.

Have a nice day.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.