Event properties cause a macro or the associated Visual Basic event procedure to run when a particular event occurs. For example, if you enter the name of a macro in a command button's OnClick property, that macro runs when the command button is clicked. For a complete list of event properties, see Events and Event Properties Reference.
Setting
To run a macro, enter the name of the macro. You can choose an existing macro in the list. If the macro is in a macro group, it will be listed under the macro group name, as macrogroupname.macroname.
To run the event procedure associated with the event, select [Event Procedure] in the list.
Note Although using an event procedure is the recommended method for running Visual Basic code in response to an event, you can also run a user-defined function when an event occurs. To run a user-defined function, place an equal sign (=) before the function name and parentheses after it, as in =functionname( ).
You can set event properties in the property sheet for an object, in a macro, or by using Visual Basic. Note that you can't set any event properties while you're formatting or printing a form or report.
Tip You can use builders to help you set an event property. To use them, click the Build button to the right of the property box, or right-click the property box and then click Build on the shortcut menu. In the Choose Builder dialog box, select:
In Visual Basic, set the property to a string expression.
To run this | Use this syntax | Example |
---|---|---|
Macro | "macroname" |
|
Event procedure | "[Event Procedure]" |
|
User-defined function | "=functionname( )" |
|