Need help to detect event

jvincent

Registered User.
Local time
Today, 15:00
Joined
Apr 30, 2005
Messages
99
Hello,
In an empty field how to detect that the RETURN key has been pressed, i don't know hot to differentiate the RETURN KEY and the field exit by clicking the mouse in an other field because in the 2 cases the value of field is set to "", is there a way to test VbKey in a field ?

This because i want to set my field to a default value only when i press RETURN and i don't want the LostFocus or Exit set my field to this default value if nothing has been typed in my field.
(I must precise that for some reasons in my form the KeyPreview is set to TRUE.)

Thanks in advance for help.
VINCENT.
 
Just replace dofunction with your function or sub or whatever,
Replace TXTBOX with the name of the text box.

Private Sub TXTBOX_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then DoFunction
End Sub
 
Thanks a lot, i'll try it
 

Users who are viewing this thread

Back
Top Bottom