By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,040 Members | 1,815 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,040 IT Pros & Developers. It's quick & easy.

looping through toolbars

P: n/a
(RE: Access 2002 SP3)

There are many default toolbars that have the database window icon in
them. Different users will have various ones visible when my app
starts. When my app opens, I only want to display my custom toolbar in
my app and hide all others.

Here are some that some of my users have open...(my list keeps growing
here as I continue testing on different workstations:)

DoCmd.ShowToolbar "Database", acToolbarNo
DoCmd.ShowToolbar "Relationships", acToolbarNo
DoCmd.ShowToolbar "Table Design", acToolbarNo
DoCmd.ShowToolbar "Table Datasheet", acToolbarNo
DoCmd.ShowToolbar "Query Design", acToolbarNo
DoCmd.ShowToolbar "Query Datasheet", acToolbarNo

My list is growing as I said. So instead of listing them one by one,
is there a way via VBA to loop through *all* of the default toolbars,
check to see if that toolbar is visible and if it is , hide it?

Thanks.

Nov 13 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
TechBoy wrote:
(RE: Access 2002 SP3)

There are many default toolbars that have the database window icon in
them. Different users will have various ones visible when my app
starts. When my app opens, I only want to display my custom toolbar in
my app and hide all others.

Here are some that some of my users have open...(my list keeps growing
here as I continue testing on different workstations:)

DoCmd.ShowToolbar "Database", acToolbarNo
DoCmd.ShowToolbar "Relationships", acToolbarNo
DoCmd.ShowToolbar "Table Design", acToolbarNo
DoCmd.ShowToolbar "Table Datasheet", acToolbarNo
DoCmd.ShowToolbar "Query Design", acToolbarNo
DoCmd.ShowToolbar "Query Datasheet", acToolbarNo

My list is growing as I said. So instead of listing them one by one,
is there a way via VBA to loop through *all* of the default toolbars,
check to see if that toolbar is visible and if it is , hide it?


I've had difficulty using the commandbars collection for anything but
explicitly naming the command bar I want to effect. For example to use
a do while loop or for each next.

But the proper way to do this is design the application with its own
menus and turn the default menus off in the startup dialog. It's simple
enough to do, but as with anything, a fair bit of work to decide what
you want your users to see and use.

--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "What's UP, Dittoooooo?" - Ditto
Nov 13 '05 #2

P: n/a
RLN

Yes, it is bombing on this line:
--> DoCmd.ShowToolbar strToolbar, acToolbarNo

Her is my code:
'Set Microsoft DAO 3.6 Object Library" in Tools/References
Dim dbs As Database
Set dbs = CurrentDb
Dim intlooper As Integer

For intlooper = 1 To CommandBars.Count
If CommandBars(intlooper).Name <> "Menu bar" Then
DoCmd.ShowToolbar strToolbar, acToolbarNo 'hide it
Debug.Print "Hiding " & _
CommandBars(intlooper).Name & " equals "_
acToolbarNo/False"
End If
Next intlooper

- - -

When VBA hits the line I referenced above, at this point Access 2002
crashes and I have to restart it.
To get around it, I have to reference each one individually, thus:

DoCmd.ShowToolbar "Form View", acToolbarNo
DoCmd.ShowToolbar "Task Pane", acToolbarNo
DoCmd.ShowToolbar "Database", acToolbarNo
DoCmd.ShowToolbar "Menu Bar", acToolbarNo
DoCmd.ShowToolbar "Print Preview", acToolbarNo
....etc...for all of them.

My bottom line target solution would be to turn off ALL toolbars in my
app and only show my customized toolbar (that does not have a Database
Window icon in it)

If anyone has a better way, let me know (that doesn't crash an Access
2002-SP3 development platform)
----------
"Perseverance - there is no substitute for hard work."
- Thomas Alva Edison

*** Sent via Developersdex http://www.developersdex.com ***
Nov 13 '05 #3

P: n/a
RLN wrote:
Yes, it is bombing on this line:
--> DoCmd.ShowToolbar strToolbar, acToolbarNo


Yes, that makes sense from what I remember.

I just make sure tools->start up is set such that allow built in
toolbars and allow toolbar/menu changes are set to no. I may also
specify a start up menu bar, but mostly I specify menu and/or tool bars
at the form level.

If you do this, your users won't be able to fiddle with menus. You
probably know you can copy builtin menu items (such as print, find) by
holding the ctrl key and dragging the item to the new menu/tool bar. I
also found that the start up property "allow full menus", if not turned
on, prevents some built-in menus from displaying when you use them.
Print menus such as the zoom options is one such item, I think. How you
deal with this depends on your requirements.

--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "What's UP, Dittoooooo?" - Ditto
Nov 13 '05 #4

P: n/a
RLN wrote:
Yes, it is bombing on this line:
--> DoCmd.ShowToolbar strToolbar, acToolbarNo


Yes, that makes sense from what I remember.

I just make sure tools->start up is set such that allow built in
toolbars and allow toolbar/menu changes are set to no. I may also
specify a start up menu bar, but mostly I specify menu and/or tool bars
at the form level.

If you do this, your users won't be able to fiddle with menus. You
probably know you can copy builtin menu items (such as print, find) by
holding the ctrl key and dragging the item to the new menu/tool bar. I
also found that the start up property "allow full menus", if not turned
on, prevents some built-in menus from displaying when you use them.
Print menus such as the zoom options is one such item, I think. How you
deal with this depends on your requirements.

--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "What's UP, Dittoooooo?" - Ditto
Nov 13 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.