Chapter 30: Using Access Macros
1061
l (^) Where Condition: This argument lets you enter a SQL Where clause or expression that
selects records for the form from its underlying table or query. For this example, this argu-
ment is set to [ProductID]=3 for the OpenProducts submacro, which only shows
one record when you open frmProducts.
l (^) Data Mode: This argument lets you choose the data-entry mode for the form. Select Add
to only allow users to add new records, Edit to allow adding and editing of records, or
Read Only to allow only viewing of records. This setting only applies to forms opened in
Form view or Datasheet view, and overrides settings of the form’s AllowEdits,
AllowDeletions, AllowAdditions, and DataEntry properties. To use the form’s
setting for these properties, leave this argument blank. For this example, frmProducts
opens in read-only mode, while frmContacts and frmSales allow editing.
l Window Mode: This argument lets you choose the window mode for the form. Select
Normal to use the form’s properties. Select Hidden to open the form with its Visible
property set to No. Select Icon to open the form minimized. Select Dialog to open the
form with its Modal and PopUp properties set to Yes and Border Style property set
to Dialog. For this example, frmContacts opens normally, frmProducts opens as a
dialog box, and frmSales opens minimized.
Cross-Reference
For more information on form properties, see Chapter 8.
Note
When you run a macro with submacros from the Navigation Pane, only the first submacro executes.
If you’re careful in planning your macros, you can create one top-level macro object for each form
or report, and use submacros for each action in the form or report you want to perform.
Submacros let you limit the number of macros that appear in the Navigation Pane and make man-
aging numerous macros much easier.
Conditions
Submacros let you put multiple groups of actions in a single macro object, but a condition specifies
certain criteria that must be met before the macro performs the action. You can enter any expres-
sion in the macro’s condition column that evaluates to True/False or Yes/No. If the expression
evaluates to False, No, or 0 , the action will not execute. If the expression evaluates to any other
value, the action is performed. Click the Conditions button in the Show/Hide group on the macro’s
Design ribbon to display the Condition column in the macro window.
Opening reports using conditions
To demonstrate conditions, use frmReportMenu (shown in Figure 30.9), which contains three
buttons and a frame control (fraView) with two option buttons: Print and Print Preview.
Clicking Print sets the frame’s value to 1 ; clicking Print Preview sets the frame’s value to 2.