Access New Logic Designer
Open the Back Office Software System backup copy sample web database (BOSSDataCopy. accdb) from the folder where you installed the sample files. A special user interface macro called Autoexec runs each time you open the database. This user interface macro determines whether the database is trusted, opens an informational form for a few seconds, and then closes the informational form so you can see the Navigation pane.
To create data macros, you first need to open a local client table in Design or Datasheet view, or a web table in Datasheet view. To display all the tables in your BOSSDataCopy.accdb web database, click the bar at the top of the Navigation pane, click Object Type under Navigate To Category and then click Tables under Filter By Group. Double-click the table called tblCompanyInformation to open it in Datasheet view and then click the Table contextual ribbon tab under Table Tools to see the data macro events.
If you are working in the client database, you can add and edit data macros from Design view as well. When you have a local client table open in Design View, Access displays a group called Field, Record, & Table Events on the Design contextual ribbon tab. Click the Create Data Macros button on the Design tab and Access displays a list of the data macro events.
You can attach data macros to the Before Change, Before Delete, After Insert, After Update, and After Delete events of tables. With the Back Office Software System sample web database, you can see that Access highlighted the Before Change and Before Delete buttons on the Table contextual ribbon tab. When you create and save a data macro for a table event, Access highlights that event button in the ribbon as a visual cue for you to show that a data macro already exists for that event.
To create a new data macro for a table event or edit an existing one, you click the corresponding event button in the ribbon. Let's explore the existing data macro that we defined for the Before Change event in the tblCompanyInformation table to show you the new Logic Designer for creating macros. Click the Before Change button on the Table contextual ribbon tab, and Access opens the new Logic Designer.
Whenever you need to create or edit data macros or user interface macros in Access 2010, this is the design surface that you use. Access selectively enables or disables the buttons on the Design contextual tab under Macro Tools based on whether you are working with data macros or user interface macros. You'll notice Access automatically collapsed the Navigation pane to show you more of the macro designer surface. Access also opens the Logic Designer window modally, which means that you cannot open any other database objects until you close the designer window.
The new Logic Designer layout looks more like a Visual Basic code window. The Expand Actions, Collapse Actions, Expand All, and Collapse All buttons in the Collapse/Expand group selectively expand or collapse the actions listed in the macro designer surface. In the Show/Hide group on the Design tab, you can choose to hide the Action Catalog shown on the right side of the Logic Designer window by clicking the Action Catalog toggle button. In the Close group, you can click Save to save any changes to your data macro. Click Close to close the Logic Designer window for now. Note that if you attempt to close the Logic Designer window with unsaved changes, Access asks if you want to save your changes before closing the window.
On the right side of the Logic Designer window is the Action Catalog. The Action Catalog shows a contextual list of the program flow constructs, data blocks, and data actions that are applicable to the data macro event you are currently viewing. (When you create user interface macros, the Action Catalog similarly displays actions that you can use for user interface macros.) We'll discuss the Action Catalog in more detail in the next section.
In the middle of the Logic Designer window is the main macro designer surface where you define your data macro. You add program flow constructs, macro actions, and arguments to the designer surface to instruct Access what actions to take for the data macro. If you have more actions than can fit on the screen, Access provides a scroll bar on the right side of the macro design surface so you can scroll down to see the rest of your actions.
In the bottom right corner of the Logic Designer window is the Help window. Access displays a brief help message in this window depending upon where the focus is located in the Action Catalog. (Remember, you can always press F1 to open a context-sensitive Help topic.)
Click the Close button in the Close group on the Design contextual tab to return to the Datasheet view of the tblCompanyInformation web table, and then close the table.
In this tutorial:
- Creating Table Data Macros
- Uses of Data Macros
- The Data Macro Design Facility
- Access New Logic Designer
- Working with Before Events
- Grouping Macros
- Using If Blocks to Create Conditional Expressions
- Raising Errors in Data Macros to Cancel Events
- Testing Your Data Macro
- Defining Multiple Actions
- Collapsing and Expanding Actions
- Moving Actions
- Preventing Duplicate Records Across Multiple Fields
- Before Delete
- Working with After Events
- After Update
- After Delete
- Working with Named Data Macros
- Saving Named Data Macros
- Calling Named Data Macros
- Renaming and Deleting Named Data Macros
- Analyzing Errors in the USysApplicationLog Table
- Using Parameters
- Using Local Variables
- Working with Return Variables
- Debugging Data Macros
- Understanding Recursion in Data Macros
- Sharing Data Macro Logic