Home

Data Controls

 

A Label

 

Introduction

A label is a control that serves as a guide to the user. It provides a static text that the user cannot change but can read to get information about another control on the form or report. You can also use it to display simple information to the user.

Most controls on the form or the report are not explicit at first glance and the user would not know what they are. Therefore, you can assign a label to the control as a help to the user.

To add a label to a form or report, in the Controls section of the Ribbon, click Label Label and click on the form or report. Type the text that the label will display and press Enter (as we will see, most controls add their own label to the form or report).

 

Practical Learning: Introducing Data Controls

  1. Start Microsoft Access and open the Red Oak High School database you created in Lesson 5
  2. On the Ribbon, click Create and, in the Forms section, click Form Design
  3. In the Properties window, click the Data tab and set the Record Source to Students
  4. Save the form as Students and close it

Properties of a Label

Probably the most important and the most obvious characteristic of a label is the text it is displaying. The text is the label's caption. If you click the Label control on the Ribbon and click the form or report, you must first define its caption. If a label already has a caption, there are various ways you can edit it. For example, you can double-click it to access its Properties window and edit the string in the Caption field. On the other hand, to edit the caption of a label, on the form or report, click inside the label. That would put it into edit mode and you can edit it as you wish.

The appearance of a label is visibly controlled by its font characteristics. The Font name, also called its face, is the name of the font as defined by the operating system. We saw that there are various ways you can define the font characteristics of a control like the label.

The size of a label control its Width and its Height. Although the dimensions are closely related to the font characteristics, they can be independently defined. There are two main ways you can resize a label, which is equivalent to changing its size. To set your own size, in the Format tab of the Properties window of the label, change the values of the Width and Height properties. Unless you plan to show the background color of a label, probably the best way to resize a label is to make it adjust to the dimensions depending on the font size and the total characters width. To do this, position the mouse on one of the label's handle and double-click. The label's width and height would be set to accommodate its caption.

The position of a label is controlled by its Top and Left properties. The Top property defines the measure from the top left corner of the section where the label is positioned, to the top left corner of the label itself.

Practical Learning: Designing Labels

  1. From the resources that accompany these lessons, open the Bethesda Car Rental1 database
  2. On the Ribbon, click Create and, in the Forms section, click Form Design
  3. Right-click the form and click Form Header/Footer
  4. In the Controls section of the Ribbon, click Label Label and click the top-left section under the Header bar
  5. Type Bethesda Car Rental - Assets and press Enter
  6. While the new label is still selected, in the Font section of the Ribbon, click the arrow of the Font combo box and select Garamond
  7. Click the arrow of the Font Size combo box and select 24
  8. Click the Bold button Bold
  9. Click the arrow of the Font Color button and click Yellow (Standard Colors: 4th column 4 - 7th row).
  10. To resize the label, position the mouse on one of the handles surrounding the label and double-click
     
    Label
  11. Click the Form Header bar. In the Font section of the Ribbon, click the arrow of the Fill/Back Color and select Dark Red (Standard Colors: 1st column - 7th row)
  12. Click the Detail bar. In the Font section of the Ribbon, click the arrow of the Fill/Back Color and select Background (Access Theme Colors: 5th column - 1st row)
  13. Save the form as Assets

A Title

 

Introduction

In our introduction to the label control, we learned to add a string to a form. To make it act as the title of the form, we had put it in the header section. We also had to remember the name of the form to apply it to the label. Microsoft Access provides a faster means of creating a title. This is done using the Title control. When you do, Microsoft Access retrieves the name of the form, creates a label, and uses the name of the form as caption.

Creating a Title

Instead of going through the label to get a title, to formally create a title, in the Controls section of the Ribbon, click the Title control Title and click the form. When you click the form, if it did not have a form header section, that section would added to the form. If it had the section, that section would be used. Then, a new label with the name of the form as caption would be added to the form header section. When creating this label, Microsoft Access would use some default characteristics, such as the font name and size, and applied them to the label. Of course, you can change any of the characteristics, including the caption of the title.

Practical Learning: Adding a Title

  1. Re-open the Red Oak High School database
  2. In the Navigation Pane, under Students: Table, right-click the Students form and click Design View
  3. In the Controls section of the Ribbon, click Title Title and click the form
  4. As the label is still blinking, type Red Oak High School - Students and press Enter
  5. While the title is still selected, in the Font section of the Ribbon, change the following characteristics:
    Font: Georgia
    Font Size: 24
    Fore Color: Blue

    Style: Bold
  6. Save the form

A Hyperlink

 

Introduction

A hyperlink is a label that can be clicked to open an object of the data, an application on computer, a file from the network, or a web site (or web page). Before using it, the user can position the mouse on the label, which would change the cursor to a pointing finger. The user can click. As stated already, a hyperlink can be made to open almost any type of file or document. When creating it, you will decide what object or file would be opened or accessed.

Creating a Hyperlink

To create a hyperlink, display a form or a report in Design View:

A dialog box made of various sections would come up. In the left section, you can click Existing File or Web Page:

In this case, if you want to open a file, click Current Folder and use the Look In combo box to specify the folder where the file is located. Once you have specified the folder, in the large list box in the middle-center of the dialog box, locate the file, click it and click OK.

If you want to open a web page, you can choose one of the pages you had previously visited. To do this, in the second column from left, click the Browsed Pages button. All the files that the dialog box can "remember" would display in the list in the middle-center. You can then select the file. You can also click the arrow of the Address combo box to find out if the web site or web page you want is in the list. If you know the web site or the web page you want the link to eventually open, type it in the Address combo box. Once you have specified the file, click OK. This description also applies if you click the Recent Files button.

If you want the link to open an object of the same database, such as a form or a report, in the left column, click Object in This Database. The middle-center of the dialog box would display a tree view:

Before selecting an object, expand its node, then select the object, and click OK.

A hyperlink is primarily a label. As such, there are some characteristics you can change for it but you should make sure it would always be obvious to the user that it represents a hyperlink. To change the caption of the hyperlink, you can click it once and click it again to put it into edit mode, and edit its caption. You can also use the Properties window of the hyperlink to manage the label.

Practical Learning: Adding a Hyperlink

  1. The Students form of the Red Oak High School database should still be opened in Design View.
    In the Controls section of the Ribbon, click Hyperlink Hyperlink
  2. In the Insert Hyperlink dialog box, click the Address text box and type http://www.functionx.com/rosh
  3. In the Text to display text box, replace the text with School Information
     
  4. Click OK
  5. Move the hyperlink to the form footer section
  6. Save the form and close it

Other Labels

 

The Page Number

In a report meant to display various records on its many pages, you may want to display the page number. To assist you with this, Microsoft Access provides a special label. To get it, display the report in Design View. In the Control section of the Ribbon, click Page Numbers and click the report. The Page Numbers dialog box would come up:

Use the Page Numbers dialog box to specify what sentence would be used, and where, to display the page number. Once you are ready, click OK. The new label would be added to the Page Footer section of the report.

The Date and Time

When displaying a form, if you want to show the current and/or time, Microsoft Access can assist you with a label. Before creating the label, display the form or report in Design View. To add the label, in the Controls section of the Ribbon, click Date and Time and click the form. The Date and Time dialog box would come up:

Use the dialog box to specify what of the date or the time, including the formats, would display. Once you are ready, click OK. If the form or report did not have the appropriate header and footer section (the Form Header section for the form and the Report Header section for the report), the section would be created. If the section existed already, it would be used to host the label. When the label is created, by default, it is added to the header section (the Form Header section for the form and the Report Header section for the report). If you do not like those positions, you can move the label(s). To do this, simply click and drag it(them) to the desired section.

The Text Box

 

Introduction

A text box is a Windows control used to get or display text for the user’s interaction. At its most regular use, a text box serves as a place to fill out and provide information. You can also use it only to display text without allowing the user to change its content.

Like most other controls, the role of a text box is not obvious at first glance; that is why it should be accompanied by a label that defines its purpose. From the user’s standpoint, a text box is named after the label closer to it. Such a label is usually on the left or the top side of the corresponding text box. 

There are two main ways you can add a text box to a form or report:

Properties of a Text Box

Like every control on a form or report, the size of a text box is controlled by its Width and Height properties. The position of a text box is controlled by its Top and Left properties.

To make a text box read-only, that is, if you do not want the user to enter text in a text box, there are various alternatives. If you change the Enabled property from Yes to No, the text box would have a gray background and cannot receive focus. If you set the Locked property from No to Yes, the control would appear with a normal (white) background.

The Special Effects properties of the text box are expanded as compared to those available on a label. Besides the ability to raise or sink a text box, you can give it a thick, etched, or shadow border. 

After adding a text box to a form or report, you can configure it to receive its data from an existing table. This can be done after the Record Source of a form or report has been defined. To link a text box to the object that is the Record Source of a form or report, click the arrow of its Record Source combo box and select the desired field.

Practical Learning: Adding Text Boxes

  1. Re-open the Bethesda Car Rental1 database
  2. In the Navigation Pane, right-click the Assets form and click Design View
  3. Double-click the button at the interaction of the rulers. In the Properties window, click Record Source and select Assets
  4. In the Tools section of the Ribbon, click Add Existing Fields
  5. From the Field List, add each field and design the form as you see fit:
     
  6. Select each text box and, in the Controls section of the Ribbon, click the arrow of the Special Effects button -> Shadowed
  7. Save the form and switch it to Form View
     
  8. Switch the form back to Design View

Pictures

 

Introduction

A picture is a graphical object that can be used either as the background of a form or report or can be positioned on top of a database object. Before using such a picture, you should prepare it or at least have it handy.

In Lesson 8, we saw that, to use a picture as the background of a form or report, in Design View, you could open the Properties window of the form or report. Then, in the Format tab, you could click the Picture field to reveal its ellipsis button, use that button to locate and retrieve the picture. Once added to the form or report, you could use some other properties to specify how the picture would be displayed.

Practical Learning: Introducing Pictures

  1. From the resources that accompany these lessons, open the Altair Realtors1 database
  2. On the Ribbon, click Create and, in the Forms section, click Form Design
  3. Double-click the button at the intersection of the rulers to access the Properties window
  4. Set the Record Source to Properties
  5. Save the form as Properties
  6. Right-click the form and click Form Header/Footer
  7. In the Controls section of the Ribbon, click Label and click under the Form Header bar
  8. Type Properties Listing and press Enter
  9. In the Tools section of the Ribbon, click Add Existing Fields and design the form as follows (do not try to match the fonts; instead, select the closest fonts you have on your computer)
     
  10. Save the form

Unbound Objects

Instead of an object whose data is linked to a field of the database, you can have an object on your form or report to simply complete the design of the parent object. That is the case for logos or fine prints on forms and reports. On a form or report, an object whose data is not linked to a specific record is referred to as unbound.

To add an unbound object, display the form or report in Design View. In the Controls section of the Ribbon, click the Unbound Object Frame button Unbound Object Frame and click on the form or report. If the Control Wizard button is clicked on the Ribbon, a wizard will help you select the object you want to add to your form or report.

Practical Learning: Binding an Object

  1. On the Ribbon, make sure that the Use Control Wizards button is highlighted Use Control Wizard.
    In the Controls section of the Ribbon, click the Unbound Object Frame Unbound Object Frame and click under the Form Footer bar on the right side
  2. On the Microsoft Office Access dialog box, click the Create From File radio button and click Browse...
  3. From the resources that accompany these lessons, select the Altair.bmp file and click OK
  4. On the Microsoft Office Access dialog box, click OK
  5. Adjust the picture and save the form before previewing it
     
  6. Close the form 

Bound Objects

When reviewing data types, we saw that a bound object is one that is tied to an existing field on a table. To add such a bound object to a form or report, in the Controls section of the Ribbon, you can click Bound Object Frame Bound Object Frame and click the desired area of the form or report:

Altair Realtors

You can then design the size and position of the frame as you see fit:

Since the object is (supposed to be) bound to a field on the source table (or the source report), the most important piece of information you should provide is the table's field that holds the bound data. This is specified in the Record Source property. After doing this, the records would show the value of the bound object (you should have associated the objects to each record, using the Insert Object dialog box):

A Logo

A logo is a picture that represents or symbolizes a company. You can use such a picture on a form or report to make it cute. In our discussion of unbound pictures, we learned that we could add a picture independent of any record. We also had to decide where to position the picture. If we wanted it to act a as a logo, we had to put it in the form header section. To formally add a logo to a form a report, Microsoft Access can assist you.

Before using a logo in your database, you must create it, design it, and save it as a picture file. To add the logo, display the form or report in Design View. In the Controls section of the Ribbon, click Logo Logo. This would open the Insert Logo dialog box where you can select a picture.

Practical Learning: Adding a Logo

  1. Re-open the Red Oak High School database
  2. In the Navigation Pane, under Students: Table, right-click the Students form and click Design View
  3. In the Controls section of the Ribbon, click Logo Logo
  4. From the Insert Picture dialog box, locate the resources that accompany these lessons and select the rosh.png picture
  5. Click OK
  6. Move the logo to the left and the title to the center of the form footer section of the form:
     
  7. Save the form

The Line and the Rectangle

 

The Line

To enhance the appearance of sections or controls on forms and reports, Microsoft Access provides a line object. You can use it to trace horizontal, vertical, or diagonal lines of various preset widths. The use, position, and orientation of a line only depend on your goal.

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.

Practical Learning: Adding Lines

  1. The Students form of the Red Oak High School database should still be opened in Design View.
    In the Controls section of the Ribbon, click Line Line and drag a horizontal line below the title in the form header section
  2. Again, in the Controls section of the Ribbon, click Line Line and drag a horizontal line below the first line
  3. While the new line is still selected, in the Controls section of the Ribbon, click the arrow of the lick the Line Thickness button and select 2 pt
  4. Move both line to the left to touch the left border
     
  5. Save the form

The Rectangle

To enhance the appearance of sections or controls on forms and reports, Microsoft Access provides a rectangle object. It is not a control (for example, it does not "own" of fire events; in other words, it does not programmatically communicate with the operating system, it does not store or receive data nor does it provide data). It is a graphical object primarily intended for aesthetic purposes. There is no formal directive on how to use the rectangle.

There are various reasons you would use a rectangle on a form or a report. You can use it to "hold" other controls. For example, if you want to isolate a group of controls, you can include them inside of a rectangle. 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 exploit the aesthetic role of a rectangle, you can change such as aspects as the back color, the borders, or the special effects, etc.

Practical Learning: Adding a Rectangle

  1. The Students form of the Red Oak High School database should still be opened in Design View.
    In the Controls section of the Ribbon, click Rectangle Rectangle and click the Detail section of the form
  2. While the rectangle is still selected, in the Font section of the Ribbon, click the arrow of the Fill/Back Color button and select Background (Access Theme Colors: 5th column - 1st row)
  3. In the Controls section of the Ribbon, click the arrow of the Special Effects button and select Special Effects: Shadowed
  4. Access the Properties window of the form and set its Record Selectors property to No
     
    Red Oak High School - Students
  5. Save the form

Lessons Summary

 

MCAS: Using Microsoft Office Access 2007 Topics  
C7 Modify the design of reports and forms
 

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