Show All

Modify macros

Once you have created a macro, you can modify it to make it better suit your needs.

Add an action to a macro

  1. 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.
  2. In the Action column, click the arrow to display the action list.
  3. Click the action you want to use.
  4. 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.
  5. Type a comment for the action. Comments are optional.

Move an action in a macro

  1. In the Macro window, click the selector for the action row.
  2. 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:

In all macros by default

Change whether Microsoft Access shows the Macro Name or Condition columns by default when you create macros.

  1. On the Tools menu, click Options.

  2. Click the View tab.

  3. Under Show In Macro Design, select or clear the Names Column and Conditions Column check boxes.

Set a macro to run under specific conditions

  1. In the Macro window, click Conditions on the toolbar.
  2. 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.

    Tip

    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).

  3. 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

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.

Tip

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).