ShowToolbar Action

Description

You can use the ShowToolbar action to display or hide a built-in toolbar or a custom toolbar. You can display a built-in toolbar in all Microsoft Access windows or just the view in which the toolbar is normally displayed (for example, the Form view toolbar in Form view).

Setting

The ShowToolbar action uses the following arguments.

Action argument

Description

Toolbar Name

The name of the toolbar you want to display or hide. The Toolbar Name box shows all the built-in toolbars in Microsoft Access, followed by any custom toolbars you’ve defined in the current database. This is a required argument.

If the Allow Built-In Toolbars check box in the Startup dialog box (which is displayed when you click Startup on the Tools menu) is cleared, the Toolbar Name box shows only the custom toolbars you’ve defined, and you can use this action only to display and hide custom toolbars.

If you run a macro containing the ShowToolbar action in a library database, Microsoft Access looks for the toolbar with this name first in the library database, then in the current database.

Show

The indicator whether to display or hide the toolbar and in which views to hide or display it. The default is No (hide the toolbar).

For built-in toolbars, you can select Yes to display the toolbar in all Microsoft Access windows that become active, Where Appropriate to display the toolbar only in the view it’s normally displayed in (as Microsoft Access does by default), or No to hide the toolbar in all Microsoft Access windows.

For custom toolbars, you can select Yes or Where Appropriate to display the custom toolbar in all Microsoft Access windows that become active or No to hide the toolbar in all Microsoft Access windows.


You can use this action in a macro with conditional expressions to display or hide one or more toolbars depending on certain conditions.

Remarks

If you want to show a particular toolbar on just one form or report, you can set the OnActivate property of the form or report to the name of a macro that contains a ShowToolbar action to show the toolbar. Then set the OnDeactivate property of the form or report to the name of a macro that contains a ShowToolbar action to hide the toolbar.

The ShowToolbar action has the same effect as clicking Toolbars on the View menu, and selecting or clearing a specific toolbar.

Note The ShowToolbar action enables you to specify whether a built-in toolbar is displayed in all Microsoft Access windows or just the view in which it’s normally displayed.

The built-in toolbars are also not available to display or hide using this action if you set the AllowBuiltInToolbars property to False (0) in Visual Basic, or if you set the Built-In Toolbars Available option to False in Visual Basic using the SetOption method.

To run the ShowToolbar action in Visual Basic, use the ShowToolbar method of the DoCmd object.

See Also

Event Properties; GetOption, SetOption Methods; ShowToolbar Method.