Auto put cursor in first position when clicking in text box?

DocNice

Registered User.
Local time
Today, 10:42
Joined
Oct 6, 2004
Messages
76
I have several fields with text boxes and input masks. When a user clicks in these fields, it puts them in whatever position in the text box they click in. If they click to the far right, it takes them to the right position and doesn't let them type the entire date, formula, etc.

Any way to set the text box so that no matter where they click it automatically starts in the first position?
 
In the OnClick event for your text box try putting

Sendkeys "{Home}"
 
Excellent! Thanks!
 
Avoid SendKeys.

Put this in the OnClick event of your text box...

Code:
    Me.YourTextBoxName.SelStart = 0
 
If the wrong object [program] some how receives the focus during the SendKeys call then who knows what the SendKeys commands will do. From what I have read, SendKeys is frowned upon by most programmers. The only trouble I ever had was when I used it to auto select the options I wanted with the standard Find box, then I could not shut the Access 97 db down. After that I keep reading other posters who dissed SendKeys. I have always been able to accomplish what I need with VBA.
 

Users who are viewing this thread

Back
Top Bottom