Microsoft Office Tutorials and References
In Depth Information
Setting Up Your Own Main-Menu Form
5. Type a short name for the command button, and click Finish.
Choose a name that has something to do with what the button does.
The wizard creates the command button and sets the button’s On
Click property to execute the embedded macro it just wrote. This
property causes Access to run the embedded macro when someone
clicks the command button.
6. Move or resize the command button as you like, and create a label to
go next to it.
If the button displays text, it may not need a label.
The Command Button Wizard sets the On Click property of each command
button to an embedded macro that it writes. In the property sheet, you see
Embedded macro in the property; click the property and then click the
Macro Builder ( … ) button to see the submacro in Design view.
If you want to change the button to run a different macro, click the On
Click property on the Event tab of the property sheet, click the down arrow
for the property, and choose your macro from the drop-down menu.
If you’re not sure whether the Command Button Wizard can write an
embedded macro for the task you want the button to perform, run the wizard
according to the preceding steps to find out. In Step 2, browse the various
programs that the wizard knows how to write. If you don’t see the program
you need, cancel the wizard, and try the steps in the next section of this
Making command buttons that run your macros
There’s a chance that you ran the Command Button Wizard but couldn’t find
the option you need. The wizard just doesn’t do everything. In that case, you
can create a button and then write a macro for the button to run.
If you followed the steps in “Creating a form that appears when the
database opens,” earlier in this chapter, you’ve already created a macro for the
macros run by command buttons on your main-menu form. Follow these
steps for each command button that runs a macro:
1. Open the macro in Design view by right-clicking the macro name in the
Navigation Pane and choosing Design View from the contextual menu.
If you’ve already created macros for this form, this macro already
contains submacros. No problem! Just add another submacro.
2. Create a submacro by double-clicking Submacro in the Action Catalog;
then add actions and enter arguments for each action.
Chapter 1 of this minibook describes how to choose the actions and
arguments for a macro.