commandbar question

M

Mark Andrews

I am trying to hide all menus except one custom menu.

This code hides all menus:

Public Function HideAllMenus()
Dim i As Integer
For i = 1 To CommandBars.Count
CommandBars(i).Enabled = False
Next i
End Function

This was my first attempt (it does not compile):
I get an error on the "Dim cbarMenu as CommandBar" line (user defined type
not defined). I have references to Microsft Access 11 object library
MSACC.OLB.

Public Function HideAllMenus()
'Hides all menus except RPTMenu

Dim i As Integer
Dim cbarMenu As CommandBar

For i = 1 To CommandBars.Count
CommandBars(i).Enabled = False
Next i

Set cbarMenu = CommandBars("RPTMenu")
cbarMenu.Enabled = True

End Function


Help,
Mark
 
D

Daniel Pineault

Firstly, you could use the Tools-Startup and then uncheck whichever toolbars
you wish to disable.

Alternatly, take a look at the following links as they cover this subject
with various approaches.

http://www.access-programmers.co.uk/forums/showthread.php?t=97578
http://www.tek-tips.com/viewthread.cfm?qid=1499473&page=1

--
Hope this helps,

Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples: http://www.devhut.net
Please rate this post using the vote buttons if it was helpful.
 
M

Mark Andrews

On both of these responses:

1. That's where I got the code to begin with.
2. I already have a reference to Microsft Access 11 object library MSACC.OLB

Note: The code to disable all commandbars works fine.

However adding a line:
Dim cbarMenu As CommandBar

will cause it to not compile.

I did notice some of the articles saying the Microsoft Access 11 object
library should reference a DLL where mine references "MSACC.OLB"

I'm guessing it is some kind of reference issue. I had reference issues
after installing Access2007 and had to uninstall it to get Access2003
working again.

Any further help you could provide???

Thanks in advance,
Mark
 
M

Mark Andrews

Chris,

Thanks for pointing out my lack of attention to detail!

That made everything work perfectly!

I guess I had it in my mind that since the commandbars collection worked
that it was something about the
Microsoft "Access" 11.0 Object library that was screwed up on my machine
(since an individual Commandbar
would not work).

Thanks again,
Mark
 

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

Top