HOW DO I FIND OUT WHETHER USER HITS THE ENTER KEY???
GETKEY?........
KEYPRESS?......
THANKS FOR THE HELP
Printable View
HOW DO I FIND OUT WHETHER USER HITS THE ENTER KEY???
GETKEY?........
KEYPRESS?......
THANKS FOR THE HELP
You can check the KeyAscii value in the KeyPress event. Just check if KeyAscii = vbKeyReturn.
Good luck!
The Object_KeyPress event should do the trick. Check for vbKeyReturn or vbKeyEnter.
Do you want to know if it's pressed when your window has the focus? Or anywhere in windows?
If you want to detect the KeyPress regardless of which object has the focus, use the following code.
Code:Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then MsgBox ("Enter was pressed")
End Sub
Private Sub Form_Load()
Me.KeyPreview = True
End Sub