Access Forms are primarily used as a means of viewing or editing data in tables - they offer an alternative to viewing or editing using a Table Window as discussed above. The information appearing on a form may be from either a table or a query. A form can also contain sub-forms which typically display related information from other tables. Creating a Form for a Single Table To create a form click on the Forms Button and click the New button. The New Form dialogue box displays. Select the table (or view) upon which the form is to be based and click the Form Wizards button. Form Wizards gives you a choice of four styles of form and AutoForm. In this example Single-Column was chosen. Having chosen a style, click the OK button.
Selecting Open the Form with data in it and clicking the Finish button displays data through the form. Alternatively selecting Modify the Form's design allows the design of the form to be altered.
Return to Table of Contents
Return to previous section

Select the fields that will appear on the form - the > button moves the currently highlighted field to the list that will appear on the form. The >> moves all of the fields. The < and << buttons work in the opposite sense. Click the Next> button when you have selected all of the fields you want.

The look affects the appearance of fields on the form. The example uses Standard look. To get some idea of what the style will produce, click the various options and look at the picture underneath the magnifying glass (top left). When a look has been chosen, click Next>.



Anatomy of a Form
The form illustrated above consists of three sections: a Header, Detail and Footer. Data appears in the Detail section, the Header contains descriptive text and the Footer is empty. In fact you can put anything anywhere (for example, data can appear in the Header) but as a general rule restricting the display of data to the Detail section is recommended. The Header and Footer might contain descriptive information, buttons (explained later) or summary information if the Detail section displayed a table of records rather than a single record as in the example above.
Form Attributes
A Form has a number of properties which affect how it looks and behaves: these can be altered to suit a specific purpose. For example the Default Editing property determines whether, by default, the form can be used to edit information and/or add records or whether it displays information read only, and the Allow Editing property determines whether a form with a Default Editing property of read only can be used to edit at the discretion of the user. Other properties affect what happens when you use the form in a particular way.
Controls
Each section contains a number of controls. Only two sorts appear on the form generated above (Labels are used for annotation, and Text Boxes display information from the table upon which the form is based). Other sorts of control are available. Each control has a (large number) of properties, which will not be listed here, which affect how it looks, its position, and in the case of some types of control, how it behaves in response to events.
When adding a control the designer of a report specifies its type using the Toolbox which displays in design view.
The following items are shown in the diagram of the Toolbox:
· A Label is used for annotation.
· A Text box is used to display data from the table or query the form is based on.
· An Option group is made up of two or more Option buttons, Toggle buttons or Check boxes. By clicking one of the options in the Option group, the value of a field can be set to an integer.
· An Option button, Toggle button or Check box sets the value of a field to -1 (Yes/True) or 0 (No/False). They are used with fields with data type yes/no.
· A Combo box or List box is used when the value of a field is one of a number of choices stored in a table or accessible through a query.
· A Graph is just that.
· A Sub-form enables a master/detail form to be built (see below).
· An Object Frame enables the display of an OLE object such as a picture.
· Lines and Rectangles are just simple graphics which can enhance the appearance of the form.
· A Page break enables vertical navigation with the Page Up and Page Down keys - useful where there are many fields on a form.
· A Command button is associated with a code segment, function (see Module below) or macro which executes when it is clicked.
The rest of the tools determine the behaviour of the Form editing process. Pointer enables controls to be selected rather than added. Tool Lock determines whether a tool remains active after a control of that type has been created (otherwise Access activates the Pointer). Control Wizards activates or deactivates Control Wizards which can be used for the specification of Combo boxes, List boxes, Option groups and Command buttons.
Altering the Design of a Form
Once created a form can be altered. Controls can be added, deleted, resized and their properties can be altered.
In the form created above, for example, it would be better to replace the Text box associated with the Account type with a Combo box which showed all the allowable types (stored in the table Account Types) and allowed the user to pick off the list. To do so the designer would:
· Open the form in Design View
· Click on the type field and delete it (press the Del key)
· Display the list of fields - the View menu should have Field List... ticked
· Click on the Combo box button in the Toolbox
· Click on the type field in the Field List and holding the mouse button down drag and drop it into position on the form
If a Property Sheet (list of properties) is not displaying, click the Properties button on the toolbar or click Properties... on the View menu and if necessary select the type Combo Box. Alter the Row Source property to Account Types (a table name).
As an alternative, the designer might activate the Control Wizards, in which case, rather than setting properties by hand they would be set as a result of a dialogue.


Aesthetics (Tips)
To move a control, select it, click on the large rectangle in its top left hand corner and, holding down the mouse button, drag it to a new position.
To resize a control click on any of the smaller rectangles on its borders and, holding down the mouse button, drag the boundary of the control
To select a set of controls either:
· Select the first and then select subsequent controls with the shift key depressed.
· Click and hold down the mouse close to one control and drag the mouse over the form - all of the controls within, or partly within, the rectangle that appears will be selected when you release the mouse button.
Once selected, the common properties of a set of controls can then be displayed and set through the property sheet and the controls themselves can be aligned, sized or positioned relative to each other using the Format menu.
To move a group of controls select them, click in one of the selected controls and hold down the mouse button (a rectangle appears) which can be dragged into a new position.
A section of a form (or report) can be resized in much the same way as a control. Position the cursor close to a bounding horizontal or vertical line and (if a two headed arrow appears) drag the line to its new position.
Use colour.
Filters
By default, when a form is opened all of the information in the Record Source - underlying Table or Query - can be viewed through it. It is possible to restrict which records display by applying a filter - a query is associated with the form and only those records satisfying the query are displayed on the form. The three Filter buttons above enable (from left to right) the filter to be altered, turned on and turned off.
Sorting
The information displayed through a form can be sorted in ascending or descending order based on a single field by clicking one of two Sort Buttons. A more complicated sort order can be specified in the query filter.
Creating a Form for Related (Master Detail) Tables
A form can contain another form, so related information from more than one table can be displayed through a single (master) form. For example when displaying Account details the designer might want to display details of the Account Owners and of the Transactions associated with it, as shown below.

Figure 35 A Master-Detail Form
To display the Account Ownership List the designer might create a query - (Account Owner Summary) which contains the Address of a Person as well as Account Owner details (see the diagram shown below) ...

Figure 36 Account Owner Summary Query
...then create a form to display information from the query in tabular form The form has a Combo Box associated with the Person field (with properties set as shown in the diagram below) and a Text Box associated with the Address field. The form is called Account Ownership (Embed).
To embed this form as a sub-form in the master form illustrated in the diagram on page
*:· Open the master form in design view.
·
Display Form Objects in the Database Window and drag and drop the relevant icon
into the body of the master form.

Figure 38 Embedding a Sub-form
Two properties of the sub-form need to be set to ensure that the information that displays in the sub-form is related to information in the master form - Link Child Fields and Link Master Fields. In this case the value of Account Id field in the Account table (upon which the master form is based) and the Account field in the Account Owner Summary query (upon which the sub-form is based) determine which records display in the sub-form.
A sub-form for transactions can be embedded in much the same way.
Expressions and Totals
In the above example Text Boxes contain information that comes directly from a table or query - the Control Source property of these controls is a field name. The Control Source can however be:
· An expression (calculation)
· A summary statistic calculated over the set of records currently displaying (for example average, count, sum)