The form VBA Current event (or On Current event) activates when the focus moves to a
record on the form. This action makes this record the 'current record'.
This event also occurs after a form is opened, requeried or refreshed.
Current Event Example:
In this example we change the field Due_Date to red when the
value of this field is less than today's date and the field Completed=false.
Private Sub Form_Current()
If Me!Due_Date < Date and Me!Completed=False Then
Me!Due_Date.BackColor = 255
Me!Due_Date.BackColor = vbWhite
The event sequence for the Current Event is:
Open → Load → Resize → Activate → Current
Close Event Visual Basic Example
Visual Basic On Close event occurs when a form is closed and removed from
On Close Event Example:
This is a subroutine we use often on the main menu of an Access
database to prevent the user from attempting to get into the database objects.
In this example Microsoft Access will exit if the user closes the form.
Private Sub Form_Close()
The event sequence when closing a form is as follows:
Unload → Deactivate → Close
VBA Undo Event Example
Visual Basic Undo event happens when the user undoes a change to a combo
box control, a form, or a text box control.
Undo Event Visual Basic Example:
The following example shows how to trap the undo event on a
form. In this case we will confirm that the user wants to cancel the undo
Private Sub Form_Undo(Cancel As Integer)
If MsgBox("Do you want to cancel the Undo?",vbYesNo) = vbYes Then
Cancel = True
Cancel = False