ACC97: ShowToolbar with Where Appropriate Hides Custom Toolbar
ID: Q176152
|
The information in this article applies to:
SYMPTOMS
Moderate: Requires basic macro, coding, and interoperability skills.
If a macro contains the ShowToolbar action with the Toolbar Name argument
set to the name of a custom toolbar, and if that toolbar is already
visible, running the macro hides the toolbar instead of showing it. This
behavior also occurs when you run a Visual Basic for Applications procedure
containing the ShowToolbar method with the toolbarname argument set to the
name of a custom toolbar.
CAUSE
You have set the Show argument of the ShowToolbar action to Where
Appropriate in your macro, or you are using the constant
acToolbarWhereApprop with the ShowToolbar method in your Visual Basic for
Applications procedure.
The Microsoft Access 97 "Show Toolbar Action" Help topic reads as follows:
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.
However, if you select Where Appropriate or use the constant
acToolbarWhereApprop, a custom toolbar is displayed only when a form or
report to which it is attached is open.
RESOLUTION
To work around this behavior, use either of the following methods.
Method 1
Set the Show argument of the ShowToolbar macro action to Yes, or use the
constant acToolbarYes with the ShowToolbar method in your Visual Basic for
Applications procedure.
Method 2
If you want to set the Show argument of the ShowToolbar macro action to
Where Appropriate, or if you want to use the constant acToolbarWhereApprop
with your Visual Basic for Applications procedure, attach the custom
toolbar to a form or report. To do so, follow these steps:
- In the Database window, select the form or report to which you want to
attach the custom toolbar, and then click Design.
- On the Edit menu, click either Select Form or Select Report.
- On the View menu, click Properties, and in the Form dialog box, click
the Other tab.
- Click in the Toolbar box and select the custom toolbar.
The custom toolbar appears when you open the form or report. If you hide
the toolbar and then run the macro or procedure, the toolbar reappears. If
the toolbar is still visible and you run the macro or procedure, the
toolbar is visible when you set the focus back to the form or report to
which it is attached.
MORE INFORMATION
Steps to Reproduce Behavior
- Open the sample database Northwind.mdb.
- On the View menu, point to Toolbars, and then click Customize.
- In the Customize dialog box, click New.
- In the New Toolbar dialog box, type Custom1 in
the Toolbar Name box, and then click OK.
- In the Customize dialog box, click Close.
- Click the Macros tab in the Database window, and then click New.
- Create the following new macro:
Action
-----------
ShowToolbar
Action Arguments
-------------------------------
Toolbar Name: Custom1
Show: Where Appropriate
- Save the macro as macShowBar and run it. Note that the custom toolbar is
now hidden.
REFERENCES
For more information about ShowToolbar, search the Help Index for
"ShowToolbar Action."
Additional query words:
tool bar
Keywords : McrArg
Version : WINDOWS:97
Platform : WINDOWS
Issue type :
Last Reviewed: April 28, 1999