Link to home
Start Free TrialLog in
Avatar of hncwalker
hncwalker

asked on

CommandBars - how to disable using VBA for different forms

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!!

ASKER CERTIFIED SOLUTION
Avatar of zabba_du
zabba_du

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rvazquez
rvazquez

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.
Avatar of hncwalker

ASKER

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!