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!

Command Button

Status
Not open for further replies.

cwalshe

Programmer
May 28, 2001
84
IE
Hi there,

I have several commands buttons on a form but I would like that one of them operate whenever the Return/Enter key is pressed on the keyboard.

Any ideas...

Cormac.
 
Set the 'Default' Property of the command button to true.
 
Try the previous suggestion first. If that doesn't work, set the form's KeyPreview property to True and trap the Enter key in either the form's KeyPress or KeyDown event:

Private Sub Form1_Keypress(KeyAscii as Integer)
Select Case KeyAscii
Case 13 ' Enter
KeyAscii = 0
Command1_Click
End Select
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top