Enter, Exit Events

Applies To

Bound Object Frame Control, Check Box Control, Combo Box Control, Command Button Control, List Box Control, Option Button Control, Option Group Control, Subform/Subreport Control, Text Box Control, Toggle Button Control, Unbound Object Frame Control.

Description

These events occur:

  • Enter — before a control actually receives the focus from a control on the same form.
  • Exit — just before a control loses the focus to another control on the same form.

Note Notes

  • The Enter and Exit events apply only to controls on a form.
  • These events don’t apply to check boxes, option buttons, or toggle buttons in an option group. They apply only to the option group itself.

Remarks

The Enter event occurs before the GotFocus event. The Exit event occurs before the LostFocus event.

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 a check box on a form, and then click a report. The GotFocus and Enter events occur when you select the check box. Only the LostFocus event occurs when you click the report. The Exit event doesn’t occur (because the focus is moving to a different window). If you select the check box on the form again to bring it to the foreground, the GotFocus event occurs, but not the Enter event (because the control had the focus when the form was last active). The Exit event occurs only when you click another control on the form.

If you move the focus on another form to a control that doesn’t have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the other form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form, the following events occur:

Exit (for the control on the main form)

LostFocus (for the control on the main form)

Enter (for the subform control)

Exit (for the control on the subform that had the focus)

LostFocus (for the control on the subform that had the focus)

Enter (for the control on the subform that the focus moved to)

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don’t occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

Because the Enter event occurs before the focus moves to a particular control, you can use an Enter macro or 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.

See Also

BeforeUpdate, AfterUpdate Events; GotFocus, LostFocus Events.