Who can explain this sellength behavior?

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

Guest

I have this code relating to a combobox that does not
select the text as it should:
Private Sub cboDistrict_GotFocus()
Me.cboDistrict.SetFocus
Me.cboDistrict.SelStart = 0
Me.cboDistrict.SelLength = Len(Me.cboDistrict.Text)
End Sub

When I add this code before the End Sub, the code works!
(the combo text is selected) but then I have the
superfluous message box.

Dr. Phil, how can I get the text in the combobox to be
selected properly?
 
Take out the line that has the "SetFocus" on it cause the control already
has the focus when the "GotFocus" event is triggered on the textbox. See if
that doesn't resolve your problem cause what may be happening, it may be
trying to run the "GotFocus" code a second time as it's already in the
process of running the first time.
 
Tried that, still no luck.
-----Original Message-----
Take out the line that has the "SetFocus" on it cause the control already
has the focus when the "GotFocus" event is triggered on the textbox. See if
that doesn't resolve your problem cause what may be happening, it may be
trying to run the "GotFocus" code a second time as it's already in the
process of running the first time.

--
Ronald R. Dodge, Jr.
Production Statistician
Master MOUS 2000




.
 
That's the same coding method I have used for certain combo boxes. If you
could give more specifically, the behavior you are getting, then maybe we
could be of more help. I haven't had any issues with this particular
coding. I am using Access 2002, so maybe there's a bit of a difference, but
I even had this in Access 97 and had no problems.

The only thing that I can think of is to check the DB Options under Tools,
Options, Keyboard, Behavior entering field, but regardless what that is set
to, that behavior should only take place at the time the object gets the
focus, which then the GotFocus Event is ran, so what has been set last is
what it should show.
 
Must be a bug in Access 2000 - changed the option w/o luck.
I don't know if this is related, but when I click on the
tab of a tab control with a Click event programmed - that
does not work (fire) either. Tried that on another
machine, same result. We're using Dell OptiPlex desktops.
 
Take out the .Text reference. (.Value is the default property and that is
what you want to use.)

Larry Linson
Microsoft Access MVP
 
Must be a bug in Access 2000 - changed the option w/o luck.
I don't know if this is related, but when I click on the
tab of a tab control with a Click event programmed - that
does not work (fire) either. Tried that on another
machine, same result. We're using Dell OptiPlex desktops.

Selecting a tab in a Tab control does not trigger the Click
event, it's the Change event that fires. The Click event
responds to some other obscure activity.
 
Marshall Barton said:
Selecting a tab in a Tab control does not trigger the Click
event, it's the Change event that fires. The Click event
responds to some other obscure activity.

Specifically, clicking the border of the control; not the tabs.
 
I can see why this person is using the Text property rather than the Value
property.

Value Property is going to store the data in whatever data type it fits in
best with, which to some extent is based on the formatting or if bound to a
field in a certain table, it will obviously be stored in whatever data type
that field set to be stored in. By default though without the formatting
done and if it's not bound to a field, it will store the data as string data
type.

Text Property is the text as it is shown in the textbox, which is largely
based on the format property of the textbox. Therefore, if you get a value
that's something like 435.234296432640213, but yet, the Format is set to
"#.000", the Text Proeprty will be "435.234". Therefore, the length of both
of these numbers are going to be different, which is the very reason why I
can see why this person has used the Text Property of the textbox rather
than the Value Property of the textbox.

The same can be set about a textbox that stored Date/Time as the value will
be in it's numeric form while the display of it is based on the format of
the value.

Now, the only down side to this, the Text Property of the textbox can only
be seen when the textbox has the focus.
 
Back
Top