Solved

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

Posted on 2001-07-16
12
249 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
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
 
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

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…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

724 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