You can use the RunMacro action to run a macro. The macro can be in a macro group.
You can use this action:
Setting
The RunMacro action has the following arguments.
Action argument | Description |
---|---|
Macro Name | The name of the macro to run. The Macro Name box in the Action Arguments section of the Macro window shows all macros (and macro groups) in the current database. If the macro is in a macro group, it's listed under the macro group name in the list as macrogroupname.macroname. This is a required argument. |
If you run a macro containing the RunMacro action in a library database, Microsoft Access looks for the macro with this name in the library database and doesn't look for it in the current database. | |
Repeat Count | The maximum number of times the macro will run. If you leave this argument blank (and the Repeat Expression argument is also blank), the macro runs once. |
Repeat Expression | An expression that evaluates to True (–1) or False (0). The macro stops running if the expression evaluates to False. The expression is evaluated each time the macro runs. |
Remarks
If you enter a macro group name for the Macro Name argument, Microsoft Access runs the first macro in the macro group.
This action is similar to clicking Macro on the Tools menu, which you can use to select and run a specified macro. However, the command runs the macro only once, whereas the RunMacro action can run a macro as many times as you want.
Tip You can use the Repeat Count and Repeat Expression arguments to determine how many times the macro runs:
When you run a macro containing the RunMacro action, and it reaches the RunMacro action, Microsoft Access runs the called macro. When the called macro has finished, Microsoft Access returns to the original macro and runs the next action.
Notes
Tip You can use the RunMacro action in a macro group that defines custom commands for a custom menu bar to run a macro from the custom menu. However, it's easier to use the new command bars functionality to run a macro from a menu bar, toolbar, or shortcut menu. On the View menu, point to Toolbars and click Customize to display the Customize dialog box. On the Toolbars tab, select the menu bar, toolbar, or shortcut menu that you want to run the macro from. On the Commands tab, click All Macros in the Categories box, then in the Commands box select and drag the macro you want to run to the menu bar, toolbar, or shortcut menu. When you click the icon for this macro on the menu bar, toolbar, or shortcut menu, Microsoft Access will run the macro. You can also drag a macro from the Database window on to a menu bar or toolbar and Microsoft Access will create an icon that runs that macro.
To run the RunMacro action in Visual Basic, use the RunMacro method of the DoCmd object.