Cursor Position when entering control on form

  • Thread starter Thread starter akellis
  • Start date Start date
A

akellis

When tabbing from control to control on a form, the normal default
behavior is to highlight the entire contents of the field. I want to
be able to tab to a control and have the cursor set to the beginning of
the value in the field instead of highlighting the entire value.

I know I've seen that done before, but I can't remember how it was
done, and I can't find it anywhere in MS-Access help files.

Please help! Thanks.
 
In the control's GotFocus event, put code like:

Me.MyTextBox.SelStart = 0

If you like, you can have a more generic routine, along the lines of:

Function NoHighlight()

If TypeOf Screen.ActiveControl Is TextBox Then
Screen.ActiveControl.SelStart = 0
End If

End Function

and simply put =NoHighlight() for the GotFocus property. (If you select the
text boxes and look in the Properties window, you can do this for all of
them at once)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top