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 ways 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
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
3. Change the following properties of the form
Auto Center: Yes
Record Selectors: No
Navigation Buttons: No
Scroll Bars: Neither
Pop Up: Yes
4. Create an Event Procedure of Form’s On Load event
Â
5. Click on ‘…’ to create the procedure in VBA screen
Â
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
7. Done, save your code and right click on the form then select Open
8. You will notice that ribbons are still visible, don’t worry it will be hidden when you re-open the MS Access file
Hope you liked this article !!
Subscribe our blog for new amazing excel tricks.
Time Management is very effective way of managing the available time. Current competitive world is making the time management crucial. There are various ways, tools and techniques by which time management can be done easily.
How to Add Outlook Reference in Excel VBA? To automate Outlook based tasks from Excel you need to add Outlook Object Library (Microsoft Outlook XX.X Object Library) in Excel References. You can follow below steps…
Colorindex in Excel VBA Today let’s try to understand how ColorIndex property in Excel VBA works. It is an easy and effective way to quickly complete the development. ColorIndex property is normally used by VBA…
Dummy Data Generator is an MS Excel based tool which has capability of generating 45 types of data which includes numbers, text, date, time, Memo (long text), Boolean etc.
VBA Code To Add New Sheet In VBA, it is sometime important to add a worksheet at the right place in the Excel. Here is a simple an effective code that adds a new worksheet…
File Properties Tool is an MS Excel based tool which helps you to get File Name, File Path, Date Created, Date Last Accessed, Date Last Modified, Size (MB) and File Type properties of the files. You just need to browse the folder where your files are and click on ‘Get File Properties’ button.
No use for this code since the user can click the more command menu and can select the navigation pane and others to return.
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.
i have tried it in access 2016, and it doesn’t work in access 2016.
Thanks for your query Ivar. You can try following code that works with MS Access 2016: