Part IV: Professional Database Development
1050
Cross-Reference
For more information on Word’s Macro Recorder, see Chapter 22.
Building macros consists of selecting actions from a drop-down list, and then filling in the action’s
arguments (values that provide information to the action). Macros let you choose actions without
writing a single line of VBA code. The macro actions are a subset of commands VBA provides. Most
people find it easier to build a macro than writing VBA code. If you’re not familiar with VBA,
building macros is a great stepping-stone to learning some of the commands available to you while
providing added value to your Access applications.
Suppose you want to build a main form with buttons that open the other forms in your applica-
tion. You can add a button to the form, build a macro that opens another form in your application,
and then assign this macro to the button’s Click event. The macro can be a stand-alone item —
which appears in the Navigation Pane — or an embedded object that is part of the event itself (see
the “Embedded Macros” section).
Creating a macro
A simple way to demonstrate how to create macros is to build one that displays a message box that
says Hello World! To create a new standalone macro, click the Client Macro button on the far
right of the Create ribbon’s Other group (shown in Figure 30.1).
FIGURE 30.1
Use the Create ribbon to build a new standalone macro.
Client Macro button
Clicking the Client Macro button opens the macro design window and displays the Macro Tools
ribbon (shown in Figure 30.2). Initially, the macro design window is almost featureless. The only
thing in the macro window is a drop-down list of macro actions.
To the right of the macro window, you may see the Action Catalog. There are dozens of different
macro actions, and knowing which action to use for a particular task can be an issue. The Action
Catalog provides a tree view of all available macro actions and helps you know which action is
needed to perform a particular task. I’ll give you a closer look at the Action Catalog later in this
chapter.