VBA Code to Hide Menu Ribbon in MS Access

VBA Code to Hide Menu Ribbon in MS Access

In MS Access, there are multiple ways to protect your code or tool from un-authorized access and edits. Some developers prefers to hide MS Access ribbons from the users to prevent changes by users. Here is one of the way you can hide MS Access Ribbons, Lock the Navigation Pane and hide hidden objects using VBA code
Note: The code is tested on MS Access 2007 and 2013

Excel Tricks

Private Sub Form_Load()
    'Hide the hidden objects in the navigation pane
    Application.SetOption "Show Hidden Objects", False
    'Lock navigation pane
    DoCmd.LockNavigationPane True
    'Disable right clicks and menus
    CurrentDb.Properties("AllowFullMenus") = False
    CurrentDb.Properties("AllowShortcutMenus") = False
    CurrentDb.Properties("AllowBuiltinToolbars") = False
End Sub

To use this code in your MS Access tool, follow below steps:

1. Open an MS Access file
2. Add a new form in MS Access using Create>Form Design menu

Excel Tricks

3. Change the following properties of the form
Auto Center: Yes
Record Selectors: No
Navigation Buttons: No
Scroll Bars: Neither
Pop Up: Yes

Excel Tricks

4. Create an Event Procedure of Form’s On Load event

Excel Tricks

5. Click on ‘…’ to create the procedure in VBA screen

Excel Tricks

Excel Tricks

6. Add the following code in the Load event procedure

    'Hide the hidden objects in the navigation pane
    Application.SetOption "Show Hidden Objects", False
    'Lock navigation pane
    DoCmd.LockNavigationPane True
    'Disable right clicks and menus
    CurrentDb.Properties("AllowFullMenus") = False
    CurrentDb.Properties("AllowShortcutMenus") = False
    CurrentDb.Properties("AllowBuiltinToolbars") = False

Excel Tricks

7. Done, save your code and right click on the form then select Open

Excel Tricks

8. You will notice that ribbons are still visible, don’t worry it will be hidden when you re-open the MS Access file

Excel Tricks

Comments
  • No use for this code since the user can click the more command menu and can select the navigation pane and others to return.

    • excelsirji says:

      Thanks Sanal for your response. There are many other ways also you can bring the controls back like opening the Access file using Shift key. However the code placed in the Form load event should bring the controls back to hidden mode.

Leave a Reply

Your email address will not be published. Required fields are marked *

Are you a Data Enthusiast?

Join us for a ride on your data and automate your stuffs

Business Analytics
Data Analyst
Programming for Data Science
Predictive Analytics for Business