In Chapter 7, you learned about the new data macro feature in Microsoft Access 2010. Data macros are attached to table events or the table itself and interact only at the data layer. In this chapter and the next, you’ll learn about user interface macros. In Access 2010, you can define a user interface macro to execute just about any task you would otherwise initiate with the keyboard or the mouse. The unique power of user interface macros in Access is their ability to automate responses to many types of events without forcing you to learn a programming language. The event might be a change in the data, the opening or closing of a form or a report, or even a change of focus from one control to another. Within a user interface macro, you can include multiple actions and define condition checking so that different actions are performed depending on the values in your forms or reports. For the remainder of this chapter and the next, we’ll only use the term macros to refer to user interface macros.
Macros are particularly useful for building small, personal applications or for prototyping larger ones. Macros are also essential if you want to automate a web database and display the application in a web browser using Access Services and SharePoint 2010. (You’ll learn how to automate a web database in Chapter 21.) As you’ll learn in Chapter 24, “Understanding Visual Basic Fundamentals,” on the companion CD, you probably should use Microsoft Visual Basic for complex applications or for applications that will be shared by several users over a network. However, even if you think you’re ready to jump right into Visual Basic, you should study all the macro actions first. You’ll find that you’ll use nearly all the available macro actions in Visual Basic, so learning macros is an excellent introduction to programming in Access in general.
The examples in this chapter are based on the Wedding List Macro (WeddingMC.accdb) sample client database on the companion CD included with this book. The results you see from the samples in this chapter might not exactly match what you see in this book if you have changed the sample data in the files. Also, all the screen images in this chapter were taken on a Windows 7 system with the Access color scheme set to Silver. Your results might look different if you are using a different operating system or a different theme.
In this chapter, you will
Learn about the various types of actions you can define in macros
Tour the new Logic Designer and learn how to build both a simple macro and a macro with multiple defined actions
Learn how to manage the many macros you need for a form or a report by creating submacros inside a macro object
See how to add conditional expressions to a macro to control the actions that Access performs
Learn about embedded macros, error trapping in macros, temporary variables, and macro actions that are not trusted
Learn how to reference other form and report objects in macros
Understand some of the actions automated with macros in the Wedding List Macro sample client database