Turn on or off Menu Bar

  • Thread starter Thread starter Rob
  • Start date Start date
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
 
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
 
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
 
Back
Top