Tab box opens with all selected

  • Thread starter Thread starter TES
  • Start date Start date
T

TES

On my forms when I move from tab to tab all the text is selected in the newly
opened text box. Is there some way to have them open with out having
everything selected?

Thanks
 
TES,
Well, actually, you're "moving from control to control, using
the Tab key"... which is the correct way to navigate a form.

Try this in each text control's OnEnter and /or Click event.
I'll use a control named [LastName]

For Tabbing into a control...
Private Sub LastName_Enter()
LastName.SelLength = 0
End Sub

For Mouse Clicking into a control...
Private Sub LastName_Click()
LastName.SelStart = 0
End Sub
--
hth
Al Campagna
Microsoft Access MVP 2007-2009
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 
TES said:
On my forms when I move from tab to tab all the text is selected in the
newly
opened text box. Is there some way to have them open with out having
everything selected?


If you want to change the default behavior for all fields on all forms, you
can change the option setting "Behavior Entering Field", on the Keyboard tab
of the Access Options dialog, from "Select entire field" to "Go to start of
field" or "Go to end of field".
 
Ken,
When I looked up my old code for this question, in my test database,
I had...
LastName.SelStart = Len(LastName)
LastName.SelLength = 0
But, I remmed out the SelStart portion, and it didn't seem to make any
difference
when tabbing into the field. The behavior was the same either with my
=Len(LastName) or your =0.
And, I now question the reason for determining the SelLength...
particularly
as regards ultimately setting the SelLength = 0.
Have you found some advantage to using the SelStart?

Al Campagna
 
Ken,
Agreed. Probably that's why I had the LastName.SelLength =
Len(LastName)
in the first place. I may have done that for an old "start at end of
string" question.
And... good point on the NZ on the Len. I hadn't considered Nulls.
Thanks,
Al

KenSheridan via AccessMonster.com said:
Al:

Assigning a zero to the SelStart property won't make any difference if you
want the insertion point at the start of the value in the control, so
could
be omitted. Where it really comes into play is when positioning it at the
end of the value, which I've found over the years is often requested in
posts
here and elsewhere. In the latter case calling the Nz function to return
a
zero-length string is also necessary, however, to cater for a Null in the
control, e.g. when at a new record, as Len(Null) is Null and the SelStart
property can't be Null. If positioning the insertion point at the end of
the
value assigning a zero to the SelLength property becomes redundant of
course,
as there is nothing beyond that to select.

Ken Sheridan
Stafford, England

Al said:
Ken,
When I looked up my old code for this question, in my test database,
I had...
LastName.SelStart = Len(LastName)
LastName.SelLength = 0
But, I remmed out the SelStart portion, and it didn't seem to make any
difference
when tabbing into the field. The behavior was the same either with my
=Len(LastName) or your =0.
And, I now question the reason for determining the SelLength...
particularly
as regards ultimately setting the SelLength = 0.
Have you found some advantage to using the SelStart?

Al Campagna
Add the following function to the form's module:
[quoted text clipped - 32 lines]
 
Of Course you could avoid the call to LEN entirely by using
LastName.SelStart = 32000

That works as longs as the length is less than 32000 characters

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

Al said:
Ken,
Agreed. Probably that's why I had the LastName.SelLength =
Len(LastName)
in the first place. I may have done that for an old "start at end of
string" question.
And... good point on the NZ on the Len. I hadn't considered Nulls.
Thanks,
Al

KenSheridan via AccessMonster.com said:
Al:

Assigning a zero to the SelStart property won't make any difference if you
want the insertion point at the start of the value in the control, so
could
be omitted. Where it really comes into play is when positioning it at the
end of the value, which I've found over the years is often requested in
posts
here and elsewhere. In the latter case calling the Nz function to return
a
zero-length string is also necessary, however, to cater for a Null in the
control, e.g. when at a new record, as Len(Null) is Null and the SelStart
property can't be Null. If positioning the insertion point at the end of
the
value assigning a zero to the SelLength property becomes redundant of
course,
as there is nothing beyond that to select.

Ken Sheridan
Stafford, England

Al said:
Ken,
When I looked up my old code for this question, in my test database,
I had...
LastName.SelStart = Len(LastName)
LastName.SelLength = 0
But, I remmed out the SelStart portion, and it didn't seem to make any
difference
when tabbing into the field. The behavior was the same either with my
=Len(LastName) or your =0.
And, I now question the reason for determining the SelLength...
particularly
as regards ultimately setting the SelLength = 0.
Have you found some advantage to using the SelStart?

Al Campagna

Add the following function to the form's module:

[quoted text clipped - 32 lines]
Thanks
 
Back
Top