Textbox Highlighting all text

Rob001

Registered User.
Local time
Today, 02:38
Joined
Feb 15, 2003
Messages
18
When i run my form, which contains only one textbox with data bound from a query, the text is fully highlighted. I do not want this to happen - is it possible to stop the text being highlighted?
 
You cannot stop the text from being highlighted, that's the default behavior for an Access text box. However, you can change the text selection once the once you have entered the text box or once it's gotten the focus.

Place code like this in the On Enter or Got Focus event of the text box:
Me.txtBox.SelStart = Me.txtBox.SelLength
That will place the cursor at the end of the text within the text box.
 
Thanks! That helped a lot. Unfortunately the code made the cursor appear half way down the text, but i just added a small bit to the code you provided to make sure it started at the top:

Me.txtBox.SelStart = Me.txtBox.SelLength = 0

Thanks! :D
 
No problem. Not sure why the code didn't work entirely, but there you have it.

If you still want the selection to be at the top, you can simplify the code to be:
Me.txtTest.SelStart = 0

If you want to have another go at it starting at the bottom, try this expression instead:
Me.txtTest.SelStart = Nz(Len(Me.txtTest), 0)
 

Users who are viewing this thread

Back
Top Bottom