Can't use application.onkey

rede96

Registered User.
Local time
Today, 06:40
Joined
Apr 2, 2004
Messages
134
I wanted to use Application.Onkey within an vba procedure but it doesn't recognise it as a valid method. Is there a specific reference I need to point to?

I'm using Office 365 on windows 10, so assume I'm using the latest version of MS Access.

Thanks
 
application.onkey is an excel application, not an access one

not tested but you could try loading the excel library and creating a new excel application, but suspect it will only execute an excel macro
 
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
 
Last edited:

Users who are viewing this thread

Back
Top Bottom