CommandBars - how to disable using VBA for different forms

hncwalker
hncwalker used Ask the Experts™
on
I am looking for a way to disable my custom CommandBar on all forms except when I want it to appear, which is a datasheet view inside a form.  Any help would be greatly appreciated!!

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
Have you tried either of these?

CommandBars("elitaToolbar").Visible = False

CommandBars("elitaToolbar").Enabled = False
'where elitaToolbar is the name of your commandbar

Hope it helps..
geo

Commented:
If your datasheet is the form itself, in the form's property sheet, you will see a Toolbar property in the Other tab.  Plug in your toolbar in there.

If your datasheet is a subform, try doing this...

In your Got_Focus event of your subform control, put in:

DoCmd.ShowToolbar "NameOfCommandBar", acToolbarYes

In the Lost_Focus event:

DoCmd.ShowToolbar "NameOfCommandBar", acToolbarNo

Hope this helps.

Author

Commented:
Thank you so much!

This worked beautifully.  When I closed the datasheet view of the form, I had to add this code to the open form event so that the toolbar would not show when I went back to the original form:
    '-------------------------------------
    ' lets try to disable the commandbar
    '-------------------------------------
    CommandBars("new menu").Visible = False

You are awesome!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial