Part IV: Professional Database Development
1064
To implement this macro, set the On Click event properties of the buttons (cmdContacts,
cmdProducts, and cmdSales) on frmReportMenu as follows:
Button name On Click event property
cmdContacts mcrReportMenu.OpenContacts
cmdProducts mcrReportMenu.OpenProducts
cmdSales mcrReportMenu.OpenSales
The If macro action in mcrReportMenu has two expressions that look at fraView on
frmReportMenu to determine if Print or Print Preview is selected:
l [Forms]![frmReportMenu]![fraView]=1: Print view selected
l (^) [Forms]![frmReportMenu]![fraView]=2: Print Preview view selected
If Print is selected on frmReportMenu, the OpenReport action with the View arguments set to
Print executes otherwise, if Print Preview is selected on frmReportMenu, the OpenReport
action with the View arguments set to Print Preview executes. This structure is set up for each
submacro in mcrReportMenu.
Multiple actions in conditions
If you want to run multiple actions based on a condition, add multiple actions within the If and
End If actions. Figure 30.11 illustrates this concept.
FIGURE 30.11
Mutliple actions within If and End If actions execute as a group.
Conditions let you selectively run actions based on other values in your application. Use the If
macro action to reference controls on forms or reports, and other objects and determine which
actions to execute.