Microsoft Office Tutorials and References
In Depth Information
Creating Command Buttons
This section covers how to run the Command Button Wizard to make
command buttons that do useful stuff. The wizard creates a macro for the form
to contain the programs for the buttons on the form. The wizard makes
buttons with actions that it divides into categories. When you place a command
button on a form, the Command Button Wizard appears, showing two lists:
Categories and Actions.
Different actions apply to the different categories. The names of the actions
are pretty self-explanatory.
The items in the Categories list are
✦ Record Navigation: These commands are for moving from record to
record. Most of them duplicate the navigation controls that appear at
the bottom of most forms (Go to First Record, Go to Previous Record,
Go to Next Record, and Go to Last Record), but you can also make a
Find Record button that displays the Find and Replace dialog box or a
Find Next button that repeats the preceding search. If you want to make
a box right on the form in which you can type a value, as well a Find
button that searches for that value, see “Making a Find Box,” later in
✦ Record Operations: This category includes buttons for adding,
deleting, duplicating, printing, saving, and undoing the edits to a record (the
current record, in most cases). The Duplicate Record button adds a new
record that’s a duplicate of the current record. The Print Record button
prints the form with the data for the current record.
✦ Form Operations: These commands apply or edit filters (described
in Book II, Chapter 3), close this form, open another form, or print
If you print another form, you get all the records in that form, so you
may want to come up with another method.
You can also make a button that reloads the data on the form, in case it
has changed since you loaded the form.
✦ Report Operations: You can make command buttons that preview, print,
mail, or save a report to a file. You can’t restrict the report to a specific
record without editing the code behind the form, however.
✦ Application: Quit Application is the only command in this category.
✦ Miscellaneous: This last group of commands includes commands that
dial a phone number (assuming that your computer is connected to
a dial-up modem and a phone), print a table in Datasheet view, run a
macro, or run a query and display the resulting datasheet.