Same control on multiple tab pages

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • doma23
    New Member
    • May 2010
    • 107

    Same control on multiple tab pages

    Hi,

    I have a tab control with couple of pages on it, like:
    InfoPage, Page1, Page2, Page3.

    On each page there are various text boxes and combo boxes.
    What I need to do is to make one of these comboboxes (i.e. cboPeriod1) to be on Page1, Page2 and Page3, but not on the InfoPage.
    The problem is that the control needs to be exactly the same.
    This is simplified - actually I have 5 comboboxes and 10 reactangles, for which the VBA code already exist. And these 15 controls need to be on 4 different pages. And I would like to avoid puting additional 45 same controls with different name, as that would mean adding much more VBA code to do the same thing with each of these controls.

    Is this possible?
    Tnx.
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    There is a little trickery that you can use to accomplish what you are requesting:
    1. Create a Combo Box on your Form 'outside' of the Tab Control.
    2. Drag-N-drop the Combo Box along with the associated Label into any Page of the Tab Control.
    3. Position it precisely on the Page and Rename it cboPeriod1.
    4. Set any other Properties of the Combo Box as required.
    5. The Control will now appear on every Page of the Tab Control.
    6. Write Code in the Tab Control's Change() Event to display the Combo Box for every Page except the one titled InfoPage.
      Code:
      Private Sub TabCtl0_Change()
       'In my Test Database, the Value of the InfoPage Tab is 2, but it may not
       'be the same in your scenario
       Me![cboPeriod1].Visible = Me![TabCtl0].Value <> 2
      End Sub

    Comment

    • doma23
      New Member
      • May 2010
      • 107

      #3
      Hi ADezii,

      Yesterday, I've thought that it probably isn't possible, so I've just put the specific controls outside the tab control, and I came to conclusion that it even has some advantages if it's outside the tab control.
      So, I haven't test your solution yet, I might maybe in later stages of development.
      I was very suprised to find out that the solution actually exist. Thank you!

      Comment

      • ADezii
        Recognized Expert Expert
        • Apr 2006
        • 8834

        #4
        You are welcome. It technically is not a solution in that the same Control, a single Control, can exist on all but one Page of a Tab Control, but I feel as though it is a viable work around.

        Comment

        Working...