Access Form Controls: Coloured Tabs For Your MS Access Forms

Access Form Controls: Coloured Tabs For Your MS Access Forms

Working with Access form controls may not always be as flexible as one would like and a particular control that comes to mind is the Tab Control.

I have often been asked about if you can add a splash of colour and other formats to the Tab Control and the simple answer is not really as you are left with the empty and grey dull look and feel for tabs and their pages. The pages can be layered with boxes and formatted but the tab is a non-touchable element when adding colour.

However, you can always build your own version by adding and utilising other controls which include a Rectangle and as many Labels for each simulated tab required along with Text Box controls for your actual data.

access form controls

This Microsoft Access database tutorial will highlight the basic steps required and include the basic (but simple) Access VBA code so your custom tab will behave as with the standard one but you having all the control over it.

Check out a previous post of how to add the standard tab control to create multi-page that will step you through the basics & is one of the standard Access form controls to help evaluate and compare with the custom version below.

Access Form Controls: Coloured Tabs For Your MS Access Forms – The Steps

1. Create a new blank form and attach a data source (table or query) to it. I’m using the table called ‘Customers’.

2. It’s really up to you if you want to include any form headers or footers and with my example I’m using the header to display the company name (along with some distinctive formatting).

As a quick reference, you can see the image below of what I intend to end up with.

access form controls tab

3. Next, I’m going to add a Rectangle control and size it to make it big enough for the maximum number of fields any one page will hold.

Choose a background colour (not too bright or dark) and remove any borders and colours too.

4. With my example, I want to have three simulated pages and therefore I’m now going to add 3 Label controls starting at the top left corner and place horizontally along the same line (as shown above).

Colour each label differently and for now just re label the captions ‘tab 1’, ‘tab 2’ & ‘tab 3’ if you haven’t yet decided what your tabs are going to be called.

5. Now add the maximum number of Text Box controls (which have associated Labels too) and position them inside the rectangle area. I’m using 6 Text Boxes because that is the maximum any one page will utilise.

The minimum number of controls for a page view will only use three and I will hide the remaining three using Access VBA code later.

6. This is probably the most important step here as it will help later with your VBA code and that is name all the controls added so they are easily identifiable during the coding process.

I have named the following:

Rectangle control = page_area
The three Labels (page tabs) = tab1, tab2 & tab3
Each Text Box = Field1, Field2 … Field6
Each correlating Label = Label1, Label2 … Label6

[Note: You may want to consider saving your work from here on at various stages]

7. It’s VBA code time! On the first (page) tab Label control locate the ‘On Click’ event property (from the Property Sheet) and open the VBA module to it.

It should read:

Private Sub tab1_Click()

End Sub

In between the two lines, add the following:

Me.page_area.BackColor = "15523798" '#D6DFEC - light blue
Me.tab1.FontBold = True
Me.tab1.BorderWidth = 2 'thicker line

'show first 3 textboxes and set control sources...

Me.Field1.ControlSource = "Contact Name"
Me.Label1.Caption = Me.Field1.ControlSource
Me.Field1.Visible = True

Me.Field2.ControlSource = "Contact Title"
Me.Label2.Caption = Me.Field2.ControlSource
Me.Field2.Visible = True

Me.Field3.ControlSource = "Phone"
Me.Label3.Caption = Me.Field3.ControlSource
Me.Field3.Visible = True

Now you can start to customise this to taste and I’m not going to complete all the code here. Look below to download the whole example.

8. Continue adding VBA code to the other two tabs and refine the code (if you are experienced with programming code) to taste.

Save changes and test it out!

You may want to instead download my free sample Access database which demonstrates the above and takes advantage of this Access form controls lack of flexibility.

Also, you may wish to consider my eBook on how to build Access database forms which is one of the seven series that I currently offer.

3 Replies to “Access Form Controls: Coloured Tabs For Your MS Access Forms”

  1. In your VBA code, you can also call the RGB function which will give an array of (16 million) colours.
    The function RGB stands for Red, Green, Blue and has three parameters that each will accept a value between 0 and 255.
    i.e. RGB(255, 255, 255) is which colour?

Leave a Reply

Your email address will not be published. Required fields are marked *