Deactivate Event

Microsoft Access Visual Basic

Deactivate Event

       

The Deactivate event occurs when a form or report loses the focus to a Table, Query, Form, Report, Macro, or Module window, or to the Database window.

Remarks

When you switch between two open forms, the Deactivate event occurs for the form being switched from, and the Activate event occurs for the form being switched to. If the forms contain no visible, enabled controls, the LostFocus event occurs for the first form before the Deactivate event, and the GotFocus event occurs for the second form after the Activate event.

When you first open a form, the following events occur in this order:

Open Þ Load Þ Resize Þ Activate Þ Current

When you close a form, the following events occur in this order:

Unload Þ Deactivate Þ Close

Example

The following example shows how to hide a toolbar when the focus moves to a different window.

Private Sub Form_Deactivate()
    ' Hide custom toolbar.
    DoCmd.ShowToolbar "CustomToolbar", acToolbarNo
    End  
Sub