Am I right in assuming you want to use this in connection with the recent lock database thread you started?
https://www.access-programmers.co.uk/forums/showthread.php?t=294135
If so I assume its to try and block key events like Alt+Tab, Ctrl+E etc
Just to say I had already tried this in the Form_KeyDown event ... but with only limited success
Examples like these do work:
If KeyCode = vbKeyF11 Then KeyCode = 0
If KeyCode = vbKeyTab Then KeyCode = 0
or a message box ...
If KeyCode = vbKeyControl Then ' KeyCode = 0
MsgBox "You have been told about this - please stop pressing the Ctrl key", vbCritical, "Error"
End If
However there is no equivalent code for Alt or Win keys so these don't work
If KeyCode = vbKeyAlt Then 'KeyCode = 0
If KeyCode = vbKeyAltTab Then 'KeyCode = 0
If KeyCode = vbKeyWin Then 'KeyCode = 0
If KeyCode = vbKeyWinE Then 'KeyCode = 0
See Keycode constants in Access help
So I think it needs to be done using Windows API calls and/or a registry hack
It IS possible to disable Windows keys in the registry but the problem is this would apply globally.
It also could be considered as 'virus-like' in its effects as it is affecting the OS behaviour