Although it is possible to work with tables just by using the datasheet view, a form permits the creation of a friendlier environment with extra features that the datasheet alone cannot provide.
Forms can be simple, merely providing a convenient way to enter information into tables. On the other hand, they can be used to create a complete system for editing, reporting and interrogating tables. A well-designed system could be passed on to a colleague who will be able to use it with only the simplest of instructions.
Forms can be used to bring together all the different Access objects - tables, reports, queries and macros - to create a single application.
To create a form that will let the operator enter each tutor record:
| In the Database Window (see Figure 2),
click on the Form tab and press the left mouse
button.
|
| Click on the New button. |
Forms are usually based on tables or queries. By using the Forms Wizards you can create a basic form quickly and easily.
| Click on the button to pull down a
list of tables, and select the Tutors table as
the base for the form.
|
| Click on the Form Wizards button.
|
| Select Single-Column. (The bottom of the Form
Wizards window shows a brief description of each wizard as you
click on it.)
|
| Click on the OK button. The Single-Column
Form Wizard will appear (Figure 6).
Figure 6 - Single-Column Form Wizard, Step 1
|
| Click on the button to move all the
fields from the Tutors table (the left-hand box) over
to the right-hand box. The right-hand box shows which fields will
appear on the form.
|
| Click on the Next > button.
|
| Choose an appearance for your form. The magnifying glass to
the left of the screen changes to show the effect of the different
possibilities as you select them.
|
| Click on the Next > button.
|
| Give the form a suitable title, such as Tutor Details. The title you enter here will appear as a heading at the top of the form. |
You can now select either Open the form with data in it, which lets you use the form straight away to view and edit data, or Modify the form's design, which allows you to change the form's details, such as colour or style, and add buttons for various functions.
| Click on Modify the form's design.
|
| Click on the Finish button. |
The form's appearance can now be changed in the Form Design View, which is described in the next section.
There is now a Tutor Details form, but it looks a bit plain and cannot do anything except allow the user to enter and edit tutor records (see Figure 7). Fortunately, there are a number of ways in which it could be improved.
Figure 7 - Design View of the Tutor Details Form
In Form Design View, each form is divided into three sections: Form Header, Detail and Form Footer. The form's fields appear in the detail section. Note that each field from the table has a label attached to it containing its field name.
The size of the Form Header, Detail and Form Footer can be changed by dragging the dividing bars up or down. (This is described in more detail in section 6.1, Creating a Report.)
There are a number of objects such as buttons, lines and graphics that can be added to the form using the toolbox, which is shown in Figure 8 (left).
To add a feature from the toolbox:
| Click on the toolbox item to be added in order to choose it.
|
| Move the pointer to where on the form you want the control
to appear.
|
| Click and hold down the mouse button, drag out the size of the object on the form, then release the button. |
This process is also described more fully in section 6.1, Creating a Report.
Once an object is part of the form, its properties can be changed.
Microsoft Access calls all the objects on a form controls. To view or edit the properties for a control:
| Click on the control with the left mouse button
(if it is not already selected).
|
| Click on the Properties toolbar button . |
OR:
| Click on the control with the right mouse button.
|
| Select Properties from the pop-up menu. |
OR: (quicker)
| Double-click on the control. |
In any case, the properties sheet for the control will appear. A sample properties sheet is shown in Figure 9.
Figure 9 - Properties Sheet for the Tutor Name Label
There are many different properties for each control, and different types of controls have different sets of properties.
Many properties have pull-down lists of options. To look at these,
click on the
pull-down button which appears
on the right-hand side of a property setting when you click in
its box.
There are properties that tell the control where its data is coming from, what it will look like, and what should happen when an event such as a double-click on the control occurs.
Note that specific groups of properties can be selected at the top of the properties sheet window. In Figure 9, All Properties are shown.
Each field will initially have a label attached to it which is the name of the field. You can, if you wish, change this to a more meaningful description of the field and the data to be entered.
You can move the field and its label around together or individually by dragging them with the mouse. Once you have selected a field and its label:
.
This means that a single object will be moved
,
which means that both field and label will be moved together.
To change the colour of a control:
| Click on the Palette toolbar button
Figure 10 - The Colour Palette This will bring up the colour palette (Figure 10, left).
|
| Click on the control or section of form to be changed
|
| Select the new colour. |
The fill and border colour, and the appearance of the control - raised, sunken or normal - can be changed too.
Colour can also be changed by using a control's property sheet.
Once a control is selected, you can alter its font, size and style using the formatting buttons in the toolbar.
The font, font size, style, alignment and colour for several controls can be changed at the same time by selecting them together. To select multiple controls, hold down the [Shift] key and click on each control in turn.
There is no need to display the Tutor No field on the screen as anyone using the form will not need to change it. The field can be made invisible as follows:
| Open the property sheet for the Tutor No field.
|
| Look for the property called Visible...
|
| Set it to No (either use the
button, or just type in N). |
The field will now not be visible when the form is opened. However, it remains visible in the design view.
To change the Room No label to the full Room Number:
| Click on the Room No label to select it.
|
| Position the cursor over the label: the cursor should change
to an "I-beam" (see right).
|
| Click once. |
You should now be able to edit the label text using the usual editing keys.
When you have finished making changes:
| Click once outside the label, or press the [Enter] key. |
Alternatively, you can use the Properties Sheet (see Figure 9) and change the Caption entry.
To save the changes:
| Pull down the File menu.
|
| Select the Save option.
|
| Type in a name for the form such as Tutor Details
and click OK.
|
| Pull down the File menu again and select Close. |
You should now be back at the Database window.
To use the form:
| Choose the Form tab from the Database Window
(Figure 2).
|
| Pick the form you need (the one you just created) and click on the Open button. |
The form will open displaying the first record (see Figure 11). You can now view the existing records, or enter new information into the field boxes.
Figure 11 - Completed Tutor Details Form
Press [Enter] to move from field to field.
In the last field, pressing [Enter] will bring up the next record; when the last record is displayed, this will be a new, empty record.
The arrow buttons at the bottom of the form can also be used to browse through the records:
Go to the first record.
Go back one record.
Go forward one record.
Go to the last record.
To insert a new record, click on the New toolbar button