Turn menu/tool bars on & off

KenHigg

Registered User
Local time
Today, 09:38
Joined
Jun 9, 2004
Messages
13,327
What is the best way to turn all the menu bars and tools bars off and back on when a form opens and closes? Can you just loop through the numerated objects?
 
Check this out for a few tricks... hide all Access tool bars and menu bars

Here is my prefered method for more control...
Code:
Public Function ToolbarsOff()
On Error GoTo Err_ToolbarsOff

    DoCmd.ShowToolbar "Menu Bar", acToolbarNo
    DoCmd.ShowToolbar "Database", acToolbarNo
    DoCmd.ShowToolbar "Relationship", acToolbarNo
    DoCmd.ShowToolbar "Table Design", acToolbarNo
    DoCmd.ShowToolbar "Table Datasheet", acToolbarNo
    DoCmd.ShowToolbar "Query Design", acToolbarNo
    DoCmd.ShowToolbar "Query Datasheet", acToolbarNo
    DoCmd.ShowToolbar "Form Design", acToolbarNo
    DoCmd.ShowToolbar "Form View", acToolbarNo
    DoCmd.ShowToolbar "Filter/Sort", acToolbarNo
    DoCmd.ShowToolbar "Report Design", acToolbarNo
    DoCmd.ShowToolbar "Print Preview", acToolbarNo
    DoCmd.ShowToolbar "Toolbox", acToolbarNo
    DoCmd.ShowToolbar "Formatting (Form/Report)", acToolbarNo
    DoCmd.ShowToolbar "Formatting (Datasheet)", acToolbarNo
    DoCmd.ShowToolbar "Macro Design", acToolbarNo
    DoCmd.ShowToolbar "Utility 1", acToolbarNo
    DoCmd.ShowToolbar "Utility 2", acToolbarNo
    DoCmd.ShowToolbar "Web", acToolbarNo
    DoCmd.ShowToolbar "Source Code Control", acToolbarNo
    DoCmd.ShowToolbar "Visual Basic", acToolbarNo
    
Exit_ToolbarsOff:
    Exit Function

Err_ToolbarsOff:
    If Err.Number = 2094 Then 'Can't find the toolbar. You tried to run a macro that includes a ShowToolbar action or a Visual Basic procedure that includes a ShowToolbar method.
        Resume Next
    Else
        MsgBox Err.Number & " - " & Err.Description
        Resume Exit_ToolbarsOff
    End If

End Function
Code:
Public Function ToolbarsOn()
On Error GoTo Err_ToolbarsOn
    
    DoCmd.ShowToolbar "Menu Bar", acToolbarYes
    DoCmd.ShowToolbar "Database", acToolbarWhereApprop
    DoCmd.ShowToolbar "Relationship", acToolbarWhereApprop
    DoCmd.ShowToolbar "Table Design", acToolbarWhereApprop
    DoCmd.ShowToolbar "Table Datasheet", acToolbarWhereApprop
    DoCmd.ShowToolbar "Query Design", acToolbarWhereApprop
    DoCmd.ShowToolbar "Query Datasheet", acToolbarWhereApprop
    DoCmd.ShowToolbar "Form Design", acToolbarWhereApprop
    DoCmd.ShowToolbar "Form View", acToolbarWhereApprop
    DoCmd.ShowToolbar "Filter/Sort", acToolbarWhereApprop
    DoCmd.ShowToolbar "Report Design", acToolbarWhereApprop
    DoCmd.ShowToolbar "Print Preview", acToolbarWhereApprop
    DoCmd.ShowToolbar "Toolbox", acToolbarWhereApprop
    DoCmd.ShowToolbar "Formatting (Form/Report)", acToolbarWhereApprop
    DoCmd.ShowToolbar "Formatting (Datasheet)", acToolbarWhereApprop
    DoCmd.ShowToolbar "Macro Design", acToolbarWhereApprop
    DoCmd.ShowToolbar "Utility 1", acToolbarWhereApprop
    DoCmd.ShowToolbar "Utility 2", acToolbarWhereApprop
'    DoCmd.ShowToolbar "Web", acToolbarWhereApprop 'I never allow this one because I hight use hyperlinks
    DoCmd.ShowToolbar "Source Code Control", acToolbarWhereApprop
    DoCmd.ShowToolbar "Visual Basic", acToolbarWhereApprop
    
Exit_ToolbarsOn:
    Exit Function

Err_ToolbarsOn:
    If Err.Number = 2094 Then 'Can't find the toolbar. You tried to run a macro that includes a ShowToolbar action or a Visual Basic procedure that includes a ShowToolbar method.
        Resume Next
    Else
        MsgBox Err.Number & " - " & Err.Description
        Resume Exit_ToolbarsOn
    End If

End Function
 
Yes. I like that better. I don't want all the stuff coming back on. Is there a reason why this couldn't just be sub-routine instead of a function?
 
Either or, makes no difference for either way works the same.
 
Have I mentioned lately that this is a great forum?

:D :D :D
 
Okay, Stupid question,
What if you turn off your tool bars, then you cant change anything?

I had the above function to turn off my menu when my form loaded, and if you logged into my database and had admin access, it would turn everything back on.. but that part got removed somehow, now i cant get to any of my menus!!! what do i do?
 
You can try holding down the shift key and then opening your database. Keep it held down until the db is fully loaded.

-dK
 
phew!
thanks for the quick reply, I was freaking out! Holding down the shift key while opening the database allowed me to get into the database window and change my login form! thanks
 
I'm using a login/password to secure certain functions of my db and while insecure, I want to disable the ribbon functions (as if you went into options and disabled Allow Full Menus and Allow Built-In Toolbars) and the navigation pane. I tried the code GHudson posted, but can't get it to work. Now, his post was in 2005, and I use 2007, I'm wondering if the toolbar names have changed and if so, does anyone know what they all are now? I can follow the logic well enough, I just need the correct names.

Any help would be great.
 
The SIMPLEST way? Rename your accdb file to accdr.

Second, is to put the uSysRibbons table in with this:
Code:
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"> 

<ribbon startFromScratch="true"> 

</ribbon> 

</customUI>
Name it HideRibbon

and set it as the default ribbon to open.
 
Actually, although I use 2007 on my machine, the original .mdb was created on a legacy workstation, thus it's not a accdb or accde

Is that going to be a problem?


Nice Bob, I like it! I'll give that a shot. Will I be able to restore the full ribbon bar once an administrator logs in?
 
Without testing, I would venture to guess that the interface is provided by Office 2007, not by the .mdb file, though you still can create the USysRibbons table & set the default ribbon, without changing the file extension.

Couldn't hurt to try.
 
Actually, although I use 2007 on my machine, the original .mdb was created on a legacy workstation, thus it's not a accdb or accde

Is that going to be a problem?


Nice Bob, I like it! I'll give that a shot. Will I be able to restore the full ribbon bar once an administrator logs in?

If you have the uSysRibbons table, it should work for all ribbons if you are using Access 2007 even if it is an mdb file.

When an admin opens the database, if they hold their shift key down it will give you the full ribbons back.
 
I remember that in earlier versions of Access there was a key-combination that restored the default menus and the component browser. With what I'm trying to do restarting while holding shift won't work. In 2007 is there a similar key combo or command that I can execute to restore the default menus/nav page w/o restarting?
 
I remember that in earlier versions of Access there was a key-combination that restored the default menus and the component browser. With what I'm trying to do restarting while holding shift won't work. In 2007 is there a similar key combo or command that I can execute to restore the default menus/nav page w/o restarting?

Nope, it all requires restarting (thanks to the way MS designed it).
 
What is the best way to turn all the menu bars and tools bars off and back on when a form opens and closes? Can you just loop through the numerated objects?

Just discover this step on how to turn back on the menu bar after turning it off

1. Close the database window, leaving just the blank access window
2. Select <VIEW> from the top menu
3. Select <Toolbar>
4. Select <Customize>
5. Select <Command>
6. In Categories List box scroll down and search for Tools
7. Then in Commands list box scroll down and search for StartUp
8. Drag that StartUp to the Top Menu
9. Open the Database Window again and click the Enabled StartUp Menu on top and check Allow Full Menu box.
10. DONE.

Hoping this will be a great help. No programming involve.
 

Users who are viewing this thread

Back
Top Bottom