In Microsoft Access 2010, you can define a data macro to respond to different types of table events that would otherwise require the use of writing Microsoft Visual Basic code or the creation of macros attached to forms and reports. The unique power of data macros in Access 2010 is their ability to automate responses to several types of table events without forcing you to learn a programming language. The event might be a change in the data, the creation of a new record, or even the deletion of an existing record. Within a data macro, you can include multiple actions and define condition checking so that different actions are performed depending on the values in your table fields or criteria you specify.
As you’ll learn in Chapter 24, “Understanding Visual Basic Fundamentals,” (on the companion CD) you can use Visual Basic to perform any functionality that you can create in a data macro. However, even if you think you’re ready to jump right into Visual Basic, you should study all the data macro actions first. Learning data macros is an excellent introduction to programming in Access in general.
The examples in this chapter are based on the backup copy of the Back Office Software System sample web database (BOSSDataCopy.accdb) 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 display theme set to Silver. Your results might look different if you are using a different operating system or a different theme.
Learn about the various types of actions that you can define in data macros and the table events that you can use.
Tour the new logic designer facility and learn how to build both a simple data macro and a data macro with multiple defined actions.
Learn how to create local variables in data macros to store values temporarily or calculate a result.
See how to define parameters and use them inside data macro actions.
Learn how to create return variables in data macros to return data to the calling macro.
See how to add conditional statements to a data macro to control the actions that Access performs.
Learn how to create named data macros and execute them from other data macros or table events.
Understand some of the actions automated with data macros in the Back Office Software System sample web database.