Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    2 Star Lounger
    Join Date
    Jul 2003
    Posts
    124
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Tab Control (Access 2002)

    I have a form where I use the Tab Control Function; I have five tabs. Is there any way to change the Tab Colors to be different for each tab? In addition, Is there a way to change the background color differetly for each tab?

  2. #2
    Silver Lounger GARYPSWANSON's Avatar
    Join Date
    Aug 2001
    Location
    Frederick, Maryland, USA
    Posts
    1,788
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Tab Control (Access 2002)

    The only way I know to do what you ask would be to insert another object such as a rectangle on the tab (In design mode, go to the toolbox, select rectangle, and draw a rectangle on the tab) and then fill in the rectangle with a color. This will simulate what you want.

    Not pretty, but it works.
    Regards,

    Gary
    (It's been a while!)

  3. #3
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Tab Control (Access 2002)

    Check-out http://www.lebans.com/ for an example of how you can change the colors (and even rotate text) on tabs.

    Although it is a fascinating read, it is REALLY complicated. The few times I've done this, I've just found it easier (as Gary suggested) just to just set my tab control to "no tabs", then make by own.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  4. #4
    2 Star Lounger
    Join Date
    Jul 2003
    Posts
    124
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Tab Control (Access 2002)

    If you read Gary's he stated to place over the Tabs; If I select no Tabs (which I agree would be easier) what controls would I put on each retangle box to view the different tabs?

  5. #5
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Tab Control (Access 2002)

    I used Labels, so I could make each a different color (background and foreground). My tab control was named [tabctl], and each Label was named [Label_tabctl_Page0], [Label_tabctl_Page1], etc. I also had a box with a thick border that I place around the tab control.

    The Onclick event contained a function, the first label (for Page0) had this:
    =SelectTabPage( [tabCtl], 0)


    The code for this function is simply this:

    Private Function SelectTabPage(ctlTab As Control, PageNo)
    ctlTab.Value = PageNo
    End Function


    The tab control's Change event contained this code, which changed each tab label's effect to Raised when it was selected, and changed the color of that box to match the backcolor of the Label.

    Dim i As Integer

    For i = 0 To TabCtl.Pages.Count - 1
    With Me("Label_tabctl_Page" & i)
    .SpecialEffect = acEffectNormal
    .Top = TabCtl.Top - 285
    End With
    Next i
    With Me("label_tabctl_Page" & TabCtl.Value)
    .SpecialEffect = acEffectRaised
    .Top = TabCtl.Top - 315
    Me("box" & TabCtl.Name).BorderColor = .BackColor
    End With

    Good luck.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  6. #6
    Silver Lounger GARYPSWANSON's Avatar
    Join Date
    Aug 2001
    Location
    Frederick, Maryland, USA
    Posts
    1,788
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Tab Control (Access 2002)

    Very Neat Mark - A tab control with "no tabs".

    So, if you input a subform or sub subform on the tab for data entry, would the reference to the subform from another form or module be the same?
    Regards,

    Gary
    (It's been a while!)

  7. #7
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Tab Control (Access 2002)

    Yes, everything is still the same. You still have a tab control, and you have tab pages; just not the little tab things that stick up.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  8. #8
    2 Star Lounger
    Join Date
    Jul 2003
    Posts
    124
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Tab Control (Access 2002)

    Work great; on the code for the function you reversed the cltTab; but I that was no big deal. Just one more, how do I default the form to open with the first tab raised and the box colored to the raised tab?

    Thanks very much for this code; it will really make the multiple tabs stand out.

  9. #9
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Tab Control (Access 2002)

    Just add this line of code to your form's OnOpen event:

    SelectTabPage [tabCtl], 0
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  10. #10
    2 Star Lounger
    Join Date
    Jul 2003
    Posts
    124
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Tab Control (Access 2002)

    Thanks; I just set the defaults on my Tab1 to what I wanted and that worked. I think I'll try yours just so I have both options available.

  11. #11
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I'm trying to create coloured tabs for a form but I'm just confused (not hard) by this bit

    [codebox]The Onclick event contained a function, the first label (for Page0) had this:
    =SelectTabPage( [tabCtl], 0)


    The code for this function is simply this:

    Private Function SelectTabPage(ctlTab As Control, PageNo)
    ctlTab.Value = PageNo
    End Function[/codebox]

    The Onclick event of what?

  12. #12
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    [quote name='robm' post='779345' date='11-Jun-2009 17:40']The Onclick event of what?[/quote]
    Of the labels mentioned by Mark just above the part that you quoted:
    "I used Labels, so I could make each a different color (background and foreground). My tab control was named [tabctl], and each Label was named [Label_tabctl_Page0], [Label_tabctl_Page1], etc."

  13. #13
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks Hans. I had assumed that, but for some reason, when I created a label, there was no 'OnClick' event. No idea what I did wrong.

  14. #14
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts
    [quote name='robm' post='779354' date='12-Jun-2009 03:08']when I created a label, there was no 'OnClick' event.[/quote]

    To create an On Click event you need to display the Properties box, select the Label, then on the Event Tab of the Properties click next to On Click , then click the three dots to the right.

    [attachment=84255nclick.gif]
    Attached Images Attached Images
    Regards
    John



  15. #15
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    In this example, you need to enter an expression in the box.

Page 1 of 2 12 LastLast

Posting Permissions

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