The simple question is that no, there isn't an easy way within VBA, but if necessary you could write form level keyboard handling code to map tab input to something else.
Something like this will do the trick (it neutralises all tab presses:
Private Sub Form_Keypress (KeyAscii As Integer)
If KeyAscii = vbKeyTab Then
KeyAscii = 0
End If
End Sub
Be sure if you use this to set the Form's Key Preview property to True, so it gets run before any control key related event handlers (it saves you having to code it for every control on the form).
I'm sure some of the people who work with lower level code will know API calls to stop it operating, or map it to something else.
If you don't mind, can I ask WHY you want to disable the Tab key? I accept (a bit grudgingly) that sometimes users have to be protected from themselves but what protection are you giving here? What can be done with the Tab key that cannot be done in another way, and are you not just removing flexibility and providing a maintenance headache?
I have seen many elaborate attempts to restrict inbuilt functionality and they rarely, if ever, add to an application.
I hope I haven't offended by asking this but I guess its one of my pet hates.
Good point - the only time I can remember is when an experienced user of a DOS app was migrating to Windows and pressing ENTER kept triggering the default button rather than moving to the next field - it took a while to get them retrained but they did in the end.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.