Text Field Help

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

Guest

When a user clicks a field on the form i am working on it inserts the mouse
into the field where the user clicked it. Is there a way through visual
basic (or some other way) to make it so that when the user clicks on the text
field to highlight the contents of the field?

This would be a very nice change to the way in which the form can be used by
the users. While I know the user can tab through the fields to get the same
effect, sometimes they would rather not tab through the 20 or so fields to
get to where they need to enter something.

Any help would be much appreciated,

Sean
 
When a user clicks a field on the form i am working on it inserts the mouse
into the field where the user clicked it. Is there a way through visual
basic (or some other way) to make it so that when the user clicks on the text
field to highlight the contents of the field?

Yes, though I'd be a bit leery of doing so. If I clicked into a field,
typed a single character, and had the entire field vanish to be
replaced by that character I'd be just a mite upset!!

To do it, put the following code in the control's GotFocus event:

Private Sub textboxname_GotFocus()
Me.SelLength = Len(Me!textboxname)
End Sub

John W. Vinson[MVP]
 
As John says elsewhere in this thread, consider carefully whether you really
want to do this - I know I would hate to have to use an application that did
something like that. Are you aware that users can switch between the
insertion point and selecting the entire contents of the field by pressing
F2? Educating the users to use this shortcut might be a better approach.
 
Thanks guys. I'll admit I didn't seem too smitten with their request to do
this. Worst comes to worst I'll add the gotfocus event John mentioned, but I
will try and educate them how to better highlight the field.
 
Back
Top