The tab control lets you easily create multipage forms in a tabbed dialog, similar to the tabbed pages you've seen in the Properties window, in the Options dialog, and elsewhere in Access. The tab control is a very efficient alternative to creating multipage forms with the Page Break control. You can use the tab control to conserve space onscreen and show information from one or more tables. The sections that follow show you how to add images to a new OLE object field of the Employees table, add a tab control to a form, and display images in a bound image control on a tab control page. You also learn to set the important properties of the tab control as a whole, as well as the properties of individual pages of the tab control. Adding the Tab Control to a FormTo add a tab control to the frmHRActionEntry form, follow these steps:
Figure 15.48. Access's default tab control has two pages.
By default, Access creates a tab control with two pages. Each page's tab displays the name of the page combined with a sequential number corresponding to the number of controls you placed on your form in this work session. The next few sections describe how to change the page tab's caption, add or delete pages in the tab control, add controls to the pages, and set the page and tab control properties. Adding Tab Control PagesDepending on the data you want to display and how you want to organize that data, you might want to include more than two pages in your tab control. To add a page to a tab control, follow these steps:
Changing the Page OrderBecause Access adds a new page only after the last page, it isn't possible to add a new page at the beginning or middle of the existing tab pages. As a result, if you want the new tab control page to appear in another location in the tab control, you must change the order of pages in the tab control. You might also want to change the order of tab control pages as you work with and test your forms in general, you should place the most frequently used (or most important) page at the front of the tab control. To change the order of pages in a tab control, follow these steps:
Deleting a Tab Control PageAt some point, you might decide that you don't want or need a page in a tab control. The frmHRActionEntry form needs only two pages in its tab control. If you added a page to the tab control by following the steps at the beginning of this section, you can delete a page from the tab control by following this procedure:
Setting the Tab Control's PropertiesTwo sets of properties govern the appearance and behavior of a tab control. A set of properties exists for the entire tab control, and a separate set of properties exists for each page in the tab control. The following list summarizes the important properties of the tab control and its pages; the remaining property settings for the tab control and its pages are similar to those you've seen for other controls (height, width, color, and so on):
To display the Properties window for the entire tab control, right-click the edge of the tab control, and choose Properties from the resulting context menu. Alternatively, click the edge of the tab control to select it (clicking the blank area to the right of the page tabs is easiest), and then click the Properties button on the toolbar to display the Properties window. To display the Properties window for an individual page in the tab control, click the page's tab to select it, and then click the Properties button on the toolbar to display the page's Properties window. The tab control in the frmHRActionEntry form uses one page to display current information about an employee: the employee's job title, supervisor, company telephone extension, hire date, and photo. The second tab control page displays a history of that employee's HRActions in a subform you add later in the chapter. Follow these steps to set the Caption property for the frmHRActionEntry form's tab control:
Figure 15.50 shows the tab control with both page captions set and the first page of the tab control selected. Notice that the sizing handles visible in the tab control are inside the control this position indicates that the page, not the entire control, is currently selected. When the entire tab control is selected, the sizing handles appear on the edges of the tab control. Figure 15.50. Set the Page properties by clicking the tab of one of the pages. Click the empty area to the right of the tabs to set the properties of the entire tab control.
Placing Other Controls on Tab PagesYou can place any of Access's 16 other types of controls on the pages of a tab control labels, text boxes, list boxes, even subforms. To add a control of any type to a tab control's page, follow this procedure:
Alternatively, you can copy controls from the same or another form and paste them into the tab control's pages by using the same techniques you learned for copying and pasting controls on a form's Detail and Header/Footer sections. You can't drag controls from the form's Detail or Header/Footer sections onto the tab control's page or vice-versa. As you proceed with the examples in this chapter and complete the frmHRActionEntry form, you place various bound and unbound controls on the pages of the tab control. |