I am trying to trap specific key downs for use on a specific form.
Basically, what I want to have happen is when the specified form is open, I want to have the number keys mapped so that when I press the 9 key, it puts the number 9 in the field and then moves to the next field. Same with the other numbers on the keyboard...
So I used the following code:
----in on form load-----------
Me.KeyPreview = True
For the form's keydown property, I created the default private sub
Private Sub form_KeyDown(KeyCode As Integer, Shift As Integer)
'When number key is pressed, enter number plus tab to next field
Select Case KeyCode
Case vbKey9
SendKeys "9~"
Case vbKey8
SendKeys "8~"
Case vbKey7
SendKeys "7~"
End Select
End Sub
Now this works....except it goes into an "extreme" loop, and puts numbers in all the fields continuously until I do a Ctrl-Break.
Maybe I am all wet on using SendKeys....
Hope you guys can help.
Basically, what I want to have happen is when the specified form is open, I want to have the number keys mapped so that when I press the 9 key, it puts the number 9 in the field and then moves to the next field. Same with the other numbers on the keyboard...
So I used the following code:
----in on form load-----------
Me.KeyPreview = True
For the form's keydown property, I created the default private sub
Private Sub form_KeyDown(KeyCode As Integer, Shift As Integer)
'When number key is pressed, enter number plus tab to next field
Select Case KeyCode
Case vbKey9
SendKeys "9~"
Case vbKey8
SendKeys "8~"
Case vbKey7
SendKeys "7~"
End Select
End Sub
Now this works....except it goes into an "extreme" loop, and puts numbers in all the fields continuously until I do a Ctrl-Break.
Maybe I am all wet on using SendKeys....
Hope you guys can help.