Make a macro run under specific conditions

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.

  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.

    Notes

  3. In the Action column, enter the action you want Microsoft Access to perform when the condition is true.

When you run the macro, Microsoft Access evaluates the first conditional expression. If the condition is true, Microsoft Access carries out the action in that row and all of the immediately following actions that are preceded by an ellipsis (...) in the Condition column. For example, the following macro carries out the MsgBox and StopMacro actions only when there is no value in the SupplierID field (when the value is Null).

Microsoft Access then runs any additional actions in the macro that have a blank Condition column until it reaches another expression, a macro name, or the end of the macro.

If the condition is false, Microsoft Access ignores the action and any immediately following actions that are preceded by an ellipsis in the Condition column and moves to the next action row that contains another condition or a blank Condition column.

For examples of macro conditions, click . For information on creating expressions, click .