Code:
varrArray(I)=me.controls(I)
is not making an array from the
TabIndex. The value of I is the index of the control in the Controls collection.
Code:
Dim TextControlValues() As String
Dim var
On Error Resume Next
For var = 0 To Me.Controls.Count
If TypeOf Me.Controls(var) Is TextBox Then
ReDim Preserve TextControlValues(var)
TextControlValues(var) = Me.Controls(var).Text
End If
Next
will make an string array of the values of all textboxes on a userform.
If not how can you move focus from one control to the next in order of the tab index?
Move by WHAT event? The TabIndex is strictly for using Tab, or Shift-Tab. It is a property, not a method, within code. You SetFocus using the index of the control, not the TabIndex.
Of course you COULD set focus by looping through the controls and determining the TabIndex, and then using logic to set the focus. However, this seems very unwieldy. There is no direct connection between a control index -Me.Controls(i) - and Me.Controls(i).TabIndex. For example:
Code:
MsgBox Me.Controls(4).Name & " " & Me.Controls(4).TabIndex
could return (and it does on my userform) "CommandButton2" - which has a
control index = 4 - "0", as it has its TabIndex = 0.
TabIndex is a property, not a method.
Gerry
My paintings and sculpture