Home

Introduction to Categories of Windows Controls

Label-Based Controls

Introduction

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

  1. Start Microsoft Access
  2. From the resources that accompany these lessons, open the Ceil Inn1 database
  3. In the Navigation Pane, right-click the Occupancies form and click Open
  4. After viewing the form, in the Views section of the Ribbon, click the button under View and click Design View

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

  1. In the Controls section of the Design tab of the Ribbon, click Label Label
  2. On the form, click under the Form Header bar
  3. Type Ceil Inn - Occupancies and press Enter
  4. On the Ribbon, click Home
  5. Using the tools in the Text Formatting section of the Ribbon, configure the label as follows:
    Font: Bodoni MT (if you don't have that font, select Garamond)
    Font Size: 28
    Font Color: Light Blue 1 (Standard Colors: 5th column - 2th row)
  6. To resize the label, position the mouse on one of the handles surrounding the label and double-click

    Label

  7. On the form, right-click the label you had created and click Copy
  8. In the Navigation Pane, right-click the Customers form and click Design View
  9. Right-click unuder the Form Header bar and click Paste
  10. Change the text to Ceil Inn - Customers and position it like the other
  11. On the Ribbon, click File and click Open
  12. In the list of files, click FunDS1
  13. On the Ribbon, click Create
  14. In the Forms section, click Form Design
  15. Right-click the body of the form and click Form Header/Footer
  16. In the Property Sheet, click the All tab and change the following properties:
    Record Source: ShoppingSessions
    Caption: Fun Department Store - Shopping Sessions
  17. Save the form as ShoppingSessions
  18. In the Controls section of the Ribbon, click the Label and click under the Form Header bar of the form
  19. Type Fun Department Store and press Enter
  20. In the Controls section of the Ribbon, click the Label Label and click under the previous label on the form
  21. Type Shopping Session and press Enter
  22. Complete the design as follows:

    Label

  23. In the Navigation Pane, right-click the StoreItems form and click Design View
  24. In the Controls section of the Ribbon, click the Label and click under the Form Header bar of the form
  25. Type Fun Department Stores - Store Items and press Enter
  26. Complete the design as follows:

    Label

  27. In the Navigation Pane, right-click the Employees form and click Design View
  28. In the Controls section of the Ribbon, click the Label and click under the Form Header bar of the form
  29. Type Fun Department Store and press Enter
  30. In the Controls section of the Ribbon, click the Label and click under the Form Header bar of the form
  31. Type Employee and press Enter
  32. Complete ethe design as follows:

    Label

  33. On the Ribbon, click File and click Open
  34. From the resources that accompany these lessons, open the Altair Realtors1 database
  35. When asked whether you want to save, click Yes each time

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

Practical Learning: Adding a Title

  1. In the Navigation Pane, double-click the Properties form to view it

    Altair Realtors - Properties

  2. After viewing the form, right-click its tab and click Design View
  3. In the Header / Footer section of the Ribbon, click Title Title
  4. As the label is still blinking, type Altair Realtors - Properties and press Enter

    Altair Realtors - Properties

  5. On the Ribbon, click Arrange
  6. In the Table section of the Ribbon, click Remove Layout
  7. In the Property Sheet, click Format and click Add
  8. Change the following properties:
    Name: lblTitleShadow
    Top: 0.1667
    Left: 0.0833
    Font Name: Blackoak Std (if you don't have that font, select Georgia)
    Font Size: 20
    Fore Color: Text 1 (Theme Colors: 1st column, 2nd row)
  9. Double-click one of the points around the selected title:

    Altair Realtors - Properties

  10. Right-click the title and click Copy
  11. Press Ctrl + V
  12. While the new title is still selected, in the Property Sheet, change the following properties:
    Name: lblGoldTitle
    Top: 0.0833
    Left: 0
    Fore Color: Accent 4, Lighter 80% (Theme Colors: 8th column, 2nd row)

    Altair Realtors - Properties

  13. Close the form
  14. When asked whether you want to save, click Yes
  15. On the Ribbon, click File and click Open
  16. In the list of files, click Ceil Inn1
  17. On the Ribbon, click Create
  18. In the Forms section, click Form Design
  19. Double-click the button at the intersection of the rulers
  20. In the Property Sheet, click the Format tab and change the following characteristics:
    Caption: Ceil Inn - Switchboard
    Width: 6.25
    Auto Center: Yes
    Record Selectors: No
    Navigation Buttons: No
  21. Click the body of the form to select the Detail section
  22. In the Format tab of the Ribbon, click Height and type 4.85
  23. To save the form, press Ctrl + S
  24. Set the file name as Switchboard and click OK
  25. Close the Switchboard form

The Date and Time

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

Date and Time

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

Introduction

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:

  • Press Ctrl + K
  • In the Controls section of the Ribbon, click the Hyperlink control Hyperlink and click the form or report

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

Insert Hyperlink

You can also use the Property Sheet of the hyperlink to manage its label.

Practical Learning: Adding a Hyperlink

  1. In the Navigation Pane, right-click Switchboard and click Design View
  2. On the Ribbon, click Design if necessary.
    In the Controls section of the Ribbon, click Hyperlink Hyperlink
  3. In the Link To list of the Insert Hyperlink dialog box, click Object In This Database
  4. In the Text to Display, type Customers
  5. In the main list, click the + button of Forms to expand it
  6. Under Forms, click Customers

    Insert Hyperlink

  7. Click OK
  8. Drag the newly added label to the main area of the form
  9. In the Controls section of the Ribbon, click Hyperlink Hyperlink
  10. In the Link To list of the Insert Hyperlink dialog box, make sure Object In This Database is selected (otherwise, click it).
    In the Text to Display, type Occupancies
  11. In the main list, click the + button of Forms to expand it
  12. Under Forms, click Occupancies
  13. Click OK
  14. Press Ctrl + K
  15. In the Link To list, make sure Object In This Database is selected (otherwise, click it).
    In the main list, expand the Forms node
  16. Double-click Rooms
  17. Save the form

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

  1. On the Ribbon, click Design if necessary.
    In the Controls section of the Ribbon, click Label Hyperlink and click on the form under the other links
  2. Type Payments and press Enter
  3. On the form, double-click the new Payments label to access its properties.
    In the Property Sheet, click Format if necessary.
    Click Hyperlink Address and click its browse button
  4. In the Link To list, make sure Object In This Database is selected (otherwise, click it).
    In the Text to Display, make sure Payments displays (otherwise, type it).
    In the main list, expand the Forms node
  5. Click Payments
  6. Click OK
  7. On the Ribbon, click Design if necessary.
    In the Controls section of the Ribbon, click Label Hyperlink and click on the form under the other links
  8. Type Employees and press Enter
  9. In the Format tab of the Property Sheet, click Hyperlink Address and click its browse button
  10. In the Link To list, make sure Object In This Database is selected (otherwise, click it).
    In the Text to Display, make sure Employees displays (otherwise, type it).
    In the main list, expand the Forms node
  11. Double-click Employees
  12. Press Ctrl + A to select all labels
  13. On the Ribbon, click Format
  14. In the Font section, set the following characteristics:
    Font: Bodoni MT Black (if you don't have that font, select Garamond)
    Font Size: 36
  15. As the labels are still selected, double-click one of the handles around it to resize the labels
  16. Move the labels and position them as you see fit or as follows:

    Ceil Inn - Switchboard

  17. Save the form

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:

  • If the table is displaying in the Datasheet View:
    • Click a cell under Click to Add. On the Ribbon, click Fields. In the Add & Delete section, click More Fields and click Hyperlink

      A Hyperlink as a Data Type

    • On the table, click Click to Add and click Hyperlink
  • If the table is displaying in the Design View, specify the name of the column under Field Name. In the Data Type, select Hyperlink

You can also change the type of an existing field to support hyperlinks, and you can insert a column that supports hyperlinks.

Practical Learning: Creating a Link-Based Column

  1. On the Ribbon, click File and click Open
  2. In the list of files, click StatesStatistics1
  3. In the Navigation Pane, right-click the States table and click open
  4. On the table, click the empty cell under Click to Add
  5. On the Ribbon, click Fields
  6. In the Add & Delete section, click More Fields, and click Hyperlink
  7. Type StateWebsite and press Enter
  8. In the menu that appears, click Hyperlink
  9. Type Wikipedia and press Enter
  10. Press Esc
  11. Update a few records as follows:
     
    Abbrv StateWebsite Wikipedia
    AL http://www.alabama.gov/ https://en.wikipedia.org/wiki/Alabama
    AK http://alaska.gov/ https://en.wikipedia.org/wiki/Alaska
    AZ https://az.gov/ https://en.wikipedia.org/wiki/Arizona
    AR http://www.arkansas.gov/ https://en.wikipedia.org/wiki/Arkansas
    CA http://www.ca.gov/ https://en.wikipedia.org/wiki/California
 

The Text Box

Introduction

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:

  • From the Ribbon, can click the Text Box control Text Box and click a section of the form or report. By default, placing a text box on the form or report also adds a corresponding label to its left
  • If you drag a text-based field from the Field List and drop it on the form or report, the field would place a text box and its corresponding label

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:

  • None: This is the default value. It indicates that the text box should not display a scroll bar
  • Vertical: This means that the text box should display the scroll bar

Practical Learning: Configuring a Form

  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 MetroStations form and click Design View
  4. Click the Summary text box to select it
  5. In the Property Sheet, click the Format tab, click Height and type 0.45
  6. On the form, right-click the left Location (the label) and click Cut
  7. Right-click the area under Form Header and click Paste
  8. Move the label to the right side
  9. In the same way, move the labels from the Detail section to the Form Header section
  10. Position the labels so you can see them and complete the design of the sub-form as you like. Here is an example:

    Properties of a Text Box

  11. On the Ribbon, click File and click Open
  12. In the list of files, click RoadSystem1
  13. When asked whether you want to save, click Yes
  14. In the Navigation Pane, right-click the Roads form and click Design View
  15. On the form, click the Location text box to select it
  16. In the Property Sheet, click the Format tab, click Height and type 0.45

    Properties of a Text Box

  17. Save the form
  18. On the Ribbon, click File and click Open
  19. In the list of files, click Ceil Inn1
  20. In the Navigation Pane, double-click the Employees form to open it:

    Customers

  21. After viewing it, right-click its title bar and click Design View
  22. Double-click the Detail bar
  23. In the Property Sheet, click the All tab and change the Height value to 5.55
  24. Scroll down to display the bottom part of the form
  25. In the Controls section, right-click the Text Box control Text Box and click Drop Multipl Control
  26. Click in the Detail area of the form 4 times
  27. On the Ribbon, click the Select button Select
  28. In the Property Sheet, click the All tab
  29. For each text box, change the caption of the accompanying label and change the name of the text box as follows:

    Ceil Inn - Employees

    Label Caption Text Box Name
    Employee Name: txtEmployeeName
    Employee Name: lblEmployeeName
    Monthly Salary: txtMonthlySalary
    Yearly Salary: txtYearlySalary
  30. Close the form
  31. When asked whether you want to save, click Yes
  32. On the Ribbon, click File and click Open
  33. In the list of files, click FunDS1
  34. In the Navigation Pane, right-click the Forms section, click Form Design
  35. Right-click the StoreItems form and click Design View
  36. Using the labels Hyperlink and text boxes Text Box from the Controls section of the Ribbon, complete the design of the form as follows:

    Form Design

    Control Caption Name
    Label Hyperlink Date in Store  
    Label Hyperlink Unit Price  
    Label Hyperlink Today  
    Label Hyperlink Days in Store  
    Label Hyperlink Discount  
    Label Hyperlink Rate  
    Label Hyperlink Amount  
    Label Hyperlink After Discount  
    Text Box Text Box   txtDateInStore
    Text Box Text Box   txtUnitPrice
    Text Box Text Box   txtToday
    Text Box Text Box   txtDaysInStore
    Text Box Text Box   txtDiscountRate
    Text Box Text Box   txtDiscountAmount
    Text Box Text Box   txtPriceAfterDiscount
  37. Close the form
  38. When asked whether you want to save, click Yes
  39. To start a new database, on the Ribbon, cllick File and click New
  40. Click Blank Desktop Database
  41. Set the name as College Park Auto-Repair1 and click Create
  42. Double-click ID on the default table to put it into edit mode. Type ReceiptNumber and press Enter
  43. Right-click the tab of the table and click Design View
  44. Set the table name as RepairOrders and click OK
  45. Add new fields with the following names and captions:
     
    Field Name Caption
    ReceiptNumber Receipt #
    CustomerName Customer Name
    PhoneNumber Phone #
    Address  
    City  
    State  
    ZIPCode ZIP Code
    Make  
    Model  
  46. Save and close the table
  47. To start a new table, on the Ribbon, click Create and click Table
  48. Double-click ID on the table to put it into edit mode
  49. Type JobPerformedID and press Tab
  50. In the list of options, select Number and type ReceiptNumber
  51. Press Tab and select Number in the list
  52. Click below JobPerformedID and type JobName and press Enter
  53. Save the table as JobsPerformed and close it
  54. To start a new table, on the Ribbon, click Create and click Table
  55. Double-click ID, type PartUsedID and press Tab
  56. In the list of options, select Number, type ReceiptNumber and press Enter
  57. Select Short Text in the list, type PartName and press Enter
  58. Save the table as PartsUsed and close it
  59. On the Ribbon, click Create and click Form Design
  60. Right-click the body of the form and click Form Header/Footer
  61. In the Property Sheet, click the All tab and change the following characteristics:
    Record Source: JobsPerformed
    Default Views: Continuous Forms
    Navigation Buttons: No
  62. Save the form as sfJobsPerformed and design it as follows:

    College Park Auto-Repair - Sub-Form Design - Jobs Performed

  63. Save and close the form
  64. On the Ribbon, click Create and click Form Design
  65. Right-click the body of the form and click Form Header/Footer
  66. In the All tab of the Property Sheet, change the following characteristics:
    Record Source: PartsUsed
    Default Views: Continuous Forms
    Navigation Buttons: No
  67. Save the form as sfPartsUsed and design it as follows:

    College Park Auto-Repair - Sub-Form Design - Parts Used

  68. Save and close the form
  69. On the Ribbon, click Create and click Form Design
  70. Right-click the body of the form and click Form Header/Footer
  71. In the Property Sheet, change the following characteristics:
    Record Source: RepairOrders
    Caption: College Park Auto-Repair: Repair Orders
    Auto Center: Yes
  72. Save the form as RepairOrders and design it as follows:

    College Park Auto-Repair - Form Design - Repair Orders

  73. Save and close the form
  74. On the Ribbon, click File and click Options
  75. On the left, click Current Database and on the right, click Overlapping Windows
  76. Click OK

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

  • Close Microsoft Access

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