Disabling shortcut menus for forms and form title bars

One of the reasons that developers disable form shortcut menus is because the shortcut menus available when you click on the form or the form title bar allow users to do things which we don’t want them to do (switch to design view is just one of many).

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.  Or you can do this for specific forms using the form Open and Close events.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

© 2024 Developing Solutions | ScrollMe by AccessPress Themes