Microsoft KB Archive/208715

= ACC2000: Error Creating CommandBar with Duplicate Name =

Article ID: 208715

Article Last Modified on 6/28/2004

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q208715



Advanced: Requires expert coding, interoperability, and multiuser skills.



SYMPTOMS
If you try to create a command bar with an existing name by using Visual Basic for Applications, you may receive the following error message:

Run-time error '5':

Invalid procedure call or argument

If you try to create a command bar with an existing name by using the user interface, you may receive the following error message:

A toolbar named ' ' already exists. Type another name.



RESOLUTION
You cannot create multiple command bars with the same name in any Microsoft Office file, except in Microsoft Word.



MORE INFORMATION
Only Word is able to create multiple command bars with the same name through Visual Basic for Applications because Word needs the ability to have multiple command bars with the same name when two templates are open.

Steps to Reproduce Behavior by Using Visual Basic for Applications
 Open the sample database Northwind.mdb.  Create a module and type the following line in the Declarations section if it is not already there: Option Explicit   Type the following procedure: Function CreateCmdBar Dim cb As CommandBar Set cb = Application.CommandBars.Add("Test1") Set cb = Application.CommandBars.Add("Test1") End Function   To test this function, type the following line in the Immediate window, and then press ENTER: ?CreateCmdBar Note that you receive the following error message on the third line of code:

Run-time error '5':

Invalid procedure call or argument



Steps to Reproduce Behavior by Using the User Interface
 Open the sample database Northwind.mdb.</li> On the View menu, point to Toolbars, and then click Customize.</li> Click the New button in the Customize dialog box. Set the Toolbar name to Test2, and then click OK.</li> Repeat step 3. Note that you receive the following error message:

A toolbar named 'Test2' already exists. Type another name.

</li></ol>

<div class="references_section">