GotFocus

Occurs when an object receives the focus, either by user action, such as tabbing to or clicking the object, or by changing the focus in code using the SetFocus method. A form receives the focus only when all visible controls are disabled.

Syntax

Private Sub Form_GotFocus()

Remarks

Typically, you use a GotFocus event procedure to specify the actions that occur when a control or form first receives the focus. For example, by attaching a GotFocus event procedure to each control on a form, you can guide the user by displaying brief instructions or status bar messages. You can also provide visual cues by enabling, disabling, or showing other controls that depend on the control that has the focus.

Note An object can receive the focus only if its Enabled and Visible properties are set to True. To customize the keyboard interface in Visual Basic for moving the focus, set the tab order or specify access keys for controls on a form.