How to get Tabindex from userform

rajkavikumar

New Member
Joined
Oct 2, 2012
Messages
20
Hello Guys,

I am working on different User forms and I am trying to get tab index of all controls available in user form some forms also have frames and I am creating generic function which will have form as argument But I am facing difficulties as some forms are having frames

I need proper tab index regardless of Frames

EX. 1 user form having 7 control in 4 frames as explained below :
frame 1 -> 2 control
frame 2 -> 1 control
frame 3 -> 3 control
frame 4 -> 1 control

I want all controls list with their ascending tab order

Control 7 -> tab index 1
control 3 - tab index 2
control 1 - tab index 3
control 2 - tab index 4
control 4 - tab index 5
control 5 - tab index 6
control 6 - tab index 7

but due to frames I am facing difficulty:confused::confused:

I am having below code
Code:
Sub TAB_Index(oFrm As UserForm)Dim iCntr As Integer, ArrTab() As String, oControl As Control, oControl1 As Control


iCntr = 0


For Each oControl In oFrm.Controls
    If oControl.Name <> "Frame_Logo" And InStr(1, oControl.Name, "Frame", vbTextCompare) > 0 Then
        For Each oControl1 In oControl.Controls
            ReDim Preserve ArrTab(1, iCntr)
            ArrTab(iCntr) = oControl.Name & iCntr
            iCntr = iCntr + 1
        Next oControl1
    End If
Next oControl

END SUB
 

mohan.pandey87

Board Regular
Joined
Sep 14, 2012
Messages
146
Here you go:

Code:
Sub LMP_Test(ByVal usrFrom As UserForm)


    Dim ctrl        As Control
    Dim frmCtrl     As Control


    For Each ctrl In usrFrom.Controls
        If TypeName(ctrl) = "Frame" Then
            For Each frmCtrl In ctrl.Controls
                Debug.Print frmCtrl.TabIndex
            Next frmCtrl
        Else
            Debug.Print ctrl.TabIndex
        End If
    Next ctrl


End Sub
 

rajkavikumar

New Member
Joined
Oct 2, 2012
Messages
20
Thank mohan.pandey87,

For your quick reply,
but if I do by this way then every frame has its own tab-index as shown below
frame 1 -> 2 control will have tab index 0 to 1
frame 2 -> 1 control will have tab index 0
frame 3 -> 3 control will have tab index 0 to 2
frame 4 -> 1 control
will have tab index 0

but I need all controls' tab-index in ascending order that's the challenge
and even frames also have their own tabindex so first I need to check their tabindex order and then I need to access each frame in ascending order and then get all controls' tab-index from that each frame.

it gonna be huge code I need to do it easily
is there any way you know to do it easily ???
 

Forum statistics

Threads
1,085,495
Messages
5,384,007
Members
401,871
Latest member
allemandi

Some videos you may like

This Week's Hot Topics

Top