Current Event — Event Procedures Examples

In the following example, a Current event procedure checks the status of an option button called Discontinued. If the button is selected, the example sets the background color of the ProductName field to red to indicate that the product has been discontinued.

To try the example, add the following event procedure to a form that contains an option called Discontinued and a text box called ProductName.

Private Sub Form_Current()
    If Me!Discontinued Then
        Me!ProductName.BackColor = 255
    EndIf
End Sub

The next 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.

To try the example, add the following event procedure to a form that contains a text box called SupplierName.

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