Home

Introduction to Windows Controls

 

The 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 Design tab 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
  2. From the resources that accompany these lessons, open the Bethesda Car Rental1 database
  3. On the Ribbon, click Create and, in the Forms section, click Form Design
  4. Right-click the form and click Form Header/Footer

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. In the Controls section of the Design tab of the Ribbon, click Label Label
  2. Click the top-left section under the Form Header bar 
  3. Type Bethesda Car Rental - Assets and press Enter
  4. On the Ribbon, click Home
  5. While the new label is still selected, in the Text Formatting section of the Ribbon, click the arrow of the Font combo box and select Garamond
  6. Click the arrow of the Font Size combo box and select 24 
  7. Click the Bold button Bold
  8. Click the arrow of the Font Color button and click Dark Blue (Standard Colors: 8th column - 7th row). 
  9. To resize the label, position the mouse on one of the handles surrounding the label and double-click
     
    Label
  10. Click the Form Header bar
  11. Click the Detail bar
  12. On the Ribbon, click Home
  13. In the Text Formatting section of the Ribbon, click the arrow of the Background Color and click More Colors...
  14. Click Custom and create a color with the following values:
    Red: 221
    Green: 241
    Blue: 255
  15. Click OK
  16. Close the form, when asked whether you want to save, click No

The 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 this, 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 Design tab 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 be 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. Open Real Estate Properties1 you modified in Lesson 3
  2. On the Ribbon, click Create
  3. In the Forms section, click Form Design
  4. In the Properties window, click Format and change the following characteristics
    Caption: Altair Realtors - Properties
    Auto Center: Yes
    Record Selector: No
    Navigation Buttons: No
  5. In the Controls section, click Title Title
  6. As the label is still blinking, type Altair Realtors - Properties and press Enter
  7. On the Ribbon, click Format
  8. 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
  9. Right-click the new title -> Size -> To Fit
  10. To preview the form, right-click its tab (Form1) and click Form View
  11. Right-click the tab of the form and click Design View

A Hyperlink

 

Introduction

A hyperlink is a label that can be clicked to open an object of the database, an application on the 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. Here is an example:

You can also use the Properties window of the hyperlink to manage the label.

Practical Learning: Adding a Hyperlink

  1. On the form, click below the Detail bar
  2. 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 main list, click the + button of tables to expand it
  5. Click Condominiums Text to display text box, replace the text with School Information
     
  6. Click OK
  7. Once again, in the Controls section of the Ribbon, click Hyperlink Hyperlink
  8. In the Link To list, click Object In This Database
  9. In the main list, expand the Tables node
  10. Double-click Single Families
  11. Once again, in the Controls section of the Ribbon, click Hyperlink Hyperlink
  12. In the Link To list, click Object In This Database
  13. In the main list, expand the Tables node
  14. Double-click Townhouses
  15. In the Detail section of the form draw a fake rectangle to includes the three hyperlinks
  16. On the Ribbon, click Format
  17. Using the objects in the Font section, change the following characteristics:
    Font: Bodoni MT Black (if you don't have that font, use another)
    Font Size: 24
  18. Right-click one of the link (they are still selected) -> Size -> To Fit
  19. On the Ribbon, click Arrange
  20. In the Table section, click Stacked
  21. In the Rows & Columns section, click Insert Left
  22. Again in the Rows & Columns section, click Insert Above
     
    Altair Realtors
  23. Right-click the form's tab and click Form View
  24. Click each of the links to open the corresponding and, after viewing the table, close it
  25. Close the form
  26. When asked whether you want to save, click Yes
  27. Set the name to Real Estate and click OK

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 Design tab of the Ribbon, click Page Numbers 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 date 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 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. 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. On the Ribbon, click Create
  3. In the Forms section, click Form Design
  4. Double-click the button at the intersection of the rulers to open the Properties window.
    Click the Data tab. Click Record Source. Then click the arrow of its combo box and select CarConditions
  5. In the Controls section of the Design tab of the Ribbon, click the Text Box and click the form
  6. If the Properties window is not visible, right-click the text box and click Properties.
    While the text box is still selected, in the Properties window, click All. Click Name, type txtCarCondition and press Enter
  7. Still in the Properties window, click Control Source. Click the arrow of its combo box and select CarCondition
  8. Click the label that accompanies the text box
  9. In the Properties window, click Caption, type Car Condition: and press Enter
     
    Car Condition
  10. On the form, click the CarCondition text box
  11. In the Properties window, click Format.
    Click Special Effects, then click the arrow of its combo box and select Shadowed
     
    Car Conditions
  12. Close the form
  13. When asked whether you want to save, click Yes
  14. Set the name to Car Conditions and press Enter
       

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.

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 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. Re-open the Real Estate Properties1 database
  2. In the Navigation Pane, right-click the Real Estate form and click Design View
  3. 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
  4. On the Microsoft Access dialog box, click the Create From File radio button
  5. Click Browse...
  6. From the resources that accompany these lessons, select the Altair.bmp file
  7. Click OK
  8. On the Microsoft Office Access dialog box, click OK
  9. Adjust the picture and save the form before previewing it
     
    Altair Realtors
  10. To preview the form, right-click its tab and click form View
     
    Altair Realtors
  11. Close the form 

Bound Objects

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

Altair Realtors

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

  Altair Realtors

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. Open the Red Oak High School database from Lesson 5
  2. On the Ribbon, click Create
  3. In the Forms section, click Form Design
  4. In the Controls section of the Ribbon, click Logo Logo
  5. From the Insert Picture dialog box, locate the resources that accompany these lessons and select the rosh.png picture
  6. Click OK
     
    Adding a Logo

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. In the Controls section of the Ribbon, click Line Line and drag a horizontal line below the logo in the form header section
     
    Line Drawing
  2. Again, in the Controls section of the Ribbon, click Line Line and drag a horizontal line below the first line
  3. On the Ribbon, click Format
  4. While the new line is still selected, in the Control Formatting section, click Shape Outline -> Line thickness -> 2 pt
  5. To preview the form, right-click its tab and click form View

    Line Drawing
  6. Right-click the title bar of the form and click Design View

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. In the Controls section of the Ribbon, click Rectangle Rectangle and click the Detail section of the form
  2. On the Ribbon, click Home
  3. While the rectangle is still selected, in the Text Formatting section of the Ribbon, click the arrow of the Background Color button and select Tan, Background 2 (Theme Colors: 2nd column - 1st row)
  4. In the Properties window, click Format. Click Special Effects, then click the arrow of its combo box and select Shadowed
  5. On the form, double-click the button at the intersection of the rulers
  6. In the Format tab of the Properties window, double-click Record Selectors to set its balue to No
     
    Red Oak High School
  7. To preview the form, right-click its tab and click form View

    Red Oak High School
  8. Close the form
  9. When asked whether you want to save, click No

The Option Group

 

Introduction

An option group is a rectangular object used to group a set of controls in a section. There may not be any relationship among the controls. The main idea might simply be to indicate that the controls go together, for any reason. As you may guess, this is sometimes done for aesthetic reasons.

Practical Learning: Introducing Option Groups

  1. Open the Danilo Pizza1 database
  2. In the Navigation Pane, right-click Pizza Order1 and click Design View

Danilo Pizza

Creating a Group Box

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. When you add it to a form or report, if the Use Control Wizards option is on Use Control Wizards, the Option Group Wizard would start. If you only want to create a simple group box, you should cancel the wizard.

Practical Learning: Introducing the Group Box

  1. In the Controls section, click the More button on the right side and click Use Controls Wizard to make it white Use Control Wizard
  2. Still in the Controls section, click the Option Group control Option Group
  3. Click the top-left section of the form under Order Date

Properties of Option Groups

As far as Microsoft Windows is concerned, an option group is a static control. This means that its appearance and the string it displays are its most important features. The option group is equipped with a rectangle that sets the area of its body. To enhance its appearance, you can set its Back Style, its Border Style, its Back Color, and its Border Color properties.

Besides the rectangle around it, 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: Creating an Option Group

  1. Double-click the label that accompanied the new option group
  2. In the Properties window, click Format and change the following characteristics
    Caption: Pizza Size
    Back Color: Background 2, Darker 10%
    Border Style: Solid
    Border Width: Hairline
    Border Color: Text 1, Lighter 35%
    Special Effect: Flat
    Font Name: Garamond
    Font Size: 12
    Font Weight: Bold
    Fore Color: Text 1
  3. Add other option groups and complete the design of the form as follows:
     
    Danilo Pizza
  4. Preview the form:
     
    Danilo Pizza
  5. Save the form
  6. Microsoft Microsoft Access
   
 

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