To run a macro when the Enter or Exit event occurs, set the OnEnter or OnExit property to the name of the macro.
When the Enter or Exit event occurs, you can run a macro that uses a GoToControl action to change the tab order based on current data in a control. For example, if the user enters Single in the MaritalStatus field, the focus won’t move to the SpouseName field.
You can use the CancelEvent action in an Exit macro to cancel exiting the control. You can’t use the CancelEvent action in an Enter macro. However, you can use the GoToControl action in an Enter macro to move the focus to a different control.
Enter, Exit Events — Event Procedures.