I have an MS Access database. The Shift key has previously been disabled but when the user presses F11 , she/he can see the navigation pane . Is there a solution to lock the F11 key to preventing opening the Navigation Pane?
4 Answers
First, the answers here don’t make sense since if you have 100 forms and 100 reports, then you have 200 objects to modify. (this amounts a huge waste of developer time).
Much worse is if a report is displayed, then a form does not have the focus and again you see the nav pane when you hit F11.
Access for 20 years has had the ability to run code and take action for any Fkey or alt key hit to run a macro – and these settings are GLOBAL to the application.
Thus the simple solution is to make an auto keys macro for the application and include F11. This thus will work GLOBAL to the application.
So create a new macro (not a module) called autokeys. The macro will look like this:
You can set function keys in { }
You can also use ^ for control keys (so you can make a global print key) eg: ^P
And you can use + for the shift key, so
+{F11} would be the macro code that runs when you hit shift F11
+^P would be shift+ctrl P
In the above we could have F11 runcode or do anything we want such as launch a form, but as above shows we simply leave the action code inside the F11 block of code blank. So this can be used to have F1 launch a custom access “help” form, or re-map any alt keys that are GLOBAL to the application.
You then simple un-check the show nav pane in the current database start up settings and you are done. Of course as a developer you will hold down the shift key during start to prevent your start up code and forms launching – this also by-passes the auto key macro and ignores all of the settings you “set” in the current database such as hiding the nav pane. So hold down shift key and you can use F11 to show, hide the nav pane and not have your application start up code run so you can work as a developer.

- 42,205
- 3
- 34
- 51
-
2Just to clarify, because it took me a bit to figure out your solution: It works because 'AutoKeys' itself is a keyword here. If you name the Submacro 'AutoKeys' it will look for the {F11}. Genius! My compliments to the chef. – Robert Koernke Oct 25 '17 at 12:16
-
I am facing the exact problem as @albert mentioned. While `+` and `^` are for `Shift` and `Ctrl`, would you please tell me what is the shortkey for `Alt` key'? – Lone Apr 29 '19 at 16:07
-
1There is no support for alt key - they are reserved for labels on a form, and say Te&st will cause alt-s to jump to that label on the form, so no support for alt key exists in the autokeys macro. You can in a form set key preview = yes, and then in the key down event, the alt key (18) code will be returned. And then the key value will be returned as the key value. (so two keys will have to occur - and you have to track the sequence. I don't think you should really try and override the alt key (but with keydown event on a form, it is possible). – Albert D. Kallal Apr 29 '19 at 23:03
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyF11
KeyCode = 0
MsgBox "F11 has been disabled.", vbOKOnly, "Disabled Key"
End Select
End Sub
This can be done this way with other keys as well. Just add another select case statement.
Also make sure you have a way to showing the Navigation Pane if you do decide to make changes in the future - otherwise you may lock yourself out from making changes.
-
Your solution is correct but if the focus is on a different form for each of the forms will have to add this code. I've searched and I found a better solution. autokeys Macro works in all parts of the program. With the F11 key defined in the macro and run the macro to display messages I solve this problem. Thank you for your help dear friend – M.Nabavi Jun 30 '16 at 04:30
-
I agree this does not solve the issue. If you have 200 forms, then you have to modify all the forms. And if a repot is being displayed, then how do you then trap the F11 - as pointed out a autokeys macro is the correct solution. – Albert D. Kallal Oct 11 '16 at 18:36
I was able to find multiple possible solutions from Google:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyF11 Then KeyCode = 0
End Sub
'(you need to set the form's Key Preview to Yes)
or try:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyF11 Then
MsgBox "F11 key is Disabled", vbCritical, "Error"
End If
End Sub
Or this:
File -> Option -> Current DB -> Use Access special Keys (Uncheck)
Ref: Disable F11 with VBA

- 3,156
- 3
- 20
- 38

- 195
- 1
- 12
-
1Your solution is correct but if the focus is on a different form for each of the forms will have to add this code. I've searched and I found a better solution. autokeys Macro works in all parts of the program. With the F11 key defined in the macro and run the macro to display messages I solve this problem. Thank you for your help dear friend – M.Nabavi Jun 30 '16 at 04:30
I think this link will provide the answer you are looking for.
The function you are looking for can be found under File --> Options --> Current Database --> Deselect 'Use Access Special Keys'
This will prevent the user from being able to use F11 Alt+F11, etc.
https://learn.microsoft.com/en-us/office/vba/access/concepts/miscellaneous/allowspecialkeys-property
The user can still hold shift while opening the database, then giving access to these special keys.

- 11
- 2