Chapter 30: Using Access Macros
1053
The most common event to which you might assign a macro is a button’s Click event. Follow
these steps to create a simple form with a button that runs mcrHelloWorld:
- Click the Create tab on the ribbon, and then click the Form Design button in the Forms
group. - In the form’s Design ribbon, deselect the Use Control Wizards option in the Controls
group.
For this example, you don’t want to use a wizard to decide what this button does.
- Click the Button control and draw a button on the form.
- Set the button’s Name property to cmdHelloWorld.
Press F4 to open the button’s Property Sheet if it isn’t visible on
the screen.
- Set the button’s Caption property to Hello World!.
- Click the drop-down list in the button’s On Click event property, and select mcr
HelloWorld from the list (shown in Figure 30.5).
FIGURE 30.5
Set any object’s event property to the macro to trigger that macro when that event
occurs.
New Command button Hello World macro
On Click Event property
That’s all there is to creating and running a macro. Just select the action, set the action arguments,
and assign the macro to an event property.