Set focus to textbox without selecting text...

Steff_DK

Registered User.
Local time
Today, 14:31
Joined
Feb 12, 2005
Messages
110
How do I do that?

I just want the focus set to the text box, ready to type further.

I need it for the onchange event of the textbox but everytime I type a letter it loses focus...
 
The on change event fires every time you type in the box, use the got focus or on enter events instead
 
you could also add this line to the end of the code that is running:

with me.txtBox
.SetFocus
.SelStart = len(.Text)
End With
 
However, now that I have posted that...

You realize that if you implement this sort of code, then if you return to the field because you realize you left out a word (for instance), every time you type a letter it will go to the end of the text? Can be very frustrating if you have more than just one character to type in a row in the middle of the field.
 
I cannot change the event - it has to run on every change to the textbox.

Will go with rubbernilly's solution - thanks ;)
 
it has to run on every change to the textbox
Are you confusing "every character typed" with "every change"? The on Change event is ONLY useful if you need to trap each character as it is typed. If the user types 100 characters, this event runs 100 times! If you want to do something every time a field is changed but only once then the proper event to use is the BeforeUpdate event if what you are doing is editing and you may need to cancel the event or the AfterUpdate event if you want to do something when the user finishes making his change except to validate the change.
 

Users who are viewing this thread

Back
Top Bottom