Microsoft Access VBA Programming for the Absolute Beginner
Displays or hides a built-in or custom toolbar.
Syntax
DoCmd.ShowToolbar ToolbarName[, Show]
with the following parameters:
ToolbarName
A String specifying the name of a built-in or custom toolbar.
Show
An AcShowToolbar constant defining the toolbar’s usage. Possible values are acToolbarNo, acToolbarWhereApprop, and acToolbarYes (the default).
Example
The following code displays the Filter/Sort toolbar whenever a form is activated and hides it whenever the form is deactivated:
Private Sub Form_Activate() DoCmd.ShowToolbar "Filter/Sort", acToolbarYes End Sub Private Sub Form_Deactivate() DoCmd.ShowToolbar "Filter/Sort", acToolbarNo End Sub
Comments
-
acToolbarWhereApprop displays a toolbar with its customary windows. acToolbarYes displays a toolbar in all windows.
-
The method affects toolbars only, not menu bars and pop-up menus.
-
You can see a list of the names of available built-in and custom toolbars by selecting the Tools | Customize menu item and clicking on the Toolbars tab.
-
If the Allow Built-in Toolbars check box in the Startup dialog is cleared, the ShowToolbar method can only be used to control the display of custom toolbars.
-
The ShowToolbar method is equivalent to selecting Tools | Customize and checking or unchecking toolbars on the Toolbars tab. This means that any changes your code makes remain in effect permanently, even after Access closes and reopens.
-
To display a particular toolbar with just one or several forms or reports, use an event procedure to display the toolbar in that object’s Activate event and to hide the toolbar in that object’s Deactivate event.
Категории