Microsoft Access 2010 Bible

(Rick Simeone) #1

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:


  1. Click the Create tab on the ribbon, and then click the Form Design button in the Forms
    group.

  2. 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.



  1. Click the Button control and draw a button on the form.

  2. 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.



  1. Set the button’s Caption property to Hello World!.

  2. 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.
Free download pdf