Disable form menus while allowing control menus

Dale FyeOwner, Dev-Soln LLC
CERTIFIED EXPERT
Published:
Edited by: Andrew Leniart
You can disable Form and Title shortcut menus without disabling the shortcut menus for other controls

One of the reasons that developers disable form shortcut menus when deploying an application is because of the shortcut menus that pop up when you right click on the form title or the form itself, allow users to do things we, as developers, don't want them to do.  Both the forms Title menu (article image) and the form Form View Popup Menu (below) offer a bunch of options you don't want your users to see.

  

As part of the work I did to develop the Access Shortcut Tool, I ran across a trick that will allow you to disable the shortcut menus associated with the title bar, and the form itself, without disabling the shortcut menus associated with controls on your form(s).  You might still want to use alternate shortcut menus for some of the controls as well, but by adding two lines of code to your application load and unload processes, you can disable all of the form Title and Form shortcut menus.


Those two lines are:


Commandbars(127).Enabled = false     'This is for the form Title Bar menu

Commandbars(6).Enabled = false          'This is the Form View Popup menu


You only need to run this code once, when you load your application, not for each form.


Technically, you don't need to reverse that when you exit your application because the Enabled property value of those two commandbars does not persist when you close Access.  However, it does persist if you simply close the application where that code is used, and open another Access application.  To be on the safe side, I would encourage you to run that code with Enabled = True when you close your application.


Dale Fye

My Profile

3
682 Views
Dale FyeOwner, Dev-Soln LLC
CERTIFIED EXPERT

Comments (1)

crystal (strive4peace) - Microsoft MVP, AccessRemote Training and Programming
CERTIFIED EXPERT
Top Expert 2015

Commented:
nice to know! thank you, Dale

Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.