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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you auto execute command button when Enter is pressed?

Status
Not open for further replies.

yryan

Programmer
May 10, 2002
15
CA
I am still trying to get my program up to speed. I would like the user to be able to press Enter after entering the second piece of information in a text box and the command button would execute. Is it something like 'on Enter goto' and if so where do I put the code? If not could someone tell me what I need to do?

Thanks.
 
What you can do is to trap the Enter Keystroke, and manually fire the button event.

Private Sub txtText_KeyPress(KeyAscii As Integer)

If (KeyAscii = 13) Then
cmdButton_Click()
End If

Exit Sub
Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein


 
Or, in the likely event of your not being a masocist, you could just set the default property on the command button to true - but don't tell anyone I told 'ya!

mmilan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top