The BeforeUpdate and AfterUpdate events for the controls on the form and for the new record occur after the BeforeInsert event and before the AfterInsert event. The AfterInsert (form) event triggers after you leave the record. The BeforeInsert (form) event triggers as soon as you start typing in the control. When you move the focus to a new (blank) record on a form and then create a new record by typing data in a control, the following sequence of events occurs:Ĭurrent (form) Enter (control) GotFocus (control) BeforeInsert (form) AfterInsert (form) If you cancel the Delete event, the BeforeDelConfirm and AfterDelConfirm events do not occur, and the dialog box is not displayed. When you delete a record, the following events occur for the form, and Microsoft Office Access displays a dialog box asking you to confirm the deletion: Open a form and change data in a control:Ĭurrent (form) Enter (control) GotFocus (control) BeforeUpdate (control) AfterUpdate (control)Įxit (control1) LostFocus (control1) Enter (control2) GotFocus (control2)īeforeUpdate (form) AfterUpdate (form) Exit (control2) Lo stFocus (control2) Current (form) For example, the following sequences of events occur when you do the following: These events occur after the BeforeUpdate and AfterUpdate events for the form, as follows:īeforeUpdate (form) AfterUpdate (form) Exit (control) LostFocus (control) Current (form)Īs you move the focus among the controls on a form, events occur for each control. When you leave the record whose data has changed, but before you enter the next record, the Exit and LostFocus events occur for the control that has the focus. When you move the focus to an existing record on a form, enter or change data in the record, and then move the focus to another record, the following sequence of events occurs for the form:Ĭurrent (form) BeforeUpdate (form) AfterUpdate (form) Current (form)
Moving the focus to records and updating data in records
Top of Page Order of events for records on formsĮvents occur for records on forms when you move the focus to a different record, update data in a record, delete an existing record or records, or create a new record. KeyDown KeyPress Dirty Change KeyUp NotInList Error If the LimitToList property of the combo box is set to Y es, the Error event for the form occurs immediately after the NotInList event: The NotInList event occurs after the keyboard events and the Change events for the combo box, but before the events for any other control or the form. The NotInList event occurs after you enter a value in a combo box that is not found in the combo box list and then try to move the focus to another control or record. The following sequence of events occurs for each key that you press in a text box or in the text box section of a combo box: This event occurs whenever the contents of the control change, but before you move the focus to a different control or record (and therefore, before the BeforeUpdate and AfterUpdate events occur). When you change the text in a text box or in the text box section of a combo box, the Change event occurs. The Exit and LostFocus events for a control whose value changes occur after the BeforeUpdate and AfterUpdate events: When you enter or change data in a control on a form and then move the focus to another control, the BeforeUpdate and AfterUpdate events occur: When you close a form, the Exit and LostFocus events occur before the events associated with closing the form (such as Unload, Deactivate, and Close), as follows:Įxit (control) LostFocus (control) Unload (form) Deactivate (form) Close (form) Changing and updating data in a control When the focus leaves a control on a form (for example, when you close a form that contains one or more active controls, or when you move to another control on the same form), the Exit and LostFocus events occur in this order: Open (form) Activate (form) Current (form) Enter (control) GotFocus (control) When you open a form, the Enter and GotFocus events occur after the events associated with opening the form (such as Open, Activate, and Current), as follows: When you move the focus to a control on a form (for example, by opening a form that contains one or more active controls, or by moving the focus to another control on the same form), the Enter and GotFocus events occur in this order: The examples in this article use the Visual Basic for Applications (VBA) format for event names. For example, the event named On Got Focus in the form's property sheet and in the Macro Builder is named GotFocus in the Visual Basic Editor. Note: Microsoft Office Access displays event names slightly differently in the Visual Basic Editor than it does in the property sheet and the Macro Builder.