An event is a specific action that occurs on or with a certain object. Clicking a button is an event, called the Click event. The Click event in this case occurs on the button object. Other events include the Dbl Click event (for double-clicking) and the On Enter event, which occurs, for example, when a user "enters" a field by clicking it. If you want to run a macro in response to an event, you have to work in the object's property sheet. The property sheet lists all of the events applicable to the object. You can choose the event and then specify the macro that will run when it occurs, or create a new macro in the Macro window.
Assign a Macro to an Event
- In Design view, double-click the object in which the event will occur.
- Click the Event tab.
- Click the box for the event you want to use.
- Click the list arrow, and then click the macro you want to use.
- Click the Close button on the Properties window.
Create a New Macro for an Event
- In Design view, double-click the object.
- Click the Event tab.
- Click the specific event to which you want to assign the macro.
- Click the Build button.
- Click Macro Builder.
- Click OK.
- Enter a name for the new macro, and then click OK.
- Enter the actions for the new macro, and then close the Macro window.
- Click the Close button on the Properties window.