Microsoft Office Tutorials and References
In Depth Information
Telling Access to “Run This Only If I Say So”
If-Then macros
You add conditional execution to a macro action by adding an If-Then
block to the macro window and then typing a condition. Suppose that
you want to print an invoice for the current order (using the OpenReport
action), but you don’t want to print it if the total amount of the order is zero.
You use the [Orders]![Total Product Cost] > 0 condition to tell
Access to perform the action only if the order contains products that cost
money. To do so, follow these steps:
1. Open your macro in Design view by right-clicking it in the Navigation
Pane and choosing Design View from the contextual menu.
Book VI
Chapter 1
You see your macro, ready to edit.
2. If the Action Catalog isn’t already visible, click the Action Catalog
button on the Show/Hide group on the Design tab of the Ribbon.
The Action Catalog appears to the right of the macro.
3. Drag the If item from the Program Flow group of the Action Catalog
to your macro, or double-click the If item.
Either way, you end up with an If block in your macro (see Figure 1-11).
Figure 1-11:
The If block
is where
you type a
that controls
a set of
4. Enter a condition in the Conditional Expression box, or click the
Expression Builder to its right to help you write the condition.
For the condition, you can use any expression that comes out to be
True (Yes) or False (No). Conditions work just like the criteria that
you use when creating queries, as described in Book III, Chapter 1. You
can compare values by using comparison operators such as =, <, and >,
and you can use Is Null and Is Not Null to spot blank and
nonblank values, respectively.
Search JabSto ::

Custom Search