Working with Tab Controls

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 Form

To add a tab control to the frmHRActionEntry form, follow these steps:

  1. graphics/design_view.gif Click the Design View button on the toolbar if the frmHRActionEntry form isn't already in Design view. No wizard for the tab control exists, so the status of the Control Wizards button doesn't matter.

  2. graphics/tab_control.gif Click the Tab Control tool in the Toolbox; the mouse cursor changes to the Tab Control icon while it's over the active surface of the form.

  3. Click and drag on the surface of the form's Detail section to create the new tab control near the bottom center of the form (see Figure 15.48).

Figure 15.48. Access's default tab control has two pages.

graphics/15fig48.gif

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 Pages

Depending 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:

  1. In Design view, right-click the tab control to open the context menu.

  2. Choose Insert Page; Access inserts a new page in the tab control to the right of the last page.

Changing the Page Order

Because 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:

  1. Right-click one of the tabs and choose Page Order to open the Page Order dialog shown in Figure 15.49.

    Figure 15.49. Change the left-to-right sequence of the tabs with the Page Order dialog.

    graphics/15fig49.gif

  2. In the Page Order list, select the page whose position you want to change.

  3. Click the Move Up or Move Down buttons, as appropriate, until the page is in the position you want.

  4. Repeat steps 3 and 4 until you have arranged the tab control pages in the order you want, and then click OK to close the Page Order dialog and apply the new page order to the tab control.

Deleting a Tab Control Page

At 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:

  1. Right-click the page tab of the page you want to delete; Access brings that page to the front of the tab control.

  2. Choose Delete Page; Access deletes the currently selected tab control page.

Setting the Tab Control's Properties

Two 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):

  • Caption is a text property, which controls the text that appears on the page's tab and applies to individual tab control pages only. If this property is empty (the default), then the page's Name property is displayed on the page's tab.

  • MultiRow is a Yes/No property, which applies to the tab control as a whole and determines whether the tab control can display more than one row of tabs. (The Options dialog, reached by choosing Tools, Options, is an example of a multirow tabbed dialog.) The default setting is No; in this case, if there are more tabs than fit in the width of the tab control, Access displays a scroll button in the tab control. If you change this property to Yes and there are more page tabs than will fit in the width of the tab control, Access displays multiple rows of tabs.

  • Picture displays an icon in any or all the page tabs. You can use any of Access's built-in icons or insert any bitmapped (.bmp) graphics file as the page's tab icon.

  • Style applies to the tab control as a whole and controls the style in which the tab control's page tabs are displayed. The default setting, Tabs, produces the standard page tabs you're accustomed to seeing in the Properties window and in various dialogs in Access and Windows. Two other settings are available: Buttons and None. The Buttons setting causes the page tabs to be displayed as command buttons in a row across the top of the tab control. The None setting causes the tab control to omit the page tabs altogether. Use the None setting if you want to control which page of the tab control has the focus with command buttons or option buttons located outside the tab control. However, using command buttons external to the tab control to change pages requires writing Access VBA program code. You should use the default Tabs setting unless you have a specific reason for doing otherwise using the Tabs setting ensures that the appearance of your tab controls is consistent with other portions of the Access user interface. Using this setting also saves you the effort of writing VBA program code.

  • Tab Fixed Height and Tab Fixed Width apply to the tab control as a whole and govern the height and width of the page tabs in the control, respectively. The default setting for these properties is 0. When these properties are set to 0, the tab control sizes the page tabs to accommodate the size of the Caption for the page. If you want all the page tabs to have the same height or width, enter a value (in inches or centimeters, depending on your specific version of Access) in the corresponding property text box.

graphics/properties_window.gif 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:

  1. graphics/design_view.gif Open the frmHRActionEntry form, and change to Form Design view, if necessary.

  2. graphics/properties_window.gif Click the first page of the tab control to select it, and then click the Properties button on the toolbar to display that page's Properties window.

  3. Click the Format tab, if necessary, to display the Format properties for the tab control page.

  4. Type Employee Info in the Caption property's text box.

  5. Click the Other tab and change the Name property value to pagEmployeeInfo.

  6. Click the second page of the tab control to select it; the contents of the Property dialog change to show the properties of the second tab control page. Click the Format tab.

  7. Type History in the Caption property text box for the second page of the tab control, type pagHistory in the Name property of the Other page, and close the Properties window.

  8. Click outside the tabbed region to select the entire tab control, and type tabHRAction as the name of the 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.

graphics/15fig50.jpg

Placing Other Controls on Tab Pages

You 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:

  1. In Design view, click the page tab you want to add the control to; Access selects the page and brings it to the front of the tab control.

  2. Add the desired control to the tab control's page using the techniques presented earlier in this chapter for creating controls on the main form.

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.



Special Edition Using Microsoft Office Access 2003
Special Edition Using Microsoft Office Access 2003
ISBN: 0789729520
EAN: 2147483647
Year: 2005
Pages: 417

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net