Turn on or off Menu Bar

R

Rob

Hi,
I have an application that someone else has written in Access 2000 and the
following line is triggered by clicking a button on a form, what I would
like to happen is that the default Menu Bar is turned ON if it's not shown
and turned OFF if it is shown. I've tried some code similar to .acToolbarNo
= Not .actoolbarYes but to no avail.

Any help most welcome. Rob

Function RestoreMenuBar()
DoCmd.ShowToolBar "Menu Bar", acToolbarYes
End Function
 
G

Graham Mandeno

Hi Rob

Try this:
If CommandBars("Menu Bar").Visible Then
DoCmd.ShowToolbar "Menu Bar", acToolBarNo
Else
DoCmd.ShowToolbar "Menu Bar", acToolBarYes
End If

Note that the visibility of most command bars can be altered by changing the
Visible property, but this is not the case for the application menu bar,
otherwise you could say:
CommandBars("Menu Bar").Visible = Not CommandBars("Menu Bar").Visible
 
R

Rob

Thank you Graham, worked a treat. Rob

Graham Mandeno said:
Hi Rob

Try this:
If CommandBars("Menu Bar").Visible Then
DoCmd.ShowToolbar "Menu Bar", acToolBarNo
Else
DoCmd.ShowToolbar "Menu Bar", acToolBarYes
End If

Note that the visibility of most command bars can be altered by changing
the Visible property, but this is not the case for the application menu
bar, otherwise you could say:
CommandBars("Menu Bar").Visible = Not CommandBars("Menu Bar").Visible
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Rob said:
Hi,
I have an application that someone else has written in Access 2000 and
the
following line is triggered by clicking a button on a form, what I would
like to happen is that the default Menu Bar is turned ON if it's not
shown
and turned OFF if it is shown. I've tried some code similar to
.acToolbarNo
= Not .actoolbarYes but to no avail.

Any help most welcome. Rob

Function RestoreMenuBar()
DoCmd.ShowToolBar "Menu Bar", acToolbarYes
End Function
 

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