Class #9 Lecture

Download Report

Transcript Class #9 Lecture

Creating your own form from scratch.

To create a custom form, you can modify an existing form or design and create a form from scratch. In either case, you create a custom form working in the Form window in Design view. A custom form can be designed to match a paper form, to display some fields side by side and others top to bottom, to highlight certain sections with color, or to add special buttons and list boxes.

A multi-page form displays the form on more than one page on a single screen. Each page is labeled with a tab like the tabs in the Database window. By clicking a tab, you can display the information on that page.

Whether the custom form you want to create is a simple or complex from, it is always best to plan the form’s content and appearance first.

The figure to the right shows a design for the custom form that we will be working with today.

Notice that the top of the design on page one indicates that a title and a graphic image are to be displayed.

Page 1 of the form

Below the title and graphic image we see that the CustomerNum and the CustomerName fields are indicated.

Page 1 of the form

Note also that the first page (shown above, labeled “Customer Information” displays the address information for the customer.

The second page, labeled “Orders,” displays order information for the customer. Each field value from the

Page 2 of the form

Customer table will appear in a text box and will be preceded by a label. The label will be the value of the field’s caption property (if any) or the field name.

The locations and lengths of each field value are indicated by a series of Xs in the form design.

Page 2 of the form

For example, the three Xs that follow the CustomerNum field label indicate that the field value will be three characters long. The Order table fields appear in a subform on the second page.

With the design for the custom form in place, you are ready to create it. You could use an Autoform Wizard to create a basic form and then customize it in Design view. However, you would need to make many modifications to a basic form to create the form shown in our paper design, so you will design the entire form directly in Design view.

You use the Form window in Design view to create and modify forms. To create our custom form you’ll create a blank form based on the Customer table and then add the Order table fields in a subform later.

The Form window in Design view contains the tools necessary to create a custom form. You create the form by placing objects on the blank form in the window. Each object - such as a text box, list box, rectangle, or command button - that you place on the form is called a control.

There are three kinks of controls that you can place on a form.

A bound control is linked, or bound, to a field in the underlying table or query. You use a bound control to display the table field values.

An unbound control is not linked to a field in the underlying table or query. You use an unbound control to display text, such as a form title or instructions, or to display graphics and pictures from other software programs. An unbound control that displays text is called a label.

A calculated control displays a value calculated from data from one or more fields by using an “expression” (formula) as we saw in queries.

Control source: =[InvoiceAmt] * .02

To create a bound control, you use the Field List button on the Form Design toolbar to display a list of fields available from the underlying table or query. Then you drag fields from the field list box to the Form window and place the bound controls where you want them to appear on the form

View Field List Tool on the Toolbar

Let’s take a look at the Form window design view for a moment and see some of the elements that we will be working with.

Rulers Field List Tool Box The Detail Section of the form

The Detail Section of the form appears as a light gray rectangle, in which you place the fields, labels, and values for your form. You can change the size of the Detail section by dragging its edges.

The Form Selector Button is located in the upper left corner of the design window, where the rulers intersect. You use this to select the form to view it’s properties.

Demonstration

Viewing the Form’s Properties

The grid consists of the dots that appear in the Detail section to help you position controls precisely on a form. If the dots on the grid appear to close together you can increase the size by changing the grid X and grid Y properties in the form’s properties window.

Demonstration

Changing the Grid of a Form Design Window.

Rulers The rulers at the top and at the left edge of the Detail section define the horizontal and vertical dimensions of the form and serve as a guide to the placement of controls on the form.

There are two ways to view a Form design Window First, create a new form from scratch.

Second, view the design view from an already existing form

Creating a new form from scratch Click on the Forms Button on the Left and then Click on the New Button on the top.

The New Form Dialog box will appear. From this window select the Design View, select the table or query that you wish the form to b bound to (if any) and then click OK.

The New Form will then appear in the design view ready for you to add objects to it.

Adding Fields to a Form There are two ways to add fields to a form

Adding Fields to a Form First by using the “View Field List” button.

Using the field List When you click the Field List Button a list of fields from the underlying table or query will appear.

Using the field List When the field list is visible, you can either click on it’s title bar to select all fields

Using the field List When this is done all fields in the list will be selected. You can click on any one of them and drag them to the form.

Using the field List Or you can click on one field at a time, holding the mouse down and dragging that field to the form.

Adding Fields to a Form The second way to add a field is by using the ToolBox

To place a field or other controls on a form, you use the tools on the toolbox. The toolbox is a specialized toolbar containing buttons that represent the tools you use to place controls on a form or a report. Screen Tips are available for each tool. If you want to show or hide the toolbox, click the Toolbox button on the form Design toolbar.

Summary of Tools Available in the toolbox for a form or report Button Tool Name Purpose Wizard Available?

Select Objects No Control Wizards Label Text Box Select, move, size and edit controls Activate Control Wizards for certain other toolbox tools Display text, such as title or instructions; an unbound control Display a label attached to a text box that contains a bound control or a bound or calculated control No No No

Summary of Tools Available Button Tool Name Option Group Toggle Button Option Button Check Box Purpose Display a group frame containing toggle buttons Display a toggle button control bound to a Yes/No field Display an option button control bound to a Yes/No field Display a check box control bound to a Yes/No field Wizard Available?

Yes Yes Yes Yes

Summary of Tools Available Button Tool Name Purpose Combo Box (Similar to the Lookup Field) List Box Command Button Display a control that combines the features of a list box and a text box.

Display a control that contains a scrollable list of values Display a control button you can use to link to a macro Display a graphic Image Image Wizard Available?

Yes Yes Yes Yes

Summary of Tools Available

Button Tool Name Purpose Wizard Available?

Yes Unbound Object Frame Bound Object Frame Page Break Tab Control Display a frame for enclosing an unbound OLE object, such as an Excel Worksheet Display a frame for enclosing a bound OLE object stored in an Access database table Begin a new screen on a form or a new page on a report Display a tab control with multiple pages Yes No No

Summary of Tools Available

Button Tool Name Purpose Wizard Available?

Yes Sub form or sub report Display data from multiple tables Line Display a line Rectangle More Controls Display a rectangle Display a list of all available controls No No No

Before you can modify a control on a form you first must select that control. To select a control simply click on it. When the control is selected, handles will appear around it’s edges.

You can move a field-value text box and its attached label box together. To move them, place the pointer anywhere on the border of the field-value text box, but not on the move handle or a sizing handle. When the pointer changes to a hand symbol, you can drag the field and its attached label to a new location.

You can also move either the field-value text box or its label box individually. If you want to move the field-value text box but not its label box, for example, place the pointer on the text box’s move handle. When the pointer changes to a hand symbol with a pointing finger, drag the field value text box to a new location.

You can also resize objects. Not just fields and labels, but any object on the form using a similar technique but this time using the resizing pointers

Adding Headers and Footers The Form Header and Form Footer sections allow you to add titles, instructions, command buttons, and other information to the top and or botton of your form.

To add a Page Header/footer or Form Header/Footer, Select View from the menu bar and then select the Page Header/Footer or Form Header/Footer Option.

Adding Labels When you add a text box to a field, a label will automatically be placed with it. If you delete the label and need to add one manually, or simply need to add a stand alone label, you can use the label tool on the toolbox to accomplish this.

Changing Label Captions To change the Caption of a label, right click the label, click Properties on the shortcut menu, click the Format tab, edit the existing label in the Caption text box or double-click it to select the current value, and then type a new caption.

Changing Label Captions right-click the label

Changing Label Captions Left-Click on Properties

Changing Label Captions click the Format tab

Changing Label Captions edit the existing label in the Caption text box

Demonstration

Using the ToolBox to add a Label Object to your form

Adding Images You can use the Image tool on the toolbox to insert a piece of clip art or photo to your form. This is used to place images created by other applications.

There are several other ways as well to accomplish this.

Demonstration

Adding Images to your form

Changing Background Colors of Objects You can change the back ground color of a form or of a specific section or object on the form by using tools available in Design View.

Demonstration

Changing Background Colors

Quick Check Review

Page AC 5.40

Quick Check Review

Let’s take a few moments to break up into discussion groups.

Each group will discuss the quick check questions on page AC 5.40 in your books. We will then review the answers at the end of the discussion.

Quick Check Review Session 5.2

1) What is the difference between a bound control and an unbound control?

Quick Check Review Session 5.2

2) How do you move a control and its label together?

Quick Check Review Session 5.2

3) How do you change a label name?

Quick Check Review Session 5.2

4) How do you resize a control?

Quick Check Review Session 5.2

5) What is the Form Header section?

Quick Check Review Session 5.2

6) How do you insert a picture, created using another software program, in a form?

Your task for this session is to complete the exercises in Tutorial #5 Page AC 5.25 through Page AC 5.39

The disk is Level 2 Disk 1