Behavior entering field - Acc2K

  • Thread starter Thread starter Edward
  • Start date Start date
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
 
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
 
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
 
Back
Top