Home

Introduction to Controls Design

 

Form and Report Design Fundamentals

 

Introduction

So far, we have used forms or reports already available with a database or forms and reports generated automatically for us. We simply accepted how those forms or reports looked and they were presented to us as friendly as possible. Form and report design consists of specifying the various characteristics of the object.

You can set the characteristics when creating a brand new form or report or you can change some aspects of an already designed form or report. These include the layout of the object, the color of its body, the objects positioned on it, etc. To design a form or a report or to change the existing design of a form or report, you must display it in an appropriate setting called the Design View.

To display a form or a report in Design View:

  • If the form or the report is currently closed, you can right-click its name in the Navigation Pane and click Design View
  • If the form is currently opened, you can right-click it (somewhere on its body) and click Design View

As mentioned previously, you can create a form whose data come from a table or you can create a form that is not meant to display data.

Practical Learning: Introducing Form and Report Design

  1. Start Microsoft Access and create a Blank Database named Exercise2
  2. Close the default table but do not save it
  3. To create a new form, on the ribbon, click Create
  4. In the Forms section, click Blank Form
  5. To save the form, press Ctrl + S
  6. Set the name to Central and click OK
     
  7. To display the form in Design View, right-click the middle of the form and click Design View 

The Properties Window

When designing a form or a report, one of the objects you will regularly use is called the Properties window. To get the Properties window of the properties associated with a control, while the form or report is in Design View, right-click the object and click Properties. To display the Properties window for the form or the report in Design View:

  • You can double-click the button in the top-left section under the tab or the title bar
  • In the Design section of the ribbon, you can click the Property sheet button Property Sheet
  • You can right-click anywhere on the form or report and click Properties

Any of these actions would display the Properties window. The Properties window is dockable. This means that you can drag its title bar and position it either in the middle of the screen or to the left or the right side of the screen:

Properties

There are various ways you can close or hide the Properties window:

  • In the Design section of the ribbon, when the Property Sheet button is highlighted , this means that the Properties window is currently displaying. To close or hide it, you can click the same button and it looses its highlighting Property Sheet
  • As a regular window, you can click its close button Close to hide it
  • You can right-click either the form, the report, or any control that is displaying in the Design View and click Properties
  • When we get to the Field List, we will see another action that hides the Properties window.

The title bar of the Properties window displays the Property Sheet string. Under the title bar, a label identifies the type of object whose characteristics the Properties window is displaying. Under the label, there is a combo box that displays the name of the object whose characteristics are displayed in the Properties window. To change the object whose properties you want to access:

  • You can click the form, the report or the control
  • You can select its name in the combo box of the Properties window

Made of five property pages, the Properties window displays the characteristics associated with the object or the control that is selected on the screen or in its top combo box.

Practical Learning: Accessing the Properties Window

  1. To display the Properties window, on the ribbon, click Design
  2. In the Tools section, click Property Sheet

Windows Controls

To populate a form or a report, you will use various objects called Windows controls or simply, controls. These are the objects a user of your database uses to interact with your product. The objects are available in the ribbon when the form or report is in Design View. To access the controls, you can click Design on the ribbon. The controls are listed in the Controls section:

In our lessons, we will mostly use controls listed in the Controls section of the ribbon; but if they are not enough, to access more controls, you can click the ActiveX Controls button. This would bring the Insert ActiveX Control dialog box from where you can select a control:

Insert ActiveX Control

After selecting the desired control, you can click OK.

The Windows controls are represented with small icons in the Controls section. Each item is identified with a name. Some of these objects may not be familiar to you. To know the name of a control and have an idea of what it is used for, you can position the mouse on top and a tool tip would appear. Here is an example for a combo box:

Controls

For the rest of our lessons, each control will be referred to by the name that displays from the tool tip.

Practical Learning: Identifying the Controls

  • Position the mouse (do not click) on each object in the Controls section of the ribbon and see the name of the control

Controls Design Fundamentals

 

Adding Controls to a Form or a Report

To select a control, you can click it in the Controls section. Once a control, such as the button Button, has been clicked, it becomes highlighted . If you clicked a control by mistake but want to use another, you can click that other control. If you clicked a control but do not want to use any, you can click the Select button Button that is used to dismiss any selected control.

There are various techniques you can use to add a control to your form or report:

  • To add a control to a form or a report, you can click it and click the form or the report. In the same way, you can add different controls and as many as necessary
  • If you will be adding a control many times, in the Controls section, you can double-click it and click the form or report as many times as necessary. To dismiss the control, you can click the Select button Button.
  • To add a control without clicking the form or report, press and hold Shift, then click the control as many times as necessary. When you have reached the desired number of controls, release Shift

Some controls are meant to assist you with performing an action on the form or report. To make this possible, the Controls section is equipped with a Use Control Wizards button . If the control is set to perform an action, to use that action, the Use Control Wizards button must be selected or highlighted . In this case, if you click a control and click the form or report, a wizard would come up and you can use it to configure the desired behavior. We will see examples in other sections and lessons. In some cases, you will not want to use the wizard. For this reason, you should always check whether the Use Control Wizards button is not selected Use Control Wizard. You can click it to put it up to make sure the control's action is not launched.

Practical Learning: Adding Controls From the Ribbon

Author Note In the following exercises, there is a 100% guaranty that the fields on our form do not display as those on your form. Therefore, the screenshots are provided only as a guide: they are not showing how your form should or must appear. When we would like you to have the same type of design, we will let you know and we will show you. Based on this, follow only the instructions and do not make any attempt to match our screenshots.
  1. In the Controls section of the ribbon, click the Text Box Text Box and move the mouse to the form
     
    Form Design
  2. Click somewhere in the middle-center area of the form (do not make any attempt to be precise)
  3. In the Controls section of the ribbon, double-click the Toggle Button to indicate that you will add it many times
  4. Click somewhere in the top-right section of the form (again, no need for precision at this time)
  5. Click again in the lower right section of the form
  6. Again, click the middle-right section of the form
  7. On the Toolbox, click the Select button
  8. In the Controls section of the ribbon, click the Use Control Wizards to make sure it is not selected Use Control Wizard.
    Press and hold Shift
  9. Click the Button control three times
  10. Release Shift and click the button under the tab
     
    Form Design
  11. To save the form, press Ctrl + S

Using Rulers and Dimensions

To perform your design, a form or a report in Design View is equipped with two rulers, one horizontal in the top section and one vertical in the left section. Since the rulers are dimensionally configured, there are divisions inside of the rulers to assist you with some precision. Between two numbered dimensions, there are 7 marks that create 8 divisions. The mark in the middle, a little taller than the others, represents the middle of two dimensions. In our lessons, the middle division will be referred to as . The first division on the right side of a number represents 1/8 of a dimension, the 2nd represents 2/8 = of a dimension, the 3rd represents 3/8, and that is why the 4th represents 4/8 = . This is how we will refer to these dimensions.

The rulers can be very useful during control design. If you do not want to use them, you can remove or hide them. To do this, on the ribbon, click Arrange. In the Show/Hide section, click the Ruler button Ruler. Alternatively, you can right-click the middle of the form or report and click Ruler. Here is an example of a form in Design View without the rulers:

A Form in Design View Without the Rulers

Because you can ignore the rulers during design, you should leave them on.

Control Design and the Grid Lines

To assist you with setting the characteristics of a control, a form or a report in Design View is equipped with grid lines on its body:

If you do not want to use the grid lines, to remove or hide them, on the ribbon, click Arrange and, in the Show/Hide section, click the Grid button . Alternatively, you can right-click the form or the report and click Grid. Here is an example of a form in Design View without the grid lines:

As we will see in the next sections, you should display the grid lines because you can ignore them during design.

Data Fields Design Techniques

 

Introduction

In Lesson 3, we saw that you could automatically generate a form or a report using data from a table. In this lesson, we have seen how to add controls from the ribbon to a form or report. By default, the controls from the ribbon are not related to any data of a table. When working on a database, most of the controls you will use are meant to display data. When starting a form or report or while designing it, if it is meant to display data from a table, you must specify it.

Practical Learning: Using Existing Fields of a Table or Query

  1. Open the Bethesda Car Rental1 database
  2. On the ribbon, click Create
  3. In the Reports section, click Blank Report
  4. To switch the report to Design View, right-click it and click Design View

The Field List

While designing an unrelated form or report, if you decide that it must display data, you can specify the table that holds that data. To do this, while in Design View, you can display the Properties window for the form or report. Then, click the arrow of the Record Source combo box and select a table. Here is an example:

After specifying the Record Source of a form or report, the controls positioned on it, if any, are ready to show the values stored in the table. To make this happen, you can first add unrelated controls, as we saw earlier, to the form or report, then "link" those controls to the columns of the Records Source's table. Microsoft Access provides another technique.

Besides the Properties window that we introduced earlier, another window that can assist you when designing a form or a report is called the Field List. This window is useful only if the form or the report is meant to display data from a table, that is, if the form or report is not an unrelated object.

The Field List is a window that holds the names of columns from the table specified as the Record Source. To display the Field List, while the form or the report is in Design View, on the ribbon, click Design and, in the Tools section, if the Add Existing Fields button is highlighted Field List, this indicates that the Field List is already displaying. Otherwise, you can click it Field List. This would open the Field List. Like the Properties window, the Field List is dockable, meaning you can move it around the screen, and you can position it either to the left or to the right sides of the Microsoft Access interface.

The Properties window and the Field List share the same window object. Consequently, when one is displaying, the other closes, and vice versa. Based on this, to display the Properties window, you can either double-click the button at the intersection of the rulers or you can click the Property Sheet button Property Sheet in the Tools section of the Design category of the ribbon. If the Field List was displaying, it would be replaced by the Properties window. To display the Field List, as mentioned already, in the Tools section of the Design category of the ribbon, you can click the Add Existing Field button Field List. If the Properties window was displaying, it would be closed and replaced by the Field List.

If you open the Field List for an unrelated form or report, that is, a form or report whose Record Source is empty, the Field List would appear blank:

If the Record Source of the form or report is already specified, the Field List would show the list of the columns of the base table. Here is an example:

When the Record Source of a form or report has been specified, by default, the Field List displays only the columns of its base table. Still, the Field List is equipped to show the columns of the various tables of the current database. To show the columns of the other tables, on the Field List, you can click the Show All Tables button.

Practical Learning: Accessing the Fields List

  1. On the ribbon, click Design if necessary.
    If the Add Existing Fields button is not highlighted Field List, click it Field List.
    On the form, double-click the button at the intersection of both rulers to display the Properties window of the report
  2. In the Properties window, click the Data property page
  3. Click the arrow of the Record Source button and click Company Assets
  4. On the ribbon, click the Add Existing Fields button and notice that the Field List is now equipped with fields
  5. To save the report, right-click the Report1 tab and click Save
  6. Set the Name to Company Assets and press Enter

Adding Fields to Forms and Reports

When designing a form or a report, one of the most usual actions you will perform consists of inserting items from the Field List to the form or the report. To add a field, you can drag it from the Field List to the form or report. To drag many fields at the same time, first select them.

To select all items at the same time on the Field List, you can click the item on one end of the list, press and hold Shift, and click the item on the other end. In fact, you can use this same process to select fields in a range.

To select fields at random, press and hold Ctrl, then click each one of the desired fields. If you had selected an item but want to remove it from the selection. While still holding Ctrl, you can click the undesired item.

To add one item to the form or report, you can drag it from the Field List and drop it on the form or the report. Alternatively, you can double-click double-click it from the Field List and it would be positioned in the body of the form or report.

To add a group of items, first select them from the Field List, then drag the selection and drop it on the form or report.

Practical Learning: Inserting Fields

  1. The Company Assets report should still be opened in Design View with the Field List
    In the Field List, click Date Acquired and hold your mouse down
  2. Then drag it (Date Acquired) from the Field List and drop it in the middle left area of the report
     
  3. In the Field List, click Category
  4. Press and hold Shift, then click Model, and release Shift. This allows you to select a range of fields
  5. Click and hold the mouse on the selection. Then drag and drop it under the Date Acquired field on the report
     
  6. To select fields at random, in the Field List, click Purchase Price
  7. Press and hold Ctrl
  8. Click CompanyAssetID
  9. Release Ctrl
  10. Click and hold the mouse on one of the selected items, such as Purchase Price
  11. Drag and drop in the upper right area of the report
  12. To save the report, press Ctrl + S
  13. In the ribbon, click Create and, in the Forms section, click Blank Form
  14. Save the form as Company Assets and switch it to Design View
  15. Using the Properties window, set its Record Source to Company Assets
  16. Display the Field List.
    From the Field List, double-click the items in the following order: Date Acquired, Category, Make, Model, CompanyAssetID, and Purchase Price
  17. Save and close the form

Control Selection

 

Selecting One Control

After adding a control to a form or report in Design View, to manipulate it, you can first select the control. To select a control, you can just click it.

A control that is selected displays 8 handles around its body with the top-left handle thicker than the others:

When a control is selected on the form or report, the Properties window shows only its characteristics and you can change only the characteristics of the selected control:

Notice that the combo box in the Properties window displays the name of the selected control.

Selecting Various Controls

To select more than one control, at random, click one, then press and hold Shift. While holding Shift, click each of the desired controls. After selecting the controls, release Shift.

To select controls aligned vertically, click inside of the horizontal ruler above the highest positioned control: everything that would be touched by the fake line will be selected. In the same way, you can select controls that are horizontally aligned by clicking inside the vertical ruler.

To select many controls in the same area on the form, click next to one of them and draw a fake rectangle that covers each of the desired controls. All controls touched by the fake rectangle would be selected when you release the mouse.

To select all controls on the form or report, you can press Ctrl + A. You can also click inside of one of the rulers on one end and drag to the other end.

After selecting the controls, we will see in the next sections that you can change the common properties of the selected control. To remove a control from a group of selected controls, press and hold Shift, then click the undesired control of the group. You can include an object back in the group by pressing Shift and clicking the control. To dismiss a group of selected controls, you can simply click an unoccupied area of the form or report. In some cases, you may have removed a control from the group by mistake or you may have dismissed the group by mistake while you still need it.

If you have a group of controls that you will use over and over again, you can include them in a formal group so that, even if you click an unoccupied area of the form or report, the group would have been saved and you can get it back when needed.

To create and save a group of controls, first select the group. Then, on the Ribbon, click Arrange and, in the Page Layout section, click the Group Group button. A rectangle would be drawn to surround the extreme objects of the group:

Notice and remember that the selected controls do not have to be adjacent. If you click an unoccupied area of the form or report, the surrounding rectangle would disappear but the group would have been saved. If you click any control of the group, the rectangle would appear again to indicate that the selected control is part of a group. When you do not need the group anymore, to dismiss it, in the Page Layout section of the ribbon, you can click the Ungroup button .

When many controls are selected, the Properties window shows (only) the characteristics common to those controls:

This means that you can change the common characteristic(s) that many controls share and each would receive the change.

Practical Learning: Selecting Controls

  1. Re-open the Exercise2 database
  2. In the Navigation Pane, right-click the Central form and click Design View
  3. On the form, click the button in the middle section of the form. Notice that 8 handles surround it to indicate that is has been selected
  4. On the form, click the control that displays Unbound. Notice that although only the text box was selected, the corresponding label has its upper-left corner selected also
  5. Press Ctrl + A. Notice that all of the controls/items on the form have been selected:

    Form Design: Selecting all Controls
  6. To dismiss the selection, click an unoccupied area of the form
  7. Click the middle Unbound text box
  8. Press and hold Shift. Then click the middle right toggle button
  9. Click the bottom button in the left section of the form
  10. Release Shift
  11. Notice that these controls have been selected at random
  12. Position the mouse inside of the horizontal ruler above the top toggle button until the mouse cursor turns into a down pointing arrow:
     
    Form Design: the Mouse in the Horizontal Ruler
  13. Then click. Notice that all items under the mouse cursor when it was clicked have been selected
  14. Position the mouse inside of the horizontal ruler at 31/2 until the mouse cursor points down
  15. Click and hold your mouse at that position
  16. With your mouse still held, drag left until the mouse pointer is at 3/4
  17. Release the mouse. Notice that all controls that were touched by the waving line have been selected
  18. Position the mouse inside of the vertical ruler to the left of the middle toggle button until the mouse pointer turns into a right pointing arrow:
     
  19. Then click
  20. Notice that everything horizontally positioned on the right side of the mouse pointer has been selected
  21. Position your mouse inside of the vertical ruler at 21/2 until the mouse turns into a right pointing arrow. Click and drag up until the mouse pointer reaches 5/8
     
  22. Release the mouse.
    Notice that all controls on the right side of the covered area have been selected
  23. Click an empty area on the form to deselect
  24. Click and hold your mouse on an unoccupied area in the lower-right area of the form without touching any control
  25. While holding the mouse, drag up and left as if you were drawing a rectangle. While dragging, make sure your rectangle covers a few but not all controls. Then release the mouse
  26. Notice that the controls that were touched have been selected
  27. Click an unoccupied area on the form to dismiss the selection

Lesson Summary

 

MCAS: Using Microsoft Office Access 2007 Topics

 
C7 Modify the design of reports and forms
 

Exercises

 

Yugo National Bank

  1. Open the Yugo National Bank1 database
  2. Using the Table button in the Create section of the Ribbon, start a a table. After the ID column, using the Add New Field, create the following columns: TransactionType and Description.
  3. Rename the first column from ID to TransactionTypeID.
  4. Save the table as TransactionTypes and close it

World Statistics

  1. Open the World Statistics1 database
  2. Use the Table button in the Tables section of the Ribbon to create a new table with the following fields: ContinentID, ContinentName
  3. Save the table as Continents and switch it to Design View
 

Previous Copyright © 2008-2012 FunctionX Next