Solved

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

Posted on 2001-07-16
12
219 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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

760 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

18 Experts available now in Live!

Get 1:1 Help Now