To add a line, display the form or report in Design View. In the Controls section of the Ribbon, click the Line object and click the form or report. After adding the line to a form or report, you can change its thickness, its color, and/or its type.
To specify the characteristics of a line, while the form or report is displaying in Design View and the line is selected:
Practical Learning: Adding Lines
To enhance the appearance of controls or to create a section on a form or a report, you can use a rectangle object. It is a graphical object primarily intended for aesthetic purposes.
To add a rectangle, display the form or report in Design View. In the Controls section of the Ribbon, click the Rectangle object and click the form or report. To set the aesthetic features of a rectangle, you can change such as aspects as the back color, the borders, or the special effects, etc. To do this:
The Group Box
A group box is a rectangular object used to delimit a set of controls. There may not be any relationship among the controls. The main idea might simply be to indicate that the controls go together.
To create a group box, after displaying a form or report in Design View, in the Controls section of the Design tab of the Ribbon, click the Option Group control and click the desired area of the form or report. If you just want to create a group box, if a wizard comes up, click Cancel.
Besides the rectangle it presents, an option group is also equipped with a label. If you want to use the label, you can specify its Caption property as you see fit. If you don't want to use its label, you can either delete it or set its caption empty.
Practical Learning: Adding a Group Box
Sub-Forms and Sub-Reports
As seen in Lesson 12, a sub-form (or a sub-report) is a form (or a report) that is positioned in the body of the form (or report). To support the sub-form and sub-report as a control, Microsoft Access provides the Subform/Subreport button in the Controls section of the Ribbon. Therefore, to add a sub-form or a sub-report, click that button and click the form or report. This will open the SubForm Wizard or the SubReport Wizard. The wizard allows you to either an existing form (or report) or a pre-designed sub-form (or sub-report). As an alternative, the wizard allows you to choose a table and then select the desired fields.
Characteristics of a Sub-Form or Sub-Report
As mentioned in Lesson 12, there must be a relationship between the table used as source to the hosting form (or report) and the table used as source to the hosted sub-form (or sub-report). If such a relationship was not previously established, you can manually indicate the relationship to Microsoft Access. In this case, the application will try to make the connection. If the relationship cannot be verified, you may get an unpredictable result, such as the sub-form or sub-report showing all records instead of only those of the current record of the parent form or report.
Using the Wizard to Indicate the Relationship
If you use the wizard to add the sub-form or sub-report, in the first page of the wizard, select the form (or the report) or the sub-form (or the sub-report). In the second page of the wizard, select the fields that will establish the relation.
The Link Fields
To let you indicate or establish the relationship between the hosting form and the sub-form, the Property Sheet is equipped with the Link Master Fields and the Link Child Fields. The Link Master Fields specifies the primary key from the table. The Link Child Fields specifies the foreign key from the table of the sub-form.
Introduction to Tab Controls
A tab control is an object that is used to hold other Windows controls. It can appear by itself. Here is an example:
In most cases, a tab control comes in a group with one or more others. In this case, each tab hosts or carries its own controls. Here is an example:
Creating a Tab Control
To create a tabbed control, while the form is in Design View, in the Controls section of the Design tab of the Ribbon, click the Tab Control and click the form. By default, after adding a new tab control to a form, it is equipped with two tab pages. The tab sheet is a rectangle that surrounds the tab controls and holds them as their parent. To tab sheet is represented by the area on the right side of the tabs. To select that tab sheet, you can click that area:
Practical Learning: Adding a Tab Control
Characterics of Tab Controls
If you select the tab sheet and move it, the tab pages on it would move also. If you delete the tab sheet, its tab pages would be deleted also. For this reason, the tab sheet is considered their parent. As the parent, the tab sheet holds the location (the left and top values) and the size (the width and the height) of the whole control.
Practical Learning: Introducing the Tab Control
Adding a Tab Page
To add a new tab, right-click one of the tabs or the area of the tab sheet and click Insert Page:
Practical Learning: Introducing the Tab Control
Deleting a Tab Page
To remove a tab page, you can click its tab and press Delete. Alternatively, you can right-click a tab and click Delete Page.
The Caption on a Tab Page
Because a tab control only serves as a parent to the tab pages, it doesn't need a caption. Instead, each tab page has one. The text of a tab page (or property page) displays on its tab. Therefore, after adding a tab control, you should set its Caption in the Property Sheet.
Practical Learning: Setting the Captions of Tab Pages
The Index of a Tab Page
The tab pages of a tab control are organized as a list (or collection). Each tab page occupies a position known as its index, wihch is an integer. The indexes are controlled by a property named Page Index. The most left tab page has an index of 0. The index of the next tab page is incremented by 1 from the previous index.
After creating the tab pages, if you want to move them, that is, if you want to change the position of a tab page, simply change its page index in the Property Sheet.
Practical Learning: Controlling the Index of a Tab Page
The Widths of Tabs
After typing the caption of a tab, its width is adjusted to accommodate it. This is done for each tab. Consequently, one tab with a Personal caption and another tab with Educational Experience as caption, would have different widths.
You can give the same width to all tabs regardless of their different lengths of strings. To give the same width to the tabs, in the Format or the All tab of the Property Sheet of the tab control (the tab sheet itself), change the value of the Tab Fixed Width property. The default value of 0" means that you let Microsoft Access determine the necessary width to contain the captionon the tab. Otherwise, you can change it:
Practical Learning: Controlling the Widths of Tabs
The Heights of Tabs
The Tab Fixed Height property can be used to control the height of the tabs or buttons.
Practical Learning: Setting the Tab Height
Pictures on Tabs
You can display either or both a picture and a label on the tab. Although the picture can be any size, you should limit it to 16x16 pixels. Here are examples:
To add a picture to the button, select the tab while in the Design View. In the Property Sheet, click the Picture property and click its ellipsis button . Locate and select a picture. It should be a bitmap (with bmp extension) or an icon (with ico extension).
If you had specified a picture on a tab but don't want the picture anymore, access the Property Sheet for that tab. In the Format or the All tab, click Picture to select (Image) and press Delete.
The Style of Tabs
By default, tab pages display their captions on a tab. If you don't like the tabs, you can use either a button or nothing. This characteristic is controlled by the Style property in the Property Sheet of the tab sheet. This property has three values: Tabs, which is the default, Buttons, and None.
Like the Tabs value, the Buttons property allows each tab page to display a label that indicates its role. You can display a button with or without a picture.
If you set the Style property to None, the tab sheet would appear as a simple rectangular box and the user would not be able to switch among the pages. Therefore, if you decide to use this option, unless you want to hide the other pages, make sure you provide the user with the means of switching to a different property page.
Based on the role of the tab sheet, some properties of the tab sheet are also imposed on the tab pages. For example, in the Property Sheet, if you change the value of the Top or the Left properties, the tab sheet moves and at the same time, the corresponding values of the tab pages are changed.
The Shape of Tabs
By defulat, the tabs of a tab control appear as rectangular objects. Microsoft Access allows you to change their shapes. To do this, select the table control on the form in Design View. On the Ribbon, click Format. In the Control Formatting section, click the Change Shape button and click one of the options:
Here is an example:
You may have a form that hosts many controls. Such a form may not have enough room/space to show all controls at one time. As we saw from the orher controls containers, Microsoft Access provides many solutions. One more solution is to divide the form in vertical sections broken by groups. To separate those sections, you create an object named a page break.
To create sections on a form, in the Controls section of the Design tab of the Ribbon, click the Page Break control and click the left side inside the Detail section of a form. You can add as many sections as you want.
Practical Learning: Creating Page Breaks
Characteristics of a Page Break
Like any object, a page break has a name. As seen with other controls, after you have added a page break, Microsoft Access gives it a default name. You can accept or change it. To make the roles of your form sections efficient, they (the sections) should have the same height.
After creating a page break, you can access it only programmatically. One way to do this is to use a macro. To do this, in the Action combo box of the Macro window, select GoToPage. In the Page Number box, enter the desired number of the section, and close the macro. You would be asked to save it.