I want to know on which tab of the sstab control is a control is located.

I want to know on which tab of the sstab control is a control is located.

I can find out which that the control is part the sstab control by checking the container of the control. I only have 1 sstab control. this control has 6 tabs
 if typeof textbox1.container is sstab then ...

what I want is or
 if typeof textbox1.container is sstab.tab(1) then ...

What I am doing is

  Dim oText As Control
  For Each oText In Me.Controls
     If TypeOf oText Is TextBox Then
      If TypeOf oText.Container Is SSTab(0) Then
         Set oText.DataSource = adoReceiveRS
       elseif TypeOf oText.Container Is SSTab(1)
        Set oText.DataSource = adoCalibrateRS
       elseif TypeOf oText.Container Is form
        Set oText.DataSource = adoMeterRS
       End If
    End If

  Next





LVL 1
jdesharnaisAsked:
Who is Participating?
 
jklmnConnect With a Mentor Commented:
Hi idesharnais,

I agree with Dave_Greene that there is no property for a control to point to a Tab.
I would set the Tag property of the controls to do what you need: say, set "0" for the controls in Tab(0) and so on:-)
0
 
Dave_GreeneCommented:
Will look into this for you...  but it would be easier to name the controls so that you could access them easier.  eg  txtMetControlName for "Meter" tab
0
 
jdesharnaisAuthor Commented:
I was considering parsing  through the name of the control  but I thought, just posibly, it could be done dynamically.
I don't need it to work, I just thought I may be able to take advantage of the way they are already grouped.
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
Dave_GreeneCommented:
Here is what I would do, since you cannot readily resolve the parent tab

I would put a frame on each tab, call it whatever makes sense for that tab, change the borderstyle to 0 so you don't know the frame is actually there.  Copy all of your controls onto the frame and adjust the frame so that everything looks the way it did before you started.

Then in code try this

Private Sub Command1_Click()
   Dim oText As Control
   For Each oText In Me.Controls
      If TypeOf oText Is TextBox Then
       If TypeOf oText.Container Is Frame Then
          MsgBox oText.Container.Name
          MsgBox oText.Name
        End If
     End If
   Next
End Sub

Then by the frames name you will know what tab it is on...

0
 
jdesharnaisAuthor Commented:
Nice try but oText.Container.Name is not valid .name doesn't work.  I know it is in the debugger.
Since I can't find the name the the control frames would work because there is more than 1
0
 
Dave_GreeneCommented:
Well if you put the frames into a control array, this should work

MsgBox oText.Container(oText.Container.index).Name
0
 
jdesharnaisAuthor Commented:
sorry I had a typo so the .name does work although you don't need the .name becase you get the name of the control by going control.container.  You idea would work but I do have a few controls that already are in frames.

I guess what I am wishing for is something like sstab.tab(0).controls

Sound like I'll have to do it the long way
0
 
Dave_GreeneCommented:
Yea, I tried to get at it the way you are describing, but with no luck.  Well, atleast you know it wasn't something you were doing...  It just doesn't work that way.

Cheers
0
 
VBTomCommented:
I was gonna say that you should set the tag property of each control to the index of the tab that they are on opon creation.  That is the easiest way. ;)

~!TOM!~
0
 
Dave_GreeneCommented:
Not a bad idea there Tom  :)
0
 
jdesharnaisAuthor Commented:
Thanks for your help I use some scheme with the tag property. thank jklmn
I still find it funny that if you take a look at the form you created through note pad.
Tab(0).Control(1)= "txtReceiveDate"

My guess is that the method I want is there but not public.
0
 
jklmnCommented:
Hi jdesharmais,

I guess your guess is correct:-)
Anyway, VB knows which control in which page of the sstab.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.