Home

Introduction to Controls Design

 

The Properties Window

 

Form and Report Design Fundamentals

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
  2. To create a new database, make sure the File tab is selected and the Blank Database icon is highlighted.
    Change the name to Exercise2
  3. Click Create
  4. Close the default table but do not save it
  5. To create a new form, on the Ribbon, click Create
  6. In the Forms section, click Blank Form
  7. To save the form, press Ctrl + S
  8. Set the name to Central and click OK
     
    Central Form
  9. To display the form in Design View, right-click the middle of the form and click Design View 

Introduction to 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 Intersection of Rulers
  • In the Tools section of the Design tab 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 Tools section of the Design tab 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:

The Sections of 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

Selecting an Item in the Properties Window

The Properties window is made of five property pages or tabs: Format, Data, Event, Other, and All. The tabs display the characteristics associated with the object or the control that is selected on the screen or in its top combo box. To access a tab, you can simply click it.

Each tab is made of two sections devided by a vertical line. To make one section wider than the other, position the mouse on the dividing line and drag left or right:

Resizing the Sections of a Tab in the Properties Window

 

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

The Name of a Property

In order to change a property, first open the table, the form, or the report in Design View, click the object whose property you want to change. In the Properties window, locate the property you want to change and click it. Each field in the Properties window is divided in two sections: its name and its value:

Names and Values of Properties

The left column of a tab in the Properties window displays the names of properties. Although you can click a property name to select it, you cannot change it. The property name can be made of one word such as Width. It can also be made of a combination of words, such as Border Style. Regardless, in our lessons, each property will be called by what displays on that left column. This means that, if a property displays "Width", we will call it "The Width Property". If it displays "Allow PivotTable View", we will call it "The Allow PivotTable View Property".

The right column of a tab of the Properties window displays the value of the property.

Types of Properties

There are values types of properties:

String-Based Properties: Some values of properties can be made of one or more characters or words. Here is an example:

String-Based Property

To change the value of a string property:

  • You can click it to select it and then type over it
  • You can double-click it to put the caret in the value, and then edit it

Numeric Properties: A property is numeric if it must hold an integral or decimal value. An integer is a natural number that does not take a decimal portion. Such a number can be made of digits only. For such a field, make sure you provide an integer of appropriate range, as you will be directed to do. Here is an example:

Numeric Property: Natural Number

A decimal number, also called a floating-point number, can be made of digits or a combination of digits and one period (or the symbol used as the decimal separator in your language; you can find this out in the Regional Settings of the Control Panel) in between. Here are examples:

Numeric Property: Decimal Numbers

When setting such a value, make sure that either you type only digits, or you type digits and one decimal separator. The decimal separator can be anywhere in the value, Microsoft Access would take care of formatting it if it judges it necessary.

To change the value of a numeric property:

  • You can click the property name to highlight the property value and type the desired value
  • You can double-click the value to put it into edit mode and change the value

Some numeric properties, such as the color properties, allow you to either type a number (provided you know what number you want to use) or to use an intermediary approach (namely a dialog box) to select an appropriate value.

Expressions Properties: Some properties are made of a combination of specific characters and digits. Examples are the format of a date or time, the concatenation of strings to produce another string. To specify the expression, you can use the same approach we described for a string. After entering the expression, Microsoft Access would analyze it. If you respect the rules of the type of expression you are supposed to create, it would be used. If you enter a wrong expression or Microsoft Access cannot identify what the expression would produce, you may get either an error or an unpredictable result.

Boolean Properties: A property is referred to as Boolean if it can have only either a Yes or a No value, an On or an Off value, a 0 or no 0 value. Both values of the property are stored in a combo box. Here are examples:

Boolean Property

To change the value of Boolean property:

  • You can click the property name to display its combo box, then click the arrow of the combo box and select the desired value
     

    Boolean Property

  • You can double-click the property name or its value. This would change to the opposite value
  • You can click the property name, type the first letter of the value, such as y or n and Microsoft Access would complete with the corresponding value

Enumerated Properties: Some properties provide a list of options as the possible values of the property. The list, which cannot be changed, comes as a combo box from where you can select one item. To change the value of an enumerated property:

  • You can click the property name to reveal its combo box, click the arrow of the combo box and select the desired value from the list

Enumerated Property

  • You can double-click either the property name or the property value. This would display the next value in the list. You can keep double-clicking until the desired value comes up
  • If you know the values in the list (from experience), you can type the first letter of the desired value and Microsoft Access would complete it with the corresponding value. If you try typing a value that is not in the list, you would receive an error
  • You can click the property name or its value, press Alt + down arrow key to display the list, press the down arrow key to select the desired value, and press Enter or Tab

Action-Based Properties: Some properties need a value that may be gotten from an external object or another application. In the Properties window, such properties show an ellipsis button:

Action-Based Property

When you click the ellipsis button, a dialog box or a window may come up. You will be directed as to what to do. If the database already has one or more values that can be used, you can click the arrow of the combo box and select from the list.

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. By default, the primary controls appear in one row:

Controls

If you resize the Ribbon to a size that cannot show all controls, the Controls section would be made into two or more rows and the right section would be equipped with three buttons. To show the hidden object, you can click the down-pointing arrow:

Controls

 

Controls

 

Controls

 To show all controls at once, you can click lowest of the three buttons:

Controls

In our lessons, we will mostly use controls listed in the Controls section of the Ribbon. 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 an option group:

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 Button. 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 Use Control Wizard. To access it, click the bottom arrow button on the right side of the Controls section:

Insert Control Wizard

If the control is set to perform an action, to use that action, the Use Control Wizards button must be selected or highlighted Control Wizard. 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 objects 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, right-click the Toggle Button Toggle Control and click Drop Multiple controls (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 Ribbon, click the Select button Select
  8. In the Controls section of the Ribbon, right-click the Button Button and click Drop Multiple controls
  9. Click the form three times
  10. On the Ribbon, right-click the Button Button and click Drop Multiple controls
  11. To save the form, press Ctrl + S

Using Rulers and Dimensions

To assist you with 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 half. 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 Sizing & Ordering section, click the Size/Space button and click Ruler:

A Form in Design View Without the Rulers

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

Grid Lines

If you do not want to use the grid lines, to remove or hide them:

  • On the Ribbon, click Arrange. In the Sizing & Ordering section, click the Size/Space button and click Grid
  • Right-click the form or the report and click Grid

Here is an example of a form in Design View without the grid lines:

No 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 a form or report unrelated to a table, 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:

Record Source

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 location. 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 Intersection of 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:

Field List

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:

Field List

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 Intersection of 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 title bar 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 technique 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 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
     
    Adding a Field
  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
     
    Adding Fields
  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. To save the form, right-click its title bar and click Save
  15. Set the Name to Company Assets1 and press Enter
  16. To switch it to Design View, right-click its title bar and click Design View
  17. Using the Properties window, set its Record Source to Company Assets
  18. 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
  19. Save and close the form

Lesson Summary

  

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 © 2010-2012 FunctionX Next