Version 1.3 Approx 0.5 MB (zipped) First Published 5 Feb 2024
This article was prompted by a question at Utter Access forum: Change Background Colour of Tab Controls
Access tab controls allow very little customisation. Pages can either be white or transparent.
The page tabs only allow limited colours depending on the current tab state (normal/mouse hover/pressed).
Using a normal tab control background, the page tabs can show different backcolors and forecolors when hovered over with the mouse or when pressed.
With a transparent control background, the tab appearance is also similarly affected.
Over the years, many people have tried to customise the appearance of tab controls. Some approaches are more complex than others.
All involve some degree of faking to create the required outcome. See
Alternative Approaches below.
This article shows one way of adding colour both to individual tabs and their pages and is about as simple as is possible.
Two forms are used with similar tab controls, each with 3 pages and subforms on 2 of those pages.
The left form has a normal background and coloured boxes (rectangle controls) are placed over each page
The right form has a transparent background and coloured boxes on each page. Tab style = None with the tabs are replaced by three coloured labels
NOTE: Placing a rectangle on a tab control page can be a bit tricky
These screenshots show the first tab, Page1, selected for the two tab controls:
The next image shows Page2 selected for each tab Control. The same 2 subforms are used on both forms with the background colours matching the rectangle (box) colors.
Finally here is Page3 for each control
In the left form, the active tab forecolor property is set to red and backcolor to white.
The form has no code. The colours are set using the property sheet for the tab control
In the right form, the active tab label forecolor property is also set to bold red and the label border is highlighted.
The label backcolors are identical to the rectangle colours for each page. This does require some code:
CODE:
Private Sub RestoreTabLabels()
Dim i As Integer
'restore default appearance for tab labels
Me.lbl1.BackColor = RGB(173, 192, 217)
Me.lbl2.BackColor = RGB(180, 229, 162)
Me.lbl3.BackColor = RGB(242, 170, 132)
For i = 1 To 3
Me("lbl" & i).ForeColor = vbBlack
Me("lbl" & i).FontWeight = 400
Me("lbl" & i).BorderWidth = 1
Me("lbl" & i).BorderColor = RGB(128, 128, 128)
Next
End Sub
'======================================
Private Sub lbl1_Click()
RestoreTabLabels
Me.lbl1.ForeColor = RGB(186, 20, 29)
Me.lbl1.BorderColor = Me.lbl1.ForeColor
Me.lbl1.FontWeight = 700
Me.lbl1.BorderWidth = 2
Me.TabCtl0.Value = 0
End Sub
'======================================
Private Sub lbl2_Click()
RestoreTabLabels
Me.lbl2.ForeColor = RGB(186, 20, 29)
Me.lbl2.BorderColor = Me.lbl2.ForeColor
Me.lbl2.FontWeight = 700
Me.lbl2.BorderWidth = 2
Me.TabCtl0.Value = 1
End Sub
'======================================
Private Sub lbl3_Click()
Me.lbl3.ForeColor = RGB(186, 20, 29)
Me.lbl3.BorderColor = Me.lbl3.ForeColor
Me.lbl3.FontWeight = 700
Me.lbl3.BorderWidth = 2
Me.TabCtl0.Value = 2
End Sub
Use either approach and modify the code to suit your own preferences
Alternative Approaches
Several other methods have been suggested over the past 20 years or so. Most are very old. These include:
1. Stephen Lebans - A97 MDB example app from 2004: Tab Colors
2. Danny Lesandrini - old web article for DatabaseJournal.com from around 2005: URL to follow if I (or any readers of this article) can re-locate it!
3. MajP - MDB example app at Access World Forums: Form Tab Colours
4. Michael Alexander - old DataPig Technologies video on YouTube: Create the "illusion" of Colored Tabs
Download
Click to download: TabPageColor_v1.3 ACCDB file Approx 0.5 MB (zipped)
Feedback
Please use the contact form below to let me know whether you found this article interesting/useful or if you have any questions/comments.
Please also consider making a donation towards the costs of maintaining this website. Thank you
Colin Riddington Mendip Data Systems Last Updated 5 Feb 2024
Return to Example Databases Page
|
Return to Top
|