Why does the text in my text box come up highlighted?

RSW

Registered User.
Local time
Today, 09:46
Joined
May 9, 2006
Messages
178
I have one form that shows an overview of records, and another form that is used for adding or updating new records. Adding a record works fine, but then when a user goes back into the form, all the text in the main text box is highlighted. I don't much care where the focus is, but the text being highlighted looks bad. Does anyone know why this might be happening?
 
It is standard behavior when the Keyboard option In OPTIONS is set to SELECT ENTIRE FIELD. You can change that (but I'm not sure if it is a database specific option or a user specific option).
 
You could put code in the Got Focus event of the text box and use:
Code:
Me.YourTextBoxNameHere.SelStart = 0
Me.YourTextBoxNameHere.SelLength = 0
 
You could put code in the Got Focus event of the text box and use:
Code:
Me.YourTextBoxNameHere.SelStart = 0
Me.YourTextBoxNameHere.SelLength = 0

That worked perfectly. Thank you! (This will be good to understand for the future)
 
An alternative if you want it at the end of the text in the control:
Code:
Me.YourTextBoxNameHere.SelStart = Len(Me.YourTextBoxNameHere.Text)
Me.YourTextBoxNameHere.SelLength = 0

Oh, and it is okay to use .Text here because you are in the control so it has the focus.
 

Users who are viewing this thread

Back
Top Bottom