Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What is the event name when the <Enter> key is pressed? 1

Status
Not open for further replies.

lookE

IS-IT--Management
Sep 28, 2002
23
0
0
US
I have a login form that has a text box for the user to enter a password and an &quot;OK&quot; command button. After typing in the password, the user has to hit <Enter> twice before the <OK> command button click event is activated.

Does anyone know how I can get the code behind my &quot;OK&quot; command button processed by just pressing the <Enter> key once after putting in the password?

Thank you.
 
The first [ENTER] is exiting the textbox and moving the focus to the command button. The second [ENTER] is the equivalent of the mouse click.

You could put some code in the &quot;On Exit&quot; or &quot;On Lost Focus&quot; event of the textbox calling the button's On Click event.

Sub YourTextBox_LostFocus()
Call YourButton_Click
End Sub

HTH
Lightning
 
Hey lookE,
I think this is what you need to do:

Go to the properties box of your OK command button, on the &quot;Other&quot; tab, and set the &quot;Default&quot; property to &quot;yes&quot;.

There can be only one default control on a form, and when you press enter, if you're sitting on a textbox, or whatever (something besides a different command button), the default control gets the press.

Was that what you were asking?

Paul
 
Tranman,

Thank you. That was exactly what I needed! Quick and easy.

Regards,
lookE
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top