A label is a simple control that displays text in a form or a report. A label provides static text that the user cannot change. Microsoft Access various objects used to add a label to a form or a report.
Practical Learning: Introducing Labels
The Label Control
The most basic control used to display text on a form or report is the Label control. To add a label to a form or report, in the Controls section of the Design tab of the Ribbon, click Label and click the desired area in the form or the report. Type the text that the label will display.
Probably the most important and the most obvious characteristic of a label is the text it displays. 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. This is done by immediately typing text. If a label already has text, you can edit it. You can double-click it to access its Property Sheet and edit the text 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.
Practical Learning: Creating a Label
The Title Label
We know that a label can be used to create a title for a form or a report. Microsoft Access provides a faster means of creating a title. This is done using the Title control . When you use it, Microsoft Access retrieves the name of the form, creates a label, and uses the name of the form as caption.
Instead of going through the label to get a title, to formally create a title, in the Controls section of the Design tab of the Ribbon, click the Title control and click the form or report. When you click the form or report, if it did not have the right header section, that section would be added to the form or report. If it had the section, that section would be used. The new label with the name of the form as caption would be added to the header section.
When you create a Title label, Microsoft Access uses some default characteristics, such as the font name and size, and apply them to the label. Of course, you can change any of the characteristics, including the caption of the title.
When displaying a form or report, if you want to show the current date and/or time, display the form or report in Design View. In the Controls section of the Ribbon, click Date and Time and click the form or report. The Date and Time dialog box would come up:
Use the dialog box to specify which one 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. Here is an example:
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.
A hyperlink is an object (a label, a picture, a button, etc) that can be clicked to open an object of the database, an application on the computer, a file from the network, or a web page. A hyperlink can be made to open almost any type of file.
Microsoft Access supports various types of hyperlinks.
A Labeled Link
Probably the easiest way to have a hyperlink is to add a label to a form or report and transform that label into a link. Microsoft Access provides various ways to do this. The easiest way is to display the form or a report in Design View. Then:
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 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. 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. Here is an example:
You can also use the Property Sheet of the hyperlink to manage its label.
Practical Learning: Adding a Hyperlink
A Link from a Label
You can transform a regular label into a link. To do this, in the Property Sheet of the label, click Format and use the Hyperlink fields.
Practical Learning: Transforming a Label to a Hyperlink
A Hyperlink as a Data Type
One of the ways Microsoft Access supports hyperlinks is as a data type of a column. This allows you create a link to a document, to provide an email address, or to indicate a webpage.
To create a new column that supports links:
You can also change the type of an existing field to support hyperlinks, and you can insert a column that supports hyperlinks.
A text box is a control used to display text in a form or report, or to get text in a form. To indicate its role, a text box is usually accompanied by a label.
As seen in previous lessons, there are two main ways you can add a text box to a form or report:
Properties of a Text Box
If you click a text box or a control that is accompanied by a label and delete it, its label gets deleted also.
To prevent the user from changing the text of a text box (to make it read-only), 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.
If the content of a text box is longer than the width of the control can display, part of the text may be hidden. The alternative is to heighten the text box to give it more room. In this case also, you can equip the text box with scroll bars. To support this, the Property Sheet of the text box provides the Scroll Bars property. Its values are:
Practical Learning: Configuring a Form
Text Box Events
As you know already, to use a text box, the user can click the control and start typing. If the control already contained some text, the user can edit it using the Space, the Backspace, the Delete, and the other letter keys. When the text is being entered or edited, the control fires the On Change event.
Practical Learning: Ending the Lesson