The macros you’ve seen so far run all their actions from start to finish. If that seems a little boring, well, it is. But your macros don’t need to stay that way. You can let them make decisions and perform conditional actions.
To create a conditional macro, you need to use the If action. You can pick the If action from the Add New Action list (where it’s the third item), or you can drag it from the Program Flow section of the Action Catalog. Figure 16-4 shows an example.
To save some serious time, you can take a bundle of existing actions and wrap it with a new If box, with no dragging required. Simply press Shift as you select the actions you want to make conditional. Then, right-click any part of this selection and choose Make If Block.
The If action requires a single argument, which is a condition. A condition is a little like an expression, except it always produces one of two results: True or False. Access examines the condition and uses it to decide whether to run the actions inside the If box. (This is known as evaluating the condition in programmer-speak.) Here’s how it works:
If the condition turns out to be True, Access runs the actions in the If box.
If the condition turns out to be False, Access skips over the actions in the If box and continues with the next action after the If action.
Presto—you have a way to make an action run only when you need it.
Figure 16-4. The If action is a bit like a group or a submacro, in that it holds one or more other actions. ...