What is a Tab Control?
A Tab Control is an Access object that allows you to create tabbed pages on an Access form. See picture below.
This is particularly useful if you have more objects (ie: text boxes, combo boxes, etc) than is possible to display on a regular Access form without having to scroll up or down.
A Tab Control can help you display these objects on your Form by displaying tabbed pages. You can then group objects on the various pages.
In this example, we have tab pages for:
- General
- Address
- Shipping Info
Creating a Tab Control
Let's take a look at how to create a Tab Control.
First, open your Form in Design View. Then select the Tab Control object in the Toolbox.
Then left-click on the Form where you'd like the Tab Control to appear.
Your Tab Control object should now appear on your form.
Naming your Tab Pages
To name your tab pages, highlight the Page in your Tab Control that you wish to name.
Then under the View menu, select Properties.
The Name property is object name for the tab page, while the Caption property is the value that will display in the label section of the tab page.
In this example, we're going to call the tab page "PageGeneral" and we'll change the caption to display "General".
Now, when we view the Tab Control, it looks as follows:
Adding objects on the Tab Pages
The next thing you'll want to do is add objects (ie: text boxes, combo boxes, etc) to your tab pages.
Select the tab page that you'd like to add the objects to. In our example, we're going to add objects to our General page.
Now, just drag and drop your objects onto your tab page.
In this example, we've created an OrderID and an OrderDate field on the General tab.
One thing to note about tab pages is that the objects that you create on a tab page, only appear on that page. As you can see, if you select Page2 of the Tab Control, you no longer see the OrderID and OrderDate fields.
Adding Tab Pages
By default, your Tab Control will be created with 2 tab pages. But if you want more tab pages, it's quite easy to customize your Tab Control to display as many pages as you'd like.
To create a tab page, right-click on the Tab Control and select "Insert Page" from the pop-up menu.
A new page should appear on your Tab Control.
Reordering Tab Pages
Once you've started adding tab pages, you may find that you want to reorder how your pages appear.
To do this, select the page that you'd like to move and change the Page Index property for that page.
Here's how the Page Index property works:
The first page on your Tab Control has a Page Index value of 0.
The second page on your Tab Control has a Page Index value of 1.
The third page on your Tab Control has a Page Index value of 2.
and so on...
In this example, we want Page3 to appear as the first tab, so we've change the Page Index property to 0.
Now when you view your Tab Control, you can see that Page3 displays as the first tab page.
You can also reorder your tab pages, by right-clicking and selecting "Page Order" from the popup menu.
When the Page Order window appears, move the order of your tab pages by highlighting the page and clicking on either the "Move Up" or "Move Down" button.
Deleting Tab Pages
Once you've started customizing your Tab Control, you may find that you wish to delete a tab page.
To do this, select the page that you wish to delete. Right-click and select "Delete Page" from the popup menu.
In this example, we've chosen to delete Page2.
Now when you view your Tab Control, you can see that Page2 has been deleted.
Displaying Labels on Multiple Rows
As you customize your Tab Control, you may find that you have more tab pages than can display on your screen and arrows appear to the right of your page labels (see picture below).
If you'd rather have the page captions appear on multiple rows, select the Tab Control object (not a page, but the whole Tab Control).
In the Property window for the Tab Control, change the Property called "Multi Row" to Yes.
Now when you view your Tab Control, you can see that the tab captions appear in multiple rows.
Congratulations! You've now created your first Tab Control.