Current Event -- Event Procedures

Description

To create an event procedure that is run when the Current event occurs, set the OnCurrent property to [Event Procedure], and click the Build button.

Syntax

Private Sub Form_Current ( )

Remarks

You can’t cancel this event using the CancelEvent method of the DoCmd object. However, you can use the GoToRecord method of the DoCmd object to move to a different record.

See Also

Current Event — Macros.

Example

In the following example, a Current event procedure checks the status of an option button called Discontinued. If the user selects the button, the example runs a query to determine substitute products.


Private Sub Form_Current ()
    If Me!Discontinued.Value = True Then
        .
        .    ' Code to run query.
        .
    End IfSub

The following example sets a form’s Caption property to the SupplierName field. As the focus moves from record to record, the title bar displays the current supplier name.


Private Sub Form_Current ()
    Me.Caption = Me!SupplierName.ValueSub