using 'enter' on a textbox to activate a command button?

  • Thread starter Thread starter neowok
  • Start date Start date
N

neowok

i have atext box which the user types into and then a command butto
next to it to do a search based on their text. what i would like is t
be able to just type the text and press enter in the text box t
perform the same search. Im pretty sure it can be done quite easily a
I remember doing something similar in VB a few years ago, i just can
remember how
 
Hi,

Private Sub txtBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal
Shift As Integer)
On Error Resume Next
If KeyCode = 13 Then Call yourSub
End Sub
I would make a sub that you either call with the enter key or by the
commandButton.
Don't call the sub under the command button.
Regards,
JY
 
Back
Top