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.
This Excel VBA Code converts the excel range into HTML and also can convert Excel to HTML Table to paste data on Outlook Email Body
How to Find Duplicate Files In excel using VBA? Yesterday I was working on my computer and cleaning the drives to make some more space. I was surprised to see so many files saved at…
How to Export Access Data to Excel using VBA Code? Creating a VBA tool in MS Access is always better as compare to MS Excel. MS Access provides better user interface and ability to handle…
How to send bulk emails from outlook using excel VBA? Have you ever felt the need of an Excel based VBA tool or code which can help you to draft Outlook emails in bulk by…
This Excel VBA Code helps to Get User Name. Here is an example environ(username) or Application.username.This macro gets the username from active directory.
VBA Code to list Files in Folder To work on multiple files through VBA programming, you need to have VBA code that can list files in a folder. In this article we will learn three…
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: