Macros: What they are and how they work
This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.
What is a macro?
A macro is a set of one or more actions that each perform a particular operation, such as opening a form or printing a report. Macros can help you to automate common tasks. For example, you can run a macro that prints a report when a user clicks a command button.
A macro can be one macro composed of a sequence of actions, or it can be a macro group. You can also use a conditional expression to determine whether in some cases an action will be carried out when a macro runs.
A sequence of actions
The following macro is composed of a series of actions. Microsoft Access carries out these actions each time the macro runs. To run this macro, you refer to the macro name Review Products.
A macro group
If you have numerous macros, grouping related macros in macro groups can help you to manage your database more easily. To display the names of macros for a macro group, click Macro Names on the View menu in the Macro window.
For example, the following macro group, named Buttons, is made up of three related macros: Employees, Products, and Reps. Each macro carries out the OpenForm action, and the Products macro also carries out the MoveSize action.
The name in the Macro Name column identifies each macro. When you run a macro in a macro group, Access carries out the action in the action column and any actions that immediately follow whose Macro Name column is blank.
To run a macro in a macro group, you use the macro group name followed by a period and then the macro name. In the preceding example, to refer to the Employees macro in the Buttons macro group, you would type Buttons.Employees.
To display the Condition column, you click Conditions on the View menu in the Macro window. The following macro runs the MsgBox and the StopMacro actions only when the expression in the Condition column is true (when there is a Null value in the SupplierID field).