|
-
Jan 12th, 2000, 06:05 AM
#1
Thread Starter
Junior Member
I have a login screen with just two fields, username and password, and two command buttons, login and cancel. After a user puts in the password, I want them just to hit <Enter> and it automatically login, just as if they had clicked the login command. Is there a way to do this?
Thanks.
-
Jan 12th, 2000, 06:15 AM
#2
Hyperactive Member
Here's how you would do that:
Private Sub Text1_KeyPress()
If KeyAscii = vbKeyEnter Then
KeyAscii = 0
Command1.Value = True
End Sub
------------------
Ryan
-
Jan 12th, 2000, 07:09 AM
#3
Thread Starter
Junior Member
It didn't work. Is there anything else I can do?
-
Jan 12th, 2000, 07:30 AM
#4
Junior Member
I tested this and the 'vbenter' did not work for me either so I replaced it with 13 which is the keycode for 'enter'. This worked for me. Give it a shot.
If KeyAscii = 13 Then
KeyAscii = 0
Command1.Value = True
End If
Good Luck!
-
Jan 12th, 2000, 07:48 AM
#5
Hyperactive Member
sorry, that was supposed to be vbKeyReturn instead of vbKeyEnter.
------------------
Ryan
-
Jan 12th, 2000, 10:10 AM
#6
Member
No need to mess around with the KeyPress event. Just set the Default property of your login command button to True and you're all set. You can also set the Cancel property of your cancel button to True and when the user presses the escape key the cancel button click event will be fired.
Gerald
[This message has been edited by Gerald (edited 01-12-2000).]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|