Share this Page URL

Chapter 13. Completing Your Database App... > Creating Macro Groups and Using Macr... - Pg. 458

Completing Your Database Application 458 Creating Macro Groups and Using Macro Conditions In Chapter 4, we created a macro that imported data from a spreadsheet. The macro used a series of actions to perform a specific database task. As you refine and finish a database application, you can use macros (as you can Visual Basic event procedures) to carry out tasks automatically-- opening a form, printing a report, and the like. Using macros in these ways adds ease of use to an Access database. For example, users can accomplish routine tasks more swiftly. The designer of a database can use macros to help enforce business rules that the database is set up to follow-- for example, that you must enter a ship date before saving a new record for an order. In the first section of this chapter, we'll explain how to create a macro group and how to add con- ditions to a macro to determine which macro action occurs or when a macro runs. We'll use the sample macro group that we create in this section in the chapter's next section when we build an application switchboard. Macro Groups A macro group is a set of related macros in which each macro is named and has its own set of actions. You can refer to a single macro within a macro group when you assign a macro to an event by entering the macro group's name, followed by a period, followed by the macro's name--for ex- ample, MacroGroupName.MacroName . You can create a macro group to use with a single form, for example, and assign each macro in the group to a form or control event. Macros and Visual Basic In Chapter 5, "Using Visual Basic to Automate Your Database," we list some of the advantages of using Visual Basic rather than macros to help automate database operations. If the tasks you want to automate don't require