How can I run code on Enter press in a textbox?

I have a text box called TxtSearch and a command button. A search tern is entered in the text box and then the user clicks the command button. How can I have the user enter the search term and just hit enter to run the code?
seanlhallAsked:
Who is Participating?
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
Put the code from the command button in the AfterUpdate event of the search text box.

mx
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:

Private Sub YourSearchTextBoxName_AfterUpdate
   ' your search code here
End Sub

mx
0
 
mbizupCommented:
Have you tried using the AfterUpdate event of the textbox?

I believe that gets fired when the Enter Key is hit, as long as the textbox's Enter Key behavior property is set to 'Normal', not 'New Line In Field'.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.