Microsoft KB Archive/167663: Difference between revisions
(importing KB archive) |
m (Text replacement - """ to """) |
||
Line 53: | Line 53: | ||
When you create a new menu bar in Visual Basic for Applications code, or when you set the Visible property of an existing menu bar to True, the current menu bar disappears. However, if you create a new menu bar or view an existing menu bar by pointing to Toolbars on the View menu, and then clicking Customize, the current menu bar remains visible along with the new one.<br /> | When you create a new menu bar in Visual Basic for Applications code, or when you set the Visible property of an existing menu bar to True, the current menu bar disappears. However, if you create a new menu bar or view an existing menu bar by pointing to Toolbars on the View menu, and then clicking Customize, the current menu bar remains visible along with the new one.<br /> | ||
<br /> | <br /> | ||
This article assumes that you are familiar with Visual Basic for Applications and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information about Visual Basic for Applications, please refer to the | This article assumes that you are familiar with Visual Basic for Applications and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information about Visual Basic for Applications, please refer to the "Building Applications with Microsoft Access 97" manual. | ||
</div> | </div> | ||
Line 63: | Line 63: | ||
<br /> | <br /> | ||
For example, assume your database contains two menu bars: MenuBar1 and MenuBar2. If MenuBar1 is displayed on your screen, the following line of code automatically sets the Visible property of MenuBar1 to False: | For example, assume your database contains two menu bars: MenuBar1 and MenuBar2. If MenuBar1 is displayed on your screen, the following line of code automatically sets the Visible property of MenuBar1 to False: | ||
<pre class="codesample">CommandBars( | <pre class="codesample">CommandBars("MenuBar2").Visible = True | ||
</pre> | </pre> | ||
If MenuBar2 is displayed on your screen, the following line of code automatically sets the Visible property of MenuBar2 to False: | If MenuBar2 is displayed on your screen, the following line of code automatically sets the Visible property of MenuBar2 to False: | ||
<pre class="codesample">CommandBars( | <pre class="codesample">CommandBars("MenuBar1").Visible = True | ||
</pre> | </pre> | ||
In order to display more than one menu bar at a time, you must create your new menu bar or view an existing one through the user interface as follows: | In order to display more than one menu bar at a time, you must create your new menu bar or view an existing one through the user interface as follows: | ||
Line 122: | Line 122: | ||
<div class="indent"> | <div class="indent"> | ||
<p><span class="kbd userinput"> CreateMenuBar | <p><span class="kbd userinput"> CreateMenuBar "ExampleMenu"</span></p> | ||
</div> | </div> | ||
Line 148: | Line 148: | ||
== REFERENCES == | == REFERENCES == | ||
For more information about menu bars, search the Help Index for | For more information about menu bars, search the Help Index for "menu bars," or ask the Microsoft Access 97 Office Assistant.<br /> | ||
<br /> | <br /> | ||
For more information about the Protection property of command bars, search the Help Index for | For more information about the Protection property of command bars, search the Help Index for "Protection property."<br /> | ||
<br /> | <br /> | ||
For more information about creating command bars in code, please see the following article in the Microsoft Knowledge Base: | For more information about creating command bars in code, please see the following article in the Microsoft Knowledge Base: |
Latest revision as of 11:03, 21 July 2020
Article ID: 167663
Article Last Modified on 1/19/2007
APPLIES TO
- Microsoft Access 97 Standard Edition
This article was previously published under Q167663
Moderate: Requires basic macro, coding, and interoperability skills.
SYMPTOMS
When you create a new menu bar in Visual Basic for Applications code, or when you set the Visible property of an existing menu bar to True, the current menu bar disappears. However, if you create a new menu bar or view an existing menu bar by pointing to Toolbars on the View menu, and then clicking Customize, the current menu bar remains visible along with the new one.
This article assumes that you are familiar with Visual Basic for Applications and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information about Visual Basic for Applications, please refer to the "Building Applications with Microsoft Access 97" manual.
RESOLUTION
You can set the Visible property of any existing menu bar in code to make it visible, but this method only allows you to display one menu bar at a time. When you set the Visible property of any menu bar to True, Microsoft Access automatically sets the Visible property of all other menu bars to False.
For example, assume your database contains two menu bars: MenuBar1 and MenuBar2. If MenuBar1 is displayed on your screen, the following line of code automatically sets the Visible property of MenuBar1 to False:
CommandBars("MenuBar2").Visible = True
If MenuBar2 is displayed on your screen, the following line of code automatically sets the Visible property of MenuBar2 to False:
CommandBars("MenuBar1").Visible = True
In order to display more than one menu bar at a time, you must create your new menu bar or view an existing one through the user interface as follows:
- On the View menu, point to toolbars, and then click Customize.
- In the Customize dialog box, select an existing menu bar, or click New to create a new one.
STATUS
This behavior is by design.
MORE INFORMATION
Steps to Reproduce Behavior
- Start Microsoft Access and open the sample database Northwind.mdb.
- Create a new module.
- On the Tools menu, click References.
- In the References dialog box, select Microsoft Office 8.0 Object Library, and then click OK. If that reference is not listed in the Available References box, click the Browse button and search for the file, Mso97.dll.
Type the following line in the Declarations section of your module:
Public strCurrentMenuName As String
Type the following procedure:
'******************************************************************* ' This procedure creates a new menu bar and makes it visible. '******************************************************************* Sub CreateMenuBar(strNewMenuName as String) Dim cmdNewMenu As CommandBar ' Set Global strCurrentMenuName to existing menu for use later when ' toggling. strCurrentMenuName = CommandBars.ActiveMenuBar.Name ' Create a new menu bar. Set cmdNewMenu = Application.CommandBars.Add(strNewMenuName, _ msoBarFloating, True, False) With cmdNewMenu ' Set Protection property to no protection so users can customize ' it. .Protection = msoBarNoProtection ' Show new menu. .Visible = True End With End Sub
- To test this function, type the following line in the Debug window, and then press ENTER:
CreateMenuBar "ExampleMenu"
A new floating menu bar is displayed on the screen, and the original menu bar is hidden from view.
NOTE: All command bars require a unique name. If you use the name of an existing command bar in the strNewMenuName argument of this procedure, you receive the following error message: - To restore the original menu bar to the screen, type the following line in the Debug window, and then press ENTER:
CommandBars(strCurrentMenuName).Visible = True
REFERENCES
For more information about menu bars, search the Help Index for "menu bars," or ask the Microsoft Access 97 Office Assistant.
For more information about the Protection property of command bars, search the Help Index for "Protection property."
For more information about creating command bars in code, please see the following article in the Microsoft Knowledge Base:
159692 ACC97: How to Create Command Bars Using Visual Basic Code
For more information on how to programmatically add and remove items on command bars, please see the following article(s) in the Microsoft Knowledge Base:
172300 ACC97: Command Bar Wizard Available in Download Center
Additional query words: Cmdbar menubar commandbar display show hide invisible disappear appear
Keywords: kbprb kbprogramming kbui KB167663