Data Macros
So far, youâve seen how to make a macro run when a specific event occurs in a form. However, you can also make a macro run when an event occurs in a table. This feature, which is new in Access 2010, gives you a way to make smarter tables that log changes, synchronize values, and refuse to accept bad data.
Macros that respond to table events are called data macros, and they follow different rules than the macros youâve seen so far. Although you create data macros using the same macro designer, youâll notice that data macros support a different set of actions. For example, data macros canât do anything user-interface related (like show a message box or open a form), and they canât perform risky actions (like running an application, deleting a database object, or starting a printout). In fact, pretty much the only things data macros can do are create a record, edit a record, and send an email. Thereâs good reason for this designâit means data macros are light, efficient, and fast.
Data macros are analogous to a concept called triggers thatâs featured in server-based databases like SQL Server. Thereâs a reason for that, too. Microsoftâs ultimate goal is to make data macros portableâin other words, to make sure that data macros can stick with your database even if you transfer it to another platform. For example, your data macros keep right on working if you convert your database to a web database (Chapter 23). Technically, itâs possible for data macros ...
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.