- In the Database window, click Macros under Objects.
- Click the New button on the Database window toolbar.
- Add an action to the macro.
- In the Macro window, click the first empty row in the Action column. If you want to insert an action between two action rows, click the selector for the action row just below the row where you want to insert the new action, and then click Insert Row on the toolbar.
- In the Action column, click the arrow to display the action list.
- Click the action you want to use.
- In the lower part of the window, specify arguments for the action, if any are required. For action arguments whose settings are a database object name, you can set the argument by dragging the object from the Database window to the action's Object Name argument box.
- Type a comment for the action. Comments are optional.
- To add more actions to the macro, move to another action row and repeat step 3. Microsoft Access carries out the actions in the order you list them.
If you want to group several related macros in one place rather than keeping track of them separately, you can organize them as a macro group.
- In the Database window, click Macros under Objects.
- Click the New button on the Database window toolbar.
- Click Macro Names on the toolbar, if it isn't already selected.
- In the Macro Name column, type a name for the first macro in the macro group.
- Add the actions you want the macro to carry out.
- In the Macro window, click the first empty row in the Action column. If you want to insert an action between two action rows, click the selector for the action row just below the row where you want to insert the new action, and then click Insert Row on the toolbar.
- In the Action column, click the arrow to display the action list.
- Click the action you want to use.
- In the lower part of the window, specify arguments for the action, if any are required. For action arguments whose settings are a database object name, you can set the argument by dragging the object from the Database window to the action's Object Name argument box.
- Type a comment for the action. Comments are optional.
- Repeat steps 4 and 5 for any other macros you want to include in the macro group.
Notes
-
When you run a macro group, Microsoft Access executes each macro, starting from the first action, until it encounters a StopMacro action, another macro group name, or no further actions.
-
When you save the macro group, the name you specify is the name of the group of macros. This name is displayed in the list of macros and macro groups in the Database window. Whenever you refer to a macro in a macro group, use this syntax:
macrogroupname.macroname
For example, Buttons.Products refers to the Products macro in the Buttons macro group. In a list of macros, such as the Macro Name argument list for the RunMacro action, Microsoft Access displays the Products macro as Buttons.Products.