MS-Access / Getting Started

Grouping Macros

When you're creating data macros, you can use a program flow construct called Group. You use a Group construct to group a set of actions together logically to make your data macro actions easier to read. When you group macro actions inside a Group construct, you can also expand or collapse the entire group easily to see more of the macro design surface. It's not required to use the Group construct when you're creating data macros; however, grouping macro actions can be especially helpful if you have many disparate actions inside the same event or named data macro.

To add a Group construct to your data macro, click on the word Group from the Action Catalog, hold down the mouse key, and drag the group just beneath the comment block that you inserted previously. As you get close to the comment block, you'll notice that Access displays a horizontal bar across the macro design surface. This horizontal bar is your insertion point for the new program flow, data block, or data action. If you want to drop your new Group above the comment block, position your mouse pointer above the comment block and Access displays the horizontal bar above the comments to indicate where it will drop your new Group. We want to have this Group positioned below the comment block, so place your mouse pointer below the comment block and then release the mouse.

Access displays a new Group block on the macro design surface. You need to provide a name for your new Group block, so type PreventNewRecords in the text box provided. You are limited to 256 characters, including any spaces, for the name of any Group block. You'll notice that Access denotes the end of the Group block by placing the words End Group at the bottom of the Group block. When you click on the Group block, Access highlights the entire block as a visual cue to indicate where the starting and ending points of the block are. You'll also notice that Access placed another Add New Action combo box inside the Group block when you dropped the Group construct onto the design surface. You can use this combo box to add new actions inside the Group block. (We'll do that in just a moment.) Next to the delete button on the right side of the Group block is a green up arrow button. Click this button if you want to move the entire Group block above the Comment block that you created earlier. For now, leave the Group block where it is.

[Previous] [Contents] [Next]