Dear mybers,
Using "SendKeys" is supposed to work, but I've had mixed success with it, and going by many postings I've read here and elsewhere, many others also have problems with it. A method I've used very successfully, however, allows you to assign any function you want to any special key, i.e. <Esc>, <Up Arrow>, <Down Arrow>, etc. You need to enter the following two subs in code:
Private Sub Form_Load()
Me.KeyPreview = True
End Sub
This sub makes Access look at the special keys when they are pressed.
Then enter:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyEscape
' Process Escape Key events.
Case vbKeyUp
' Process Up Arrow Key events.
Case vbKeyDown
' Process Down Arrow Key events.
Case vbKeyF2
' Process F2 key events.
Case vbKeyF3
' Process F3 key events.
Case vbKeyF4
' Process F4 key events.
Case Else
End Select
End Sub
Under each "Case" enter the code you want executed when the particular key is pressed.
Hope this is helpful.
The Missinglinq
"It's got to be the going,
not the getting there that's good!"
-Harry Chapin