Home   Fees/Services   Access Templates   Tutorials  Tutorial Downloads   Articles   Search   Contact  Privacy  Links

VBA Exit





Access Event Tutorials:
Before Insert Event
After Insert Event
After Update Event
Before Update Event
Change Event
Close Event
Current Event
Double Click Event
Error Event
Exit Event
VBA Timer Event
Undo Event

New...
Table-Level Events


Exit Event Programming Visual Basic Example

VBA Form Event Examples - Code Samples

Visual Basic On Exit event occurs just before a control loses the focus to another control on the same form.

Access Database On Exit Event Example:

Here we show how to do validation on a the Due_Date field of a form.  The Due_Date is a required field and we want to make sure the user does not leave it blank on exiting.  Using the On Exit event for validation is not fool proof since this event does not always trigger based on the form and field the user is moving to.

Private Sub LastName_Exit(Cancel As Integer)
If isnull(Me.Due_Date)=True then
    Msgbox "The Due Date is a required field."
    Me.Due_Date.SetFocus
End If
End Sub

We strongly advice that you don't try to over control cursor movement on an Access form using the on exit event.  In the end you will encounter errors and Access will prevent you from going to a specific field or changing data depending on the status of the form.

You'd be better off using Access 2010's new table-level event triggers to perform most data validation with the Before Change table event macro capability.




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



A Blue Claw Database Design Template:

Farmer's Feed Inventory Tracking Database
 








A Blue Claw Database Design Article:

MS Access Versus Other Systems
 











Microsoft Office:
MS Access 2003
Access 2007
Access 2010
Access 2013
Access 2016


Contact Information

Copyright 2000-2017 Blue Claw Database Design