Microsoft Office Tutorials and References
In Depth Information
Running Macros in Forms
Table 2-2
Some Form-Control Events
Before Update
When the control or record is about to be updated
After Update
Immediately after the control or record is updated
On Not in List
When a user tries to enter a value in combo and list
boxes that’s not in the list of values
On Enter
When focus (the cursor) moves to the control
On Exit
When focus (the cursor) leaves the control
On Click
When you click the control
On Dbl Click
When you double-click the control
You can make a macro for an order form that automatically moves you to
the last record in the table, for example. (You rarely want to edit the first,
oldest order in the table, but you may well want to edit the newest order.)
The macro runs when you open the form. The macro, which you might name
GoToLastRecord and store in your Order Form macro, looks like Figure 2-4.
It uses the GoToRecord action, with the Record argument set to Last.
Figure 2-4:
moves the
cursor to
the last
record in
the record
source of
the form.
To make the macro run each time you open the form, set the form’s OnOpen
event property to the name of the macro: Order Form.GoToLastRecord.
Creating command buttons on forms
Book IV, Chapter 3 describes how to make command buttons on a form. The
Command Button Wizard can write macros for many tasks that you may
want a button to carry out, such as going to the first or last record, applying
a filter, or finding a record. The wizard writes a macro that’s attached to the
form — an embedded macro.
Search JabSto ::

Custom Search