• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 285
  • Last Modified:

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?
0
seanlhall
Asked:
seanlhall
  • 2
1 Solution
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
Put the code from the command button in the AfterUpdate event of the search text box.

mx
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:

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

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now