Login form vbkeyEnter?

BobJones

Registered User.
Local time
Today, 21:39
Joined
Jun 13, 2006
Messages
42
I have a login form which works fine, but I would like it so that when the caret is in the password field that if the user presses Enter it will do the loginBtn_Click event.
This is what I've tried so far...

Private Sub txtPassword_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbkeyEnter Then
kecode = 0
loginBtn_Click
End If
End Sub

Any ideas or suggestions would be awesome.
 
Try Call loginBtn_Click and make sure the Form's KeyPreview is set to Yes.
 
Nope still doesnt seem to work, just sets the focus on the loginBtn. hmmm
 
well, the big enter key on the kb has as its code vbkeyReturn, perhaps thats what is worng?
 
no need for the sarcasm but thanks yea that worked :)
 
I just tested it and it works but I had to use a different constant.
Code:
If KeyCode = [B][COLOR="Red"]vbKeyReturn [/COLOR][/B]Then
KeyCode = 0
Call loginBtn_Click
End If
 

Users who are viewing this thread

Back
Top Bottom