refering to a control by its tab index

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

Guest

hi,

quick question: how does one refer to a control by its tab index using VBA,
as oppose to using the control's name?

thanks in anticipation...
 
AFAIK, you can't. For one thing, the Form Header, Form Detail and Form
Footer sections each have their own tab order. In other words, on a single
form, you can have 3 separate controls that have TabIndex = 0.

If you wanted to live with that restriction, you could loop through all of
the controls on the form, looking for the one that has that value for its
TabIndex. Note that not all controls support the TabIndex property.
 
Miguel said:
quick question: how does one refer to a control by its tab index using VBA,
as oppose to using the control's name?


In addition to Doug's comments, you really do need to know
the control's section. Then you can loop through the
section's Controls collection. E.g. if the control is in
the detail section:

On Error Resume Next
For Each ctl in Me.Setions(acDetail).Controls
ndx = ctl.TabIndex
If Err.Number = 0 Then
If ndx = x Then
'do something
End If
End If
Next ctl
 
Back
Top