Microsoft Office Tutorials and References
In Depth Information
Running Stand-Alone Macros and Submacros
You can also create groups in macros, which allows you to enclose a set of
actions in a box with a name. We’re not sure what the point is, however.
Stick with submacros, which are very useful!
Running Stand-Alone Macros and Submacros
You can run a stand-alone macro directly by double-clicking the macro in
the Navigation Pane, or you can right-click it and choose Run from the
contextual menu. If the macro contains only groups, Access runs just the first
macro in the group.
Book VI
Chapter 1
The most common way to run a macro or submacro, however, is to assign
it to an event on a form, such as the On Click event of a command button.
You specify the name of the macro or the full name of the submacro (macro
name, a dot, and submacro name) in one of the properties of a command
button. We cover using macros on forms in Chapter 2 of this minibook. In this
section, however, we cover two other cool ways to run macros: autoexecution
when the database opens and execution when certain keystrokes are used.
Running a macro when the database opens
We like our databases to automatically display a main-menu form, or some
other commonly used form, as soon as the database opens. If the first thing
you usually do after opening the database is open the Order Entry form, why
not tell Access to open it for you? You may have other actions that you’d like
Access to take when your database opens. Perhaps you want to prompt the
user for his or her name or to display a list of reports.
To tell Access to do something automatically when the database opens, you
can write a macro with the actions you want Access to take and then tell
Access to run the macro on startup.
Running a macro when the database opens is a snap: Just name the macro
AutoExec. That’s the whole thing. When you open a database, Access looks
in the database for a macro named AutoExec, and if it finds one, it runs
the macro. Enter the actions and arguments for the AutoExec macro in the
usual way.
If you don’t want the AutoExec macro to run when you open the database,
hold down the Shift key while the database is loading.
Another way to make something happen when your database opens is to
tell Access to open a form. Click the File tab on the Ribbon, click Options to
display the Access Options dialog box, click Current Database, and set the
Display Form option to the name of the form you want to open.
Search JabSto ::




Custom Search