AfterUpdate Event

 

Access Event Tutorial – Afterupate

Form events offer you the power to control all aspects of the user interface including control over navigation, implementation of data integrity and validation procedures through visual basic event programming. Afterupdate event is triggered and the entire record is updated and the data is saved in the database when:

  • The control loses the focus

  • The user presses ENTER or TAB

  • The focus leaves the record

  • The user clicks Save Record on the Records menu

Access Event Tutorial – AfterUpdate VBA:

In this AfterUpdate event example we requery a grand total field on the master form after records are updated in the detail form:

Private Sub Form_AfterUpdate()
Form_F_Order_Total_Price.Form.Requery
End Sub

Note: When validating form field values it is important to know that the OldValue property isn’t set to the updated value until after the event for the form occurs.

If you decide to cancel the update the value of the OldValue property replaces the changed value in the control.

New with Microsoft Access 2010 are table level event procedures.  These events are defined in design view or datasheet view of the table.  You can create a macro run run code now for the After Update table event.  This new capability significantly extends the power and flexibility of Access 2010.

More AfterUpdate Examples & Discussion:

Current Value Previous Field Value

Access database calculations – compare old vs new form field values. Finally in the After Update event we have both the new and old values available for

Global Variables as Query Parameters

This is easily done by adding the following line of code in the After Update event… GBL_Project_ID=Project_Combo. In the query there’s no more trying to

Private Sub Qty_Out_AfterUpdate()
Dim db As DAO.database ‘ note that we always use DAO database and recordset operations because we always use Microsoft Jet databases.

Form Triggers
Table Triggers
Form Flags
Table Triggers
Record Flags
Record Events