Activate, Deactivate Events — Event Procedures Example

The following example shows how to display a custom toolbar named CustomToolbar when a form receives the focus and to hide it when the focus moves to a different window.

To try the example, add the following event procedure to a form that has a custom toolbar called CustomToolbar.

Private Sub Form_Activate()
    ' Display custom toolbar.
    DoCmd.ShowToolbar "CustomToolbar", acToolbarYes
End Sub

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