Home  Fees/Services  Access Templates  Tutorials  Tutorial Downloads  Articles  Search  Contact  Privacy  Links
VBA Exit Form Event Tutorial
 Home > Microsoft Access Tutorial > Form Event Tutorials > Exit Event





Access Event Tutorials:
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


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.











A Blue Claw Database Design Template:

Airline Reservations Database Template
 








A Blue Claw Database Design Article:

How To Create Faster Access Databases
 



Contact Information

Copyright 2000-2013 Blue Claw Database Design