=> cycle controls in tab index order

  • Thread starter Jonathan Parminter
  • Start date
J

Jonathan Parminter

Hi, is it possible to loop through the controls of a form
in tab index order? How?

Thanks
Jonathan
 
D

Dirk Goldgar

Jonathan Parminter said:
Hi, is it possible to loop through the controls of a form
in tab index order? How?

Possibly you could adapt this routine to your purpose. It just lists
the controls in a form section (e.g., the Detail section) in tab order:

'----- start of code -----
Sub ListControlsInTabOrder(sect As Access.Section)

Dim astrControlNames() As String
Dim ctl As Access.Control
Dim intI As Integer

ReDim astrControlNames(sect.Controls.Count)

On Error Resume Next
'to ignore errors due to controls with no TabIndex

For Each ctl In sect.Controls
With ctl
astrControlNames(.TabIndex) = .Name
End With
Next ctl

For intI = 0 To UBound(astrControlNames)
If Len(astrControlNames(intI)) > 0 Then
Debug.Print astrControlNames(intI)
End If
Next intI

End Sub
'----- end of code -----

When you call it, you have to pass the section object whose controls are
to be listed. For example

ListControlsInTabOrder Forms(0).Detail
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top