Link to home
Start Free TrialLog in
Avatar of seanlhall
seanlhallFlag for United States of America

asked on

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?
ASKER CERTIFIED SOLUTION
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

Private Sub YourSearchTextBoxName_AfterUpdate
   ' your search code here
End Sub

mx
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'.