8.1. When Events Fire
Events are at the heart of event-driven programming—which is no surprise. What can be surprising to novice programmers is the sheer number of events available to use. They all beg to have some code behind them. In reality though, very few events are used on a consistent basis. Most of them have absolutely no code behind them, and never will in normal usage. The trick is to know which ones are important and commonly used, and which ones are obscure and hardly ever used. They all look equally important in Access Help.
8.1.1. Common Form Events
To cut to the chase, here's a list of commonly used events and how you might want to use them. If you know how to use this basic set of events, you're most of the way there to understanding event-driven programming in Access VBA.
Form—On Open: The Open event for a form fires before the Load event, and before the recordset is evaluated for the form. This means you can use this event to change the recordset (by changing the Where or Order By clause) before the form continues to load. This event can be cancelled, which means the form will not continue to the Load event.
Form—On Load: The Load event for a form fires after the recordset for the form has been evaluated, but before the form is displayed to the user. This offers you an opportunity to make calculations, set defaults, and change visual attributes based on the data from the recordset.
Form—Before Update: If you want to perform some data edits before the user's changes ...
Get Access 2003 VBA Programmer's Reference 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.