Chapter 16. Connecting Macros to Forms and Tables
If all you do with macros is launch them from the navigation pane, you’re missing out on the real fun. Macros become far more powerful when you attach them to forms and tables and use Access events to run them automatically when something important happens. For example, you can use events to run an email-sending macro when someone clicks a button, or to trigger a data-checking macro when someone edits a field.
In this chapter, you’ll start by learning how you can plug your macros into forms and controls and trigger them with Access events. It’s time well spent, because you’ll use almost the same approach to hook up Visual Basic code in Chapter 17. Next, you’ll see how to build smarter macros that evaluate conditions and make decisions. Finally, you’ll connect a macro to a table, so Access runs the macro when a specific type of editing action takes place.
Macro-Powered Forms
The slickest macros work with the forms in your database. Using this combination, you can create macros that fire automatically when something happens (like when a button is clicked or a record is changed). You can also build much more flexible macros that don’t have fixed argument values—instead, they can read the data they need from the text boxes on a form.
In the following sections, you’ll learn how to help macros and forms come together.
Understanding Events
So far, you’ve been running macros the hard way: by finding the ones you want in the navigation pane, and ...
Get Access 2013: The Missing Manual now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.