Embedded Macros

Developers used to campaign loudly against macros because one little error could shut down an entire application. Now, macros can be embedded in events for forms, reports, and controls and are often an effective replacement for some VBA code. An embedded macro becomes part of the parent object and is not visible in the Navigation pane. Embedded macros can run in disabled mode, and they include error handling and debugging, can be combined into groups, and can use temporary variables. Okay, before anyone has a heart attack about perceived risks, I'll add the caveat that unsafe macro actions are blocked in disabled mode, which means that they would not allow embedded macros to run such tasks as File system interactions. But the big picture is that not only can macros save time, but they can avoid a lot of hassles associated with deployment and trusting files.

When you combine embedded macros with the new features in 2007, you can create robust solutions with little or no VBA code. Before you scoff at the potential functionality, realize that Access 2007 templates deliver all their features, program integration, and a polished interface using macros instead of VBA code. Developers need not panic—there's still plenty of need for VBA code. For one thing, somebody needs to create all of the new macros, and who knows the business rules and needs better than a developer? When you think about it, the real purpose of a developer is to understand the business model and to build smart solutions with whatever combination of VBA, macros, add-ins, and integration seems appropriate.

How about allowing a user to add a new item to a combo box list, refresh the list, and then select the new item? Of course, it must be done smoothly, without unnecessary messages or warning. If you use a value list, Access can handle the process with just a couple of questions, as shown in Figure 3-10. Because most combo boxes use a query or table instead of a value list, you've probably been using VBA to manage the process. Now, macros can do all of that without using VBA code. Chapter 10 discusses several ways of working with combo boxes.

The following is a recap of some of the key features and benefits of macros. Chapter 2 included a more detailed discussion.

Edit UstlternE HRI^]

Type each item on a separate line (1) Great (2jGood (3] Satsfactory :;r: Bad Poor

Default Value:

Was this article helpful?

0 0

Post a comment