Home

Controls Containers and Delimiters

Shape-Based Controls

The Line

To enhance the appearance of sections of/or controls on a form or a report, you can use a line object. You can use it to place a horizontal, a vertical, or a diagonal line.

To add a line, display the form or report in Design View. In the Controls section of the Ribbon, click the Line object Line 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:

  • On the Ribbon, click Format. In the Shape Formatting section, click Shape Ouline
  • In the Property Sheet, click Format. You can then change the Border Style, the Border Width, and/or the Border Color

Practical Learning: Adding Lines

  1. Start Microsoft Access
  2. In the list of files, click Ceil Inn1
  3. In the Navigation Pane, double-click the Customers form to open it
  4. Right-click its title bar and click Design View
  5. In the Controls section of the Ribbon, click the Line Line
  6. On the form, draw (drag) a horizontal line below Emergency Phone (from left to right)
  7. While the line is still selected, in the Property Sheet (if it is not available, double-click the line), click Format and make sure Border Style is set to Solid
  8. Change the following properties:
    Border Width: 2pt
    Border Color: Accent 5, Darker 50%
  9. Make them horizontal and separated by two marks from the vertical rulers:

    Line Drawing

  10. Close the form
  11. When asked whether you want to save the changes, click Yes
  12. On the Ribbon, click File and click Open
  13. In the list of files, click FunDS1 from the previous lesson
  14. In the Navigation Pane, right-click the ShoppingSessions forms and click Design View
  15. In the Controls section of the Ribbon, click the Line control Line and click ini the Form Header section of the form
  16. Put the line between the label and spanning the whole width of the form:

    Label

  17. Close the form
  18. When asked whether you want to save, click Yes
  19. In the Navigation Pane, right-click the Employees form and click Design View
  20. In the Controls section of the Ribbon, click the Line control Line and click in the Form Header section of the form
  21. Move it under the top label and as wide as the form
  22. Complete ethe design as follows:

    Label

  23. Close the form
  24. When asked whether you want to save, click Yes
  25. In the Navigation Pane, right-click the StoreItems form and click Design View
  26. Using the Line control Line  of the Controls section of the Ribbon, add two lines in the Form Header section of the form as follows:

    Form Design - Line

  27. Close the form
  28. When asked whether you want to save, click Yes
  29. On the Ribbon, click File and click Open
  30. In the list of files, click College Park Auto-Repair1 from the previous lesson
  31. In the Navigation Pane, double-click the RepairOrders form to open it
  32. After viewing the form, on the right side of the status bar of Microsoft Access, click Design View
  33. From the Controls section of the Ribbon, add a horizontal line between the two top labels:

    College Park Auto-Repair - Form Design - Repair Orders

  34. Close the form
  35. When asked whether you want to save, click Yes

The Rectangle

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

  • On the Ribbon, click Format. In the Shape Formatting section:
    • If you want to change the background color of the rectangle, click Shape Fill
    • If you want to change the characteristics of the border, click Shape Ouline
  • In the Property Sheet, click Format. You can then change the Back Color, the Border Style, the Border Width, and/or the Border Color

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 Option Group 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

  1. On the Ribbon, click File and click Open
  2. In the list of files, click FunDS1
  3. In the Navigation Pane, right-click the Employees form and click Design View
  4. In the Controls section, click the Option Group control Option Group and click the form.
    If a wizard comes up, click Cancel
  5. While the group box is still selected on the form, in the Property Sheet, click Format and change the following characteristics:
    Top: 3.0833
    Left: 0.25
    Width: 4.25
    Height: 2.125
  6. Click the label on top of the group box
  7. In the Property Sheet, click the Format tab and change the following characteristics:
    Caption: Employee Pay Summary
    Back Color: #D6DFEC
    Border Color: Accent 1, Darker 50%

    Adding a Group Box

  8. Save the form

Sub-Forms and Sub-Reports

Introduction

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.

Practical Learning: Using the Link Fields

  1. On the Ribbon, click File and click Open
  2. In the list of files, click Road System1
  3. In the Navigation Pane, right-click the Roads form and click Design View
  4. In the Navigation Pane, drag sfIntersections and drop it on the form

    Sub-Form

  5. On the form, click the border around the sub-form to access its properties
  6. In the Property Sheet, click Data and set the following properties:
    Link Master Fields: RoadName
    Link Child Fields: Road1
  7. Complete the design of the form as you see fit. Here is an example:

    Sub-Form

  8. To see the result, in the Views section of the Ribbon, click the View button

    Sub-Form

    Sub-Form

  9. Ēlose the form
  10. When asked whether you want to save, click Yes
  11. On the Ribbon, click File and click Open
  12. In the list of files, click FunDS1
  13. In the Navigation Pane, right-click the ShoppingSessions form and click Design View
  14. From the Navigation Pane, drag sfSoldItems and drop it on the form

    Fun Department Store - Shopping Sessions

  15. Close the form
  16. When asked whether you want to save, click Yes

Introduction to Tab Controls

Description

A tab control is an object that is used to hold other Windows controls. It can appear by itself. Here is an example:

Tab Control

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:

Tab Control

Tab Control

Practical Learning: Introducing Tab Controls

  1. On the Ribbon, click File and click Open
  2. In the list of files, click College Park Auto-Repair1 from the previous lesson
  3. In the Navigation Pane, double-click the RepairOrders form to open it
  4. After viewing the form, on the right side of the status bar of Microsoft Access, click Design View

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

Tab Controls

Practical Learning: Adding a Tab Control

  1. In the Controls section, click the Tab Control Tab Control
  2. Click below the other controls on the form
 
 
 

Characterics of Tab Controls

Introduction

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

  1. On the form, click the empty area on the right side of the tabs to select the tab control
  2. In the Property Sheet, click the All tab and change the following properties:
    Name: tcRepairOrders
    Top: 1.6667
    Left: 0.125
    Width: 7.25
    Height: 2.21

    College Park Auto-Repair - Form Design - Repair Orders

  3. Save the form
  4. On the Ribbon, click File and click Open
  5. In the list of files, click Metro System1
  6. In the Navigation Pane, right-click the MetroLines form and click Design View
  7. In the Controls section of the Ribbon, click the Tab Control Tab Control
  8. On the form, click below the other controls
  9. While the tab control is till selected, in the All tab of the Property Sheet, change other characteristics as follows:
    Name: tcMetroLines
    Width: 9.875
    Height: 7.875
    Top: 1
    Left: 0.125

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:

Tab Control

Practical Learning: Introducing the Tab Control

  1. On the form, right-click anywhere on the tab sheet and click Insert Page
  2. On the Ribbon, click File and click Open
  3. In the list of files, click College Park Auto-Repair1
  4. When asked whether you want to save, click Yes
  5. In the Navigation Pane, right-click the RepairOrders form and click Design View
  6. Right-click the right side of the tab control and click Insert Page
  7. Right-click the right side of the tab control and click Insert Page

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

  1. On the form, click the left Page_X to select one of the tab pages (its body should now have an orange rectangle)
  2. In the Property Sheet, click Format, click Caption and type Parts Used
  3. On the form, click another Page_X and make sure an orange rectangle appears in its body
  4. In the Format tab of the Property Sheet, click Caption and type Jobs Performed
  5. On the form, click another Page_X
  6. In the Format tab of the Property Sheet, click Caption and type Problem Description
  7. On the form, click another Page_X
  8. In the Format tab of the Property Sheet, click Caption and type Recommendations

    College Park Auto Repair

  9. On the form, click the Parts Used tab to select it and make sure its body has an orange rectangle
  10. From the Navigation Pane, drag sfPartsUsed and drop it on the tab page
  11. Click the accompanying label, sfPartsUsed, and press Delete
  12. Adjust the location and the size of the sub-form. Here is an example:

    College Park Auto-Repair

  13. On the form, click the Jobs Performed tab to select it and make sure its body has an orange rectangle
  14. From the Navigation Pane, drag sfJobsPerformed and drop it on the Jobs Performed tab page
  15. Click the accompanying label, sfJobsPerformed, and press Delete
  16. Adjust the location and the size of the sub-form. Here is an example:

    College Park Auto-Repair - Repair Orders

  17. Save the form

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

  1. On the form, click the Problem Description tab page to select it
  2. In the All tab of the Property Sheet, click Page Index and type 0
  3. On the form, click the Jobs Performed tab page to select it
  4. In the All tab of the Property Sheet, click Page Index and type 1
  5. On the form, click the Recommendations tab page to select it
  6. In the All tab of the Property Sheet, click Page Index and type 3

    Date/Time Values

  7. Save hte form

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:

Tab Control

Practical Learning: Controlling the Widths of Tabs

  1. On the form, click the empty area on the right side of the tabs to select the tab control
  2. In the Format tab of the Property Sheet, click the Format tab and click Tab Fixed Width:
  3. Type 1.78

    College Park Auto-Repair - Repair Orders

  4. To preview the form, on the right side of the status bar of Microsoft Access, click Form View
  5. Close the form
  6. When asked whether you want to save, click Yes
  7. On the Ribbon, click File and click Open
  8. In the list of files, click MetroSystem1
  9. In the Navigation Pane, right-click the MetroLines form and click Design View
  10. On the form, click the left tab page to select it
  11. In the Format tab of the Property Sheet, click Caption and type Stations
  12. On the form, click the middle tab page
  13. In the Format tab of the Property Sheet, click Caption and type Description
  14. On the form, click the right tab page
  15. In the Format tab of the Property Sheet, click Caption and type General Metro Map
  16. Save the form

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

  1. The MetroLines form of the MetroSystem1 database should still be opened in Design View.
    On the form, click the empty area on the right side of the tabs to select the tab control
  2. In the Format tab of the Property Sheet, click Tab Fixed Height and type 0.35
  3. On the form, click the Stations tab to select it
  4. From the Navigation Pane, drag sfLinesStations and drop it on the Stations tab page
  5. Click the accompanying label and press Delete
  6. Adjust the location and the size of the sub-form. Here is an example:

    College Park Auto-Repair - Repair Oders

  7. Close the form
  8. When asked whether you want to save, click Yes

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:

Tab Controls

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 Browse. 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.

Practical Learning: Setting the Style of a Tab Control

  1. On the Ribbon, click File and click Open
  2. In the list of files, click StatesStatistics1 from the previous lesson
  3. In the Navigation Pane, double-click the States form to open it

    States Statistics

  4. After viewing the form, on the right side of the status bar of Microsoft Access, click Design View
  5. In the Controls section, click the Tab Control Tab Control
  6. Click the right side of the form
  7. While the tab control is selected, in the Property Sheet, click the Format tab and click Style
  8. In the Style field, select Buttons
  9. To change other characteristics, in the Property Sheet, click the All tab and change the following properties (the size you will set depend on the resolution of your monitor; if the following width and height are too much, reduce them; when writing this lesson, a 27" monitor was used):
    Name: tcWebsites
    Width: 11.65
    Height: 7.875
    Top: 0.125
    Left: 3.3646
    Font Name: Century (if you don't have that font, select Times New Roman)
  10. On the form, click the left Page_X to select one of the tab pages
  11. In the Property Sheet, click Format, click Caption and type State's Website
  12. On the form, click the other tab page (Page_X) to select it
  13. In the Property Sheet, click Caption and type Wikipedia

    States Statistics - Form Design

  14. Close the form
  15. When asked whether you want to save, click Yes

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:

Shape

Here is an example:

Shape

Practical Learning: Setting the Shape of a Tab Control

  1. On the Ribbon, click File and click Open
  2. In the list of files, click Metro System1
  3. In the Navigation Pane, right-click the MetroLines form and click Design View
  4. On the form, click the empty area on the right side of the tabs
  5. In the Control Formatting section of the Ribbon, click the Change Shape button and click Oval
  6. Om tje Property Sheet, click the Format tab and set the Tab Fixed Width value to 3.30

    Metro System

  7. On the Ribbon, click Design
  8. On the form, click the Stations tab to select it
  9. In the Design section, click the Subform / Subreport button Subform / Subreport
  10. Click inside the orange rectangle on the form

    SubForm Wizard

  11. In the first page of the wizard, accept the first radio button and click Next
  12. In the combo box of the second page, select Table: MetroStations
  13. In the Available List, double-click StationNumber
  14. Double-click StationName
  15. Double-click Location

    SubForm Wizard

  16. Click Next

    SubForm Wizard

  17. In the third page of the wizard, make sure the first radio button is selected, and click Next
  18. In the fourth page of the wizard, set the name to sfLinesStations

    SubForm Wizard

  19. Click Finish
  20. Click the accompanying label and press Delete

    Metro System

  21. Close the form
  22. When asked whether you want to save, click Yes
  23. In the Navigation Pane, right-click sfLinesStations and click Design View
  24. In the Property Sheet, set the Navigation Buttons to No
  25. To preview, switch the form to Form View

    Metro System

  26. Save the form

Page Breaks

Introduction

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

  1. On the Ribbon, click File and click Open
  2. In the list of files, click Ceil Inn1
  3. In the Navigation Pane, right-click the Employees form and click Design View
  4. Scroll down to display the middle of the form
  5. In the Controls section of the Ribbon, click the Page Break button Page Break
  6. On the form, position the mouse in the Details section at 27/8 of the vertical ruler and click

    Page Break

  7. Close the form
  8. When asked whether you want to save, click Yes

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.

Practical Learning: Using a Macro

  1. On the Ribbon, click Create
  2. In the Macros & Code section, click Macro
  3. In the Macro1 window, click the arrow of the combo box and select GoToPage
  4. In the Page Number text box, type 1

    Macro: Go To Page

  5. Click the Close button Close to close the macro window
  6. When asked whether you want to save, click Yes
  7. Set the name to mcrPage1 and click OK
  8. Close Microsoft Access
 
 
   
 

Previous Copyright © 2002-2016, FunctionX, Inc. Next