Programmatically Hide all custom toolbars

S

Silvio

Hello, how can I programmatically hide all my custom toolbars without having
to specify each toolbar name? In my database, I am showing toolbars based on
the user credential, (Admin, user, guest, etc.)

I know I can do this:

If Me.GroupID = 1 Then
DoCmd.ShowToolbar "GuestToolbar", acToolbarNo
DoCmd.ShowToolbar "UserToolbar", acToolbarNo
DoCmd.ShowToolbar "AdminToolbar", acToolbarYes
Exit Sub
End If

But, instead of having to specify all the toolbar names to hide (in this
example I have used "GuestToolbar" and UserToolbar) I would like to hide all
of them regardless of the name, and at the end display only the one I want
(In this example "AdminToolbar"). I guess should be something like:

DoCmd.ShowToolbar "*", acToolbarNo
DoCmd.ShowToolbar "AdminToolbar", acToolbarYes

Thank you,
Silvio
 
S

Silvio

Alex: I am getting a "User-defined type not defined" error message when
compiling
for the line: Dim cmb As CommandBars

Any other idea?

Thank you,
Silvio
 
D

Douglas J. Steele

You need to add a reference to the appropriate Office library (Microsoft
Office n.0 Object Library, where n is 8 for Access 97, 9 for Access 2000 or
10 for Access 2002, 11 for Access 2003)

Note, too, that Alex said to use

dim cmb as commandbar

not

dim cmb as commandbars
 
S

Silvio

Even using commandbar instead of commandbars I am getting the same message. I
am using Access 2003. How do I add a reference to the appropriate Office
library? I ahve no idea what you talking about sorry. My access programming
experience is limited.
 
D

Douglas J. Steele

Go into the VB Editor, and select Tools | References from the menu bar.
Scroll through the list of available references until you find the reference
Microsoft Office 11.0 Object Library, select it, and click OK to exit the
dialog.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Toolbars Hide 2
ShowToolbar method not working? 3
Access 2007 toolbars 2
Hide ribbon event not working 11
Custom MenuBar 2
invisible toolbar 1
Hide menus is Global? 0
Hide menus is global? - repost 1

Top