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 Tools To Create Folders In VBA, you can use MkDir function to create folders in your system or shared drive. To make your work simple, we bring a free Excel VBA tool to create…
In this article we are going to show you how you can delete file or files using a single line of VBA code. 1. Delete a specific file from the folder, 2. Delete specific type of files from the folder, 3. Delete all files from the folder
Excel Add-in helps you to extend the features of Excel application. Using Excel Add-in, you can perform custom actions in Excel such as formatting the data, doing complex calculations which are not possible through Excel formulas, Reading or Writing data in other Excel files and so many more actions.
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…
VBA Code to send Outlook Emails Sending bulk emails is a very common activity, there are many office activities that need a person to send bulk emails to single or multiple recipients. You also may…
VBA Code to Convert MM.DD.YYYY To DD.MMM.YYYY in Excel In different parts of the world, there are different languages spoken and written. With this, a VBA programmer also faces language related issues while writing a…
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: