By default, the controls on
an Access form receive events before the form. This means that a form??™s controls mask key events
from the form, and the form can never respond to those events. You must set the KeyPreview
property to Yes (True) before the form responds to any of the key events (KeyDown, KeyUp, and
so on).
Form data events
The primary purpose of Access forms is to display data. Not surprisingly then, Access forms have
a number of events that are directly related to a form??™s data management (see Table 12-4). You will
see these events programmed over and over again in this book, and will encounter event procedures
written for these events virtually every time you work on an Access application.
423
Understanding the Access Event Model 12
TABLE 12-4
Form Data Events
Event When the Event Is Triggered
OnCurrent When you move to a different record and make it the current record
BeforeInsert After data is first entered into a new record but before the record is actually
created
AfterInsert After the new record is added to the table
BeforeUpdate Before changed data is updated in a record
AfterUpdate After changed data is updated in a record
OnDirty When a record is modified
OnUndo When a user has returned a form to clean state??”record set back to
unmodified state??”opposite of OnDirty
OnDelete When a record is deleted but before the deletion takes place
BeforeDelConfirm Just before Access displays the Delete Confirm dialog box
AfterDelConfirm After the Delete Confirm dialog box closes and confirmation has happened
Error When a runtime error is produced
Filter When a filter has been specified but before it is applied
ApplyFilter After a filter is applied to a form
Form PivotTable events
The more recent versions of Access include the ability to create PivotTables that display data in
interesting ways.
Pages:
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920