Collapsing and Expanding Actions
When you have complex data macros with many program flow constructs, data blocks, and data actions, you might find it harder to understand everything happening with the structure of your data macros, especially if you have to scroll the macro design surface to see everything. Fortunately, the Logic Designer includes features that can make these tasks easier.
Open the tblWeekDays table in Datasheet view, click the Table contextual ribbon tab under Table Tools, and then click the Before Change button in the Before Events group. You should now see the data macro that you created previously for preventing new records from being added to this table and changing existing values. To the left of the Group and If blocks on the macro design surface, you'll notice that Access displays a box with a dash inside. If you place your mouse over the RaiseError data action, you can also see a similar box. (For data actions, Access only shows this box when you hover over the action.) You can use this box to expand and collapse the group or action. By default, the Logic Designer displays all group blocks and data actions in expanded mode so you can see all actions and arguments. To collapse the RaiseError data action, hover over the action until you see the box to the left of the RaiseError action and then click inside the box. Access changes the dash inside the box to a plus symbol and then collapses the action onto one line.
Access now displays the action without the argument names-Error Number and Error Description-and separates the argument values with a comma. By collapsing the action, you can now see more of the macro design surface. To expand the action again, click inside the box, now displaying a plus symbol, and Access expands the RaiseError action. You can also collapse an entire group, such as the PreventNewRecords Group block that you created earlier or any If blocks, by clicking inside the expand/collapse box next to each block. If you want to collapse all data actions showing on the macro design surface at the same time, you can click the Collapse Actions button in the Collapse/Expand group on the ribbon. You can see that Access collapsed both RaiseError data actions onto one line. Click the Expand Actions button in the Collapse/Expand group on the ribbon to expand all data actions showing on the macro design surface.
If you hover your mouse over a collapsed data action, Access displays a super tooltip with all the arguments. You can then view all the argument values of the data action easily, without having to expand the data action.
For the maximum amount of space on the macro design surface, click the Collapse All button in the Collapse/Expand group on the ribbon. Access collapses all groups onto one line. You can't see very much with this view, of course. However, you can then selectively expand Groups and If blocks one at a time to work on specific parts of the data macro. Click the Expand All button on the ribbon to expand all Group blocks, If blocks, and data actions.
Note When you expand or collapse Group blocks, If blocks, or Data Actions, Access marks the macro design surface as dirty even if you did not make any other changes. If you attempt to close the Logic Designer window, Access prompts you to save your changes. Access remembers the state of any expanded or collapsed elements when you save changes and reopen the data macro.
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