Text being highlighted when form opened

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have one form with two unbound text boxes for the user to edit text that
then gets saved into a table. The existing table value is displayed in these
boxes upon opening the form. Strangely, the contents of whichever box is
assigned to be the first in Tab Order is highlighted when the form is opened.
If the user should hit Delete it would be wiped out. Why is this happening?
I haven't seen this before. There must be something simple I'm missing.
Why doesn't the cursor just go to the beginning of the box? (I have
"Behavior entering field" set to "Go to start of field" in Options and that's
what happens when the user moves between fields.)
 
Use the On Got Focus event of the control to set the cursor to the end of any
existing text ...

Private Sub YourControlName_GotFocus()
Me.YourControlName.SelStart = Me.YourControlName.SelLength
End Sub

R. Hicks
 
Thanks. I tried this for this event and for On Entry and Before Change, but
it doesn't fix the problem. This only changes the cursor placement upon
re-entry into the control, but doesn't affect cursor placement when the form
opens. I still can't get rid of the text being highligfhted in this control
upon opening the form. Any other ideas?
ctdak
 
OK, I discovered what I was doing wrong. The existing values were being
assigned to these text controls after the OpenForm statement but before the
On Open event occurred. As soon as I placed the assigment statements in the
On Open event itself then the text appeared normally with the cursor at the
beginning of the field, and not with the text highlighted.
ctdak
 
Back
Top