Table of contents
Collapse the table of content
Expand the table of content

Enter, Exit Events

office 365 dev account|Last Updated: 6/12/2017
1 Contributor

Enter occurs before a control actually receives the focus from a control on the same form. Exit occurs immediately before a control loses the focus to another control on the same form. SyntaxPrivate SubobjectEnter( )Private Sub_objectExit( ByVal_CancelAs MSForms.ReturnBoolean) The Enter and Exit event syntaxes have these parts:

objectRequired. A valid object name.
CancelRequired. Event status. False indicates that the control should handle the event (default). True indicates the application handles the event and the focus should remain at the current control.

Remarks The Enter and Exit events are similar to the GotFocus and LostFocus events in Visual Basic. Unlike GotFocus and LostFocus, the Enter and Exit events don't occur when a form receives or loses the focus. For example, suppose you select the check box that initiates the Enter event. If you then select another control in the same form, the Exit event is initiated for the check box (because focus is moving to a different object in the same form) and then the Enter event occurs for the second control on the form. Because the Enter event occurs before the focus moves to a particular control, you can use an Enter event procedure to display instructions; for example, you could use a macro or event procedure to display a small form or message box identifying the type of data the control typically contains.

Note To prevent the control from losing focus, assign True to the Cancel argument of the Exit event.

© 2018 Microsoft