Microsoft Office Tutorials and References
In Depth Information
Running Macros in Forms
Running Macros in Forms
Most macros are used with forms to make form controls smarter or to power
command buttons. Every control in a form has events connected to it —
things that happen when the user clicks the control, changes its value, or
opens or closes the form itself.
You can run two kinds of macros from a form:
Regular old stand-alone macros, like the ones described in Chapter 1 of
this minibook. You can make a macro for the form, and in the macro, you
can create a submacro for each event for which you want a macro to run.
Embedded macros, which Access creates when a wizard makes a
command button on a form. These macros are attached to the form in the
same way that data macros are attached to tables. You can get to them
when you have the form open in Design view.
The rest of this section describes how to run both types of macros from
your forms.
Running a macro when a form event happens
To tell Access to run a macro when an event happens, you enter the macro
name in the event property for the control (or for the whole form). Follow
these steps:
1. Create and save the macro you want to run.
You can store the macro by itself or as a submacro in a macro for the
form. (We usually create one macro for each form and make a submacro
for each event for which we want something to happen.) Save the macro
before continuing.
You can keep the macro open in Design view if you plan to make further
changes in your macro.
2. Open the form in Design view.
See Book IV, Chapter 2 for information about editing a form in Design
view.
3. Display the property sheet by clicking the Property Sheet button in
the Tools group on the Design tab of the Ribbon, and click the Event
tab.
See Book IV, Chapter 1 for information about the property sheet. The
Event tab displays all the events for the selected object.
Search JabSto ::




Custom Search