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 ...
Get Access 2010: 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.