Selecting SStab individual tab container

debrafry
debrafry used Ask the Experts™
on
I am trying to loop through controls on an ssTab control and collect the control name and value (this is not a problem), however, I either need to collect:

1) a value for the tab that the control was on or

2) specify which tab to loop through individually

The code that I have been experimenting with is:

   Dim dynCtlName() As String
   Dim dynCtlValue() As Variant
   Dim MyCtl As Control
   Dim i As Integer
   
   
   i = 0
   For Each MyCtl In Me.tabDetails.container
      If TypeOf MyCtl Is TextBox Then
         If MyCtl.Text <> "" Then
            ReDim Preserve dynCtlName(i)
            ReDim Preserve dynCtlValue(i)
            dynCtlName(i) = MyCtl.Name
            dynCtlValue(i) = MyCtl.Text
            i = i + 1
         End If
      ElseIf TypeOf MyCtl Is CheckBox Then
         If MyCtl.Value = 1 Then
            ReDim Preserve dynCtlName(i)
            ReDim Preserve dynCtlValue(i)
            dynCtlName(i) = MyCtl.Name
            dynCtlValue(i) = MyCtl.Index + 1
            i = i + 1

         End If
      End If
   Next
However this does not tell me at present the tab that the control was on.
Any suggestions gratefully received.

Thanks
Debs
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
I would suggest placing each control from a particular tab into a frame that will fill the tab.  Then it's just a matter of checking the control's parent.  If it's the desired frame, then you know what tab it's one.

For example, if you have three tabs, create a control array of frames (probably borderless):  fmeTab(0), fmeTab(1), fmeTab(2).  Place all controls on tab-0 into fmeTab(0)

When cycling through the controls:

    If MyCtl.Container.Name = "fmeTab" Then
      MsgBox MyCtl.Name & " is on tab " & MyCtl.Container.Index
    End If

Author

Commented:
Was just working in type exact same solution, only problem being when there are other controls in frames already on that tab, therefore producing a frame within a frame, at most there would only be one other frame within the "main" frame.

Thank you for your time.
 

Commented:
Yes, the frame-within-frame is a problem.

Another possibility is to actually temporarily set the tab and see which controls are enabled and/or visible.  I think I'd done something like that at one point, but obviously this can be a problem if controls are disabled even when the tab is shown.

Good luck, and thanks for the "A"-grade.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial