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

VBA Current Event Close Event Undo Event





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
Table Level Triggers


Current Event Visual Basic Example

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
Else
    Me!Due_Date.BackColor = vbWhite
End If
End Sub

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 the screen.

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()
    DoCmd.Quit
End Sub

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 operation.

Private Sub Form_Undo(Cancel As Integer)
If MsgBox("Do you want to cancel the Undo?",vbYesNo) = vbYes Then
    Cancel = True
Else
    Cancel = False
End If
End Sub

 





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



A Blue Claw Database Design Template:

Lease Contract Admin Software
 








A Blue Claw Database Design Article:

Access Form Design Help
 











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


Contact Information

Copyright 2000-2017 Blue Claw Database Design