Behavior entering field - Acc2K

E

Edward

Can I programatically force either a 'Select Entire Field' or 'Go To End Of
Field', upon entry to a control/field? I have 1 or 2 fields in a tabbed
form that, depending on if its a new or pre-existing record, selects my
entire text field upon arrival. I have the Options, Keyboard choices set to
"Go to end of field' but it ignores that when this occurs.

I need to be sure and send the cursor to the end of a last field or to a
label upon entry to a different page-tab, to prevent goofy users from
starting to key over existing wanted data, without first selecting a field.

Any suggestions appreciated.
Ed
 
K

Ken Snell [MVP]

You can use the GotFocus event to move the cursor to the end of the
textbox's contents (note: will work only if the user tabs to the textbox;
won't go to the end if the user clicks into the textbox, but then no text
will be selected):

Private Sub TextBoxName_GotFocus()
On Error Resume Next
Me.TextBoxName.SelStart = Len(Me.TextBoxName.Value)
Me.TextBoxName.SelLength = 0
End Sub
 
E

Edward

Thanks Ken!
That solved my problem.

Ken Snell said:
You can use the GotFocus event to move the cursor to the end of the
textbox's contents (note: will work only if the user tabs to the textbox;
won't go to the end if the user clicks into the textbox, but then no text
will be selected):

Private Sub TextBoxName_GotFocus()
On Error Resume Next
Me.TextBoxName.SelStart = Len(Me.TextBoxName.Value)
Me.TextBoxName.SelLength = 0
End Sub
 

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

Top