MS Access 2003 Forms Design
MS Access 2003 Forms Design
oit.wvu.edu/support/training/classmat/db/
ii
Course Description
This is the fifth in a series of six workshops about Microsoft Access. It deals specifically
with form design.
The purpose of this installment is to expose you to the possibilities involved in designing
your database forms. Form design is time consuming and requires some patience.
Learning the form design process is a considerable portion of the database
development process.
Our goal is to assist you to learn the software, understand some basic concepts and
show you some tips and techniques so you can develop your database
management/programming skills over time.
The six workshops are:
• Introduction to Access
• Access Queries
• Access Reports
• Access Database Design
• Access Form Design
• Access Macros
Thank you,
The OIT Technical Support Services Trainers
West Virginia University
Uses of Forms
Forms created in Microsoft Access are very much like paper forms except they have a
wider variety of functions and uses. They can be used to:
• Calculate totals
The form can extract raw numbers from a table record, calculate totals or
evaluate mathematical expressions, and display the results as a part of the form.
Creation Methods
Access contains several ways to create a form. You can design the form yourself by
placing controls on a blank grid or you can use one of the built-in Wizards. The most
common approach is to use a wizard to develop the basic design of the form (a rough
draft) and then switch to the design view for form customization.
• Build From Scratch
You, as the user, can enter controls, labels, and links to the data in the
underlying tables in the design view of a form.
• Autoform Wizards
Each of the autoform wizards produces a simple preformatted form in either
columnar, tabular, or datasheet format. Each wizard works automatically, without
prompting from the user.
• Other Wizards
Other form wizards are available that will produce columnar, tabular, datasheet,
justified, chart, or pivot table forms. Each wizard prompts the user with a series of
questions and bases the form on the answers.
Types of Forms
Microsoft Access forms are generally classified into one of these types:
• Columnar
In a columnar form, the values are all placed in one
vertical column; one item to a line and one record per
form. Access will place the data in newspaper style
columns if the number of data items exceeds the form
length.
• Tabular
In a tabular form, the data is placed in rows with field
labels at the top. Multiple records can be displayed on a
single form. Tabular forms are best when you want to
display multiple records with relatively few fields to
prevent the need for left to right scrolling.
• Datasheet
A datasheet form will display multiple records in a
typical datasheet view or single records in a tabular
view. This form is used mainly as a subform.
• Justified
Available through the Form Wizard; lays out fields in a
staggered compact manner.
• Hierarchical
Hierarchical forms are used to display relationships between tables. There are
two types of hierarchical forms, the subform which is embedded in another form,
and the linked form which is attached to another form.
− Linked Forms
The main form in a linked form set contains a button that branches to or
opens another form related to the first. The second form is displayed in its
own window, generally on top of the first form. Closing the second form
returns control to the main form.
• Charts
The chart form displays data as a graph
such as a bar chart, pie chart, or a
column graph. The chart cannot be used
for data entry.
• Pivot Tables
A pivot table lets you summarize large
amounts of data in spreadsheet form.
The pivot table requires that Microsoft
Excel be installed on the computer before
the table can be created. Management
and editing of the table is done with an
OLE branch to Excel.
1. In the Database Window, click the Forms entry in the Objects list
2. Click on the New button in the toolbar to display the New Form dialog box.
3. Select the appropriate table or query in the Choose Table or Query field
(click the T pop-up to display the list of available tables and queries).
4. Select a Wizard or Design View from the list and click the OK button.
If you choose a wizard, follow the instructions in the Wizard dialog boxes. Click
the Next button after each step to continue through a Wizard.
Create a form to add or update information in the class table using the Tabular
AutoForm Wizard.
Creating forms in the Design View is a little more complicated and requires a more in-
depth discussion of the design screens, options, and tools that are available within
Access. These items will be covered in the next section.
Notes:
• Creating Charts and/or Pivot Tables within forms and reports poses special
requirements and data organization. The wizards will provide a step by step
procedure for creating these objects but they assume that the necessary items
are available prior to use. For example, the Pivot Table wizard requires that
Microsoft Excel be installed on the computer.
• Access help files contain some excellent tips and pointers for using Charts and/or
Pivot Tables. They also specify the system requirements.
Control Toolbox
The Toolbox is a special type of toolbar that is used to create controls. The toolbox is
automatically displayed when you enter the form design view. You can move the toolbox
around the work area by dragging it or you can click on the control box to close it.
When a tool is in use, it is outlined with a small square indicating it is active.
Option Group: if you are going to use this, create it before you create the buttons to go inside it.
Select the tool and draw the box on your form. Then create option buttons, check boxes, or toggle
buttons.
When a command button is clicked on a form, the button will run a program or macro or perform
some operation such as go to first record or close form.
Toggle Buttons, Option Buttons, and Check Boxes work best for yes/no, true/false type variables.
When the item is selected, the value is True or 1. When it is left blank, the value is False or 0.
These buttons can be used as part of an option group to create mutually exclusive choices. In a
group, the first button created will have the value of 1, second button's value will be 2, etc.
There are two ways to create a bound control. Either of these methods result in a pair of
controls: a bound control used to display data from the table and an unbound control
used to label the bound control.
The easiest method is to drag the field from the field list to the form, creating a text
box control by default. The control will be assigned a label that is the same as the field
name or caption. It also inherits most of the properties from the connected field.
1. Open the form in Design view.
2. Select the Field List command from the View menu.
This displays the field list in a separate window.
3. From the field list, drag the field(s) to the desired position on the form.
Alternatively, you can create the control using the toolbox and then assign the field
name in the control’s property sheet.
1. Open the form in design view. For a new form, specify the table or query that is
to be connected to the form.
2. Select the control from the toolbox and position it on the form.
3. Click on the control with the right mouse button and choose Properties, or
double-click on the control and select Properties, or click on the control to select
it and then click on the Properties button.
4. Select the Control Source property and select the field from the pull down
menu.
• Moving a control
Click on the control when the cursor looks like a flat hand and drag it to a new
location.
• Validation of data
To avoid mistakes when entering data into forms, you can alter the DefaultValue,
ValidationRule, ValidationText, and InputMask properties.
A bound control will inherit the lookup, format, input mask, caption, default value,
validation rule, validation text, and decimal places properties from the underlying table
fields. However, the validation rule, validation text, and default value settings will not
appear in the property sheet for the form. Any entries made in the property sheet will
override or append to these properties.
14 Access Form Design
Customizing the Form
Access offers a wide variety of controls that can be used to make your form easier to
use and more visually appealing. Some of the more common or useful controls are:
• Using a list box or combo box:
A list box allows you to make choices from a simple list of values. A combo box is
like a list box and a text box in one control; you can choose from the items in the
list or type in your own item like a text box. In either case, the list can be field
values from a table or query or it can be values entered into a value list.
1. From the View menu, turn off the Control Wizard if you plan to create a list box.
2. In the toolbox, select either the List Box or the Combo Box.
3. Click and drag (draw a box) on the form where you want to place the control.
4. Set the Control Source property of the box to bind it to the desired field.
5. Set the RowSourceType property to indicate what type of data should be
displayed in the control.
6. Set the RowSource property to indicate the source of the data. When creating a
list of values, place them in the RowSource property separated by semicolons.
Activity 7 - Add a Combo Box and a List Box to your Student Form
Option Groups
You can use a group of option controls to present a limited set of alternatives. An option
group consists of a group frame that contains a set of check boxes, option buttons, or
toggle buttons. Only one option in a group can be selected at a time (mutually exclusive
choices). One value in the group can be set as the default. Option controls used in a
group have different properties from those used stand alone. In a group, each option
has its Option Value property set to a number that indicates its value in the bound field.
The group frame, which must be created first, is bound to the table field. Option Value
properties, which can only be set to numbers, not text, are the values that are placed in
the bound field when that option is selected.
Command Buttons
A command button is placed on a form to initiate an action. To make a command button
do something, you need to write a macro or code module. The command button wizard
will create some common buttons for you and will create the underlying Access Visual
Basic event code.
1. From the toolbox, select Control Wizards.
2. In the toolbox, click on the command button.
3. Click on the form where you want the button placed. Access will display the
wizard dialog box.
4. Follow the directions in the dialog box to create the event code.
1. Switch to the Queries tab and create a new query in design view.
2. Include these three tables: Class, Attend, Student
3. Include these fields: S-ID from the Student table, C-Name, Grade and Status
4. Save the query as StudentAttend
5. Return to your Student form in design mode. Drag the bottom of the form down to
get some more room.
6. Make sure the Wizard button is selected.
7. Click on the Form/Subform button and drag a box on top of your form.
8. Wizard responses: Use existing query "StudentAttend". Select all fields. Show
StudentAttend for each record in Student.
3. In the Switchboard Manager dialog box, click the Edit button to edit the default
Main switchboard.
4. In the Edit Switchboard Page dialog box, click on New to add a new item to the
list of possible actions.
5. In the Edit Switchboard Item dialog box, type the text for the first switchboard
button in the Text box, and then choose a command in the Command box.