GotFocus, LostFocus Events — Event Procedures Example

The following example displays a message in a label when the focus moves to an option button.

To try the example, add the following event procedures to a form named Contacts that contains an option button named OptionYes and a label named LabelYes.

Private Sub OptionYes_GotFocus()
    Me!LabelYes.Caption = "Option button 'Yes' has the focus."
End Sub

Private Sub OptionYes_LostFocus()
    Me!LabelYes.Caption = ""        ' Clear caption.
End Sub