- 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.
- In the Macro window, click the selector for the action row.
- Click the selector again and drag the row to a new position.
Show or hide macro names and conditions
In one macro
Do one of the following:- To show or hide the Macro Name column, click Macro Names on the toolbar.
- To show or hide the Condition column, click Conditions on the toolbar.
In all macros by default
Change whether Microsoft Access shows the Macro Name or Condition columns by default when you create macros.
-
On the Tools menu, click Options.
-
Click the View tab.
-
Under Show In Macro Design, select or clear the Names Column and Conditions Column check boxes.
Set a macro to run under specific conditions
- In the Macro window, click Conditions on the toolbar.
- In the Condition column, type a conditional expression in the row where you want to set the condition. You can't use an SQL expression in a macro Condition column.
In a Microsoft Access database (.mdb), click the Build button to use the Expression Builder. The Expression Builder is not available from a Microsoft Access project (.adp).
- In the Action column, enter the action you want Microsoft Access to perform when the condition is true.
Enter an expression in a macro action argument
- Type an equal sign (=) followed by the expression.
For example, the following expression sets the action argument to the value of the CompanyPickList control:
=[CompanyPickList]
There are two instances in which you do not use an equal sign: the Expression argument of the SetValue action, and the Repeat Expression argument of the RunMacro action. If you precede an expression in these arguments with an equal sign, Microsoft Access evaluates the expression twice, which can cause unexpected results.
In a Microsoft Access database (.mdb), click the Build button to use the Expression Builder. The Expression Builder is not available from a Microsoft Access project (.adp).