Solved

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

Posted on 2001-07-16
12
222 Views
Last Modified: 2008-02-01
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





0
Comment
Question by:jdesharnais
  • 5
  • 4
  • 2
  • +1
12 Comments
 
LVL 8

Expert Comment

by:Dave_Greene
ID: 6286939
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
 
LVL 1

Author Comment

by:jdesharnais
ID: 6286970
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
 
LVL 8

Expert Comment

by:Dave_Greene
ID: 6286980
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
 
LVL 1

Author Comment

by:jdesharnais
ID: 6286993
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
 
LVL 8

Expert Comment

by:Dave_Greene
ID: 6287037
Well if you put the frames into a control array, this should work

MsgBox oText.Container(oText.Container.index).Name
0
 
LVL 1

Author Comment

by:jdesharnais
ID: 6287316
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 8

Expert Comment

by:Dave_Greene
ID: 6287328
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
 
LVL 5

Accepted Solution

by:
jklmn earned 200 total points
ID: 6287551
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
 

Expert Comment

by:VBTom
ID: 6288136
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
 
LVL 8

Expert Comment

by:Dave_Greene
ID: 6288147
Not a bad idea there Tom  :)
0
 
LVL 1

Author Comment

by:jdesharnais
ID: 6302857
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
 
LVL 5

Expert Comment

by:jklmn
ID: 6305290
Hi jdesharmais,

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now