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.
VBA Code to Browse a Folder Quite often a VBA developer requires code to browse a folder. This is mainly for saving the output file or reading the input file(s). Below is the VBA code…
Learn how to write your first VBA macro in Excel to automate repetitive formatting tasks across multiple worksheets. This beginner-friendly guide will walk you through the process step-by-step, from recording your actions to customizing the code for your specific needs.
VBA Code to Filter Data in Excel Here is an easy reference code which filters data in the sheet. In the code, we have filtered the data in three steps. Step 1: Remove existing filter from…
Working with huge data is always exciting and challenging. From 2007 version onward, Excel is supporting more than a million rows in each worksheet. One of the common problems with huge data is “Duplicates” and the bigger problem is to identify and remove these duplicates. In this article, we will be sharing 4 ways to delete duplicate records from your data.
Merge Excel Files From last few months, we have been receiving frequent requests from users for a VBA tool which can consolidate Excel files from a folder. So here we come with one more free…
Did you come across any requirement where you want the user to interact with a sheet only through VBA Form? Here is a simple code which can help you.
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: