Results 1 to 3 of 3
  1. #1
    5 Star Lounger
    Join Date
    Feb 2001
    Louisville, Kentucky, USA
    Thanked 0 Times in 0 Posts

    Tabbed Form Index (A2K)

    Afternoon All,
    I have a tabbed form where each tab is named for a collection of controls related to the name of the tab...i.e. Education has many controls relating to the Education for that record.

    An individual may have attended many different colleges/universities to achieve his/her degree. Therefore at least I have at least 3 different groups of pertaining to: Recent Education (name of facility, start date, finish date, etc.) Other Education2 (with the same controls as Recent only named secFacility, secStartDate, secFinishDate as "sec"=Secondary) and Other Education3 (with the same controls as Recent and Other Education2 only name terFacility, terStartDate, terFinishDate as "ter"=tertiary).

    Also included on this tabbed form is a respective data collection for Hospitals. Again, I have 3 different groups pertaing to the naming of the tab. Again in each group is a collection of data pertaining to the 1st Hospital, 2nd Hospital and 3rd and the names of the controls once again begin with "sec" for secondary hospital data collection and "ter" for the tertiary Hospital data collection.

    So....I wrote the following function for visible property changes:

    <pre>Public Function MCHV(vp)
    Dim ctl As Control
    'For Each ctl In frm.Controls
    If Screen.ActiveControl.Value = -1 Then
    V = True
    V = False
    End If
    For Each X In Screen.ActiveForm.Controls
    If Left(X.Name, 3) = ff Then
    X.Visible = V
    End If
    Next X
    End Function

    It works fine with one small exception.... ALL the collections within the form are affected once the procedure is called.
    For instance. ... on the Education tab, if I click the "Other Education1" button (all respective controls pertaining to this choice beging with "sec", I want the visible property=TRUE. It works but it also works on the "Hospital" tab collection because of course, the names of the controls for "Hospital1" begin with "sec".

    I've tried using TabIndex.visible but that doesn't apply. What must I do to have the code look at the ACTIVE form and the ACTIVE tab?

    Thanks for any suggestions.
    Roberta Price <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 28 Times in 28 Posts

    Re: Tabbed Form Index (A2K)

    You can use the Parent property of the control. In your situation, the Parent is the tab page the control is sitting on. Let's say the tab control is named tabPages. Try changing

    If Left(X.Name, 3) = ff Then


    If Left(X.Name, 3) = ff And X.Parent Is Me.tabPages.Pages(Me.tabPages) Then

    - You don't use the argument vp of the function.
    - You declare a variable ctl but use the undeclared variable X instead.
    - The variable V is not declared.
    - It is not clear what ff is.

  3. #3
    5 Star Lounger AndrewKKWalker's Avatar
    Join Date
    Apr 2001
    Cambridge, UK
    Thanked 3 Times in 3 Posts

    Re: Tabbed Form Index (A2K)

    I wasn't coming here to do this but anyway.

    I think if you use the value of the tabControl (not the individual tab)
    It will tell you which tab you are on counting from 0
    This should assist you in determining which the active tab is

    For example IF you have a Tab Control on a form called tbcMain

    Then tbcMain.Value will return the active Tab (Page)
    and tbcMain.Pages(tbcMain.Value).Name will return the Name of the page itself

    Similarly if you have a control on a tab on a form you can use the parent name property to find out which tab it is on
    Suppose you had a control called secHospital on Page2 of a tab control
    Then secHospital.Parent.Name will return the name of the Controls Tabbed page.

    Using these two bits of information should help you work out which controls are on the active tab.

    And now back to my question

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts