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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting Focus to a txtbox using the OnKeyDown Event

Status
Not open for further replies.
Aug 9, 2001
23
0
0
GB
I have used the following code in the OnKeyDown event of a txtbox to run a command held on the click event of a button (the outcome of which sets the focus to the txtbox):

If KeyCode = 13 Then cmdLogIn_Click

The code works fine when the button itself is pressed (the txtbox aquires the focus), but the OnKeyDown event does not set focus back to the txtbox. It runs the cmdLogIn_Click code fine, but the focus remains with the button. I have littered txtbox.setfocus all over the place, but nothing seems to work.

Any ideas?

Thom
 
Have you attempted to SetFocus to another control on the form and then back to the TextBox.

PaulF
 
Certainly have! You can see the cursor flick into the txtbox then settle on the button.

Thom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top