[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1026
  • Last Modified:

MS Access - How do I show and hide Full Menus by VBA?

I use keyboard commands to open a hidden form which has buttons that either show or hide the database window.

Private Sub HideDB_Click()
With DoCmd
.SelectObject acTable, "", True
.RunCommand acCmdWindowHide
End With
End Sub

Private Sub ShowDB_Click()
DoCmd.SelectObject acTable, "", True
End Sub

I would like to add buttons that also show and hide the full menus versus the "default minimum menu" or Non-Full Menu (I don't know what Access calls it).

I tried DoCmd.acToolbarYes and acToolbarNo but that didn't work.

Thanks for your help with this.
0
billb1057
Asked:
billb1057
  • 6
  • 2
1 Solution
 
eantarCommented:
Application.CommandBars("MenuName").visible = False.

BTW, you can do this with a form as well. Forms!frmMyForm.Visible = False

Will hide a form.
0
 
billb1057Author Commented:
eantar -- thanks for such a quick answer.  Now another dumb question.  What are the names of the Default Full Menu and the Default Non-Full Menu?  In other words, I think I could use this command for a customized shorter-menu with it's own name, but how do you restore the default Full Menu ("Full Menu Name").visible = True?
0
 
billb1057Author Commented:
... also, can that be assigned to a Click()?  Or does it need a DoCmd?
So something like:
Private Sub ShowMenu_Click()
Application.CommandBars("Full Access Menu - whatever it is called").visible = True
End Sub
 
 
0
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 
eantarCommented:
I can't see why you shouldn't be able to do it from a click.

To hide everything try running a loop

For i = 1 To CommandBars.Count
    Application.CommandBars(i).Visible = False
Next i

I believe the main one is called "Menu Bar"

E
0
 
billb1057Author Commented:

Ok, we're getting a closer - thanks.  This might be more difficult than I thought.
This code works somewhat:

 Private Sub ShowMenus_Click()
Dim i As Integer
For i = 1 To CommandBars.Count
CommandBars(i).Enabled = True
Next i
End Sub

ShowHideMenus.mdb
0
 
billb1057Author Commented:
... continued ...
When CommandBars(i).Enabled = False, then it removes all menus, that would have to be adjusted to provide the minimum commands.  When True, it shows what was there at the beginning.
Now the problem is that when Startup properties turn off "Full Menus", then Access gives a defaul shorter menu (no "Tools" commands, etc).  So, if you start with the smaller menus, the Show/Hide functions that we have will hide everything and then only show the shorter menu (restoring what we started with).
Now I'm guessing the way to show the Full Menu is to itemize all the commands somehow and turn them on.
I posted a very simple file with the form and buttons.  It works fine if you start with the full menu enabled.  Then you can turn everything off and turn on the full menu again.
But if you have the startup which disables the full menu, then you can't get it back.
Thanks again for your help -- we're making good progress.
0
 
billb1057Author Commented:
With some work I figured out what to do.
I created a custom toolbar with the commands that mimic the Access "minimal" toolbar.  Then set this as the startup.  When the "Menu Bar" gets restored, then the full toolbar appears.
0
 
billb1057Author Commented:
Thanks -- this helped and put me in the right direction.
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 6
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now