Public Function GetSortedTabControls(frm As Access.Form) As Collection
  Dim ctrl As Access.Control
  Dim AvailableTabs As New Collection
  Dim I As Integer
  For Each ctrl In frm.Controls
    Select Case ctrl.ControlType
      Case acTextBox, acListBox, acComboBox, acCheckBox
        If ctrl.TabStop = True Then
          If AvailableTabs.Count = 0 Then
            AvailableTabs.Add ctrl.TabIndex
          Else
          
           For I = 1 To AvailableTabs.Count
                 If ctrl.TabIndex < AvailableTabs(I) Then
                  AvailableTabs.Add ctrl.TabIndex, I
                  Exit Function
                 End If
                If I = AvailableTabs.Count Then AvailableTabs.Add ctrl.TabIndex
           Next I
        
         End If
      
       End If
     End Select
  Next ctrl
  Set GetSortedTabControls = AvailableTabs
End Function
Public Function GetNextControl(frm As Access.Form, ActiveCtrl As Access.Control, AvailableTabs As Collection) As Control
  Dim I As Integer
  Dim Active_idx As Integer
  Dim ctrl As Access.Control
  Dim nextIDX As Integer
  Active_idx = ActiveCtrl.TabIndex
  nextIDX = Active_idx
  For I = 1 To AvailableTabs.Count
    If AvailableTabs(I) > nextIDX Then
     nextIDX = AvailableTabs(I)
      Exit For
    End If
  Next I
 
  For Each ctrl In frm.Controls
    Select Case ctrl.ControlType
      Case acTextBox, acListBox, acComboBox, acCheckBox
        If ctrl.TabIndex = nextIDX Then
          Set GetNextControl = ctrl
          Exit Function
        End If
     End Select
  Next ctrl
 
End Function