Microsoft Office Tutorials and References
In Depth Information
Telling Access to “Run This Only If I Say So”
5. Enter actions and arguments in the If‑Then block, using the Add New
Action box, or add actions from the Action Catalog.
If the If command is selected in the Action Catalog, double-clicking
another action adds the action inside the If block. You can move an
action into or out of an If block by dragging it or by clicking the up and
down arrows at the right end of the action.
Any actions that are inside the If block’s box are executed only if the
condition is True. If the condition is False, Access skips the If block and
continues executing the macro with the action following the If block.
If-Then-Else macros
If you want an if-then-else condition — you want to run one set of actions if
the condition is True and another set if the condition is False — you can
add an Else or ElseIf section to your If block. An Else section gives you
a place to add actions to your macro that will be executed only if the If
condition is False. An ElseIf section enables you to enter a second condition
for Access to check.
To add an Else or ElseIf section to your If block, click the Add Else or
Add ElseIf link in the bottom-right corner of the If block’s box.
The example macro shown in Figure 1-12 prints a receipt if the order has
been paid for, and it prints an invoice if the order hasn’t been paid for. The
OpenReport actions have been collapsed (shrunk) so that their arguments
appear on the same line as the action, which saves screen space (and paper).
Figure 1-12:
An
If
ThenElse
macro
executes
one set of
actions if a
condition
is True
and another
set if the
condition is
False .
Search JabSto ::




Custom Search