To create an event procedure that runs when the GotFocus or LostFocus event occurs, set the OnGotFocus or OnLostFocus property to [Event Procedure], and click the Build button .
Syntax
Private Sub Form_GotFocus( )
Private Sub controlname_GotFocus( )
Private Sub Form_LostFocus( )
Private Sub controlname_LostFocus( )
The GotFocus and LostFocus event procedures have the following argument.
Argument | Description |
---|---|
controlname | The name of the control whose GotFocus or LostFocus event procedure you want to run. |
Remarks
You can use a LostFocus event procedure to validate entered data as the user moves the focus from a control. You can also reverse or change conditions that you set up in the object's GotFocus event procedure.
Other uses for LostFocus and GotFocus event procedures are enabling, disabling, hiding, and displaying other objects.
You can't cancel a GotFocus or LostFocus event.