You are on page 1of 4

COMM 335 – Winter 2019 Term 1

Tutorial 3: Microsoft Access - Creating Queries and Building Simple Forms

The purpose of this tutorial is to enable you to:

1) create queries using Query Wizard and specify simple query criteria; and
2) build a simple form for viewing and entering data.

You should download the sample database, comm335_T3.accdb, from the UBC Canvas as the
foundation to create queries in this tutorial.

 Creating Simple Queries

Queries allow you to select specific records from a table (or from several tables) and show some or all
fields for the selected records. The displayed records may appear in a different sequence from the
underlying table. You may create a query either by using the Query Wizard or specifying the tables
and fields directly in the Query Design View.

Selected fields that


will be displayed in
Specify sorting
the query result,
sequence. i.e. dataset.

By default, the
records are Hide the field in
displayed in the query result.
primary key.
Specify the
selection criteria.

Demonstration:
 Create a query using Query Wizard to list all the movies in the database, sorted by title.
(qryMovie)
How do you create this query without using Query Wizard?_____________________________

 Create a query to list the title, length, and synopsis of all movies that are categorized as “A” or
“B”. (qryMovieCatAB)

COMM 335 Winter 2019 Term 1 Tutorial 3 Page 1


Copyright ©2019 Y.M.Cheung
 Create a query to list the title, length, and synopsis of all movies that have “DVD” format. Sort
the result by title. Do not display the format field. (qryVideoDVD)

 Create a query to list the title, length, and synopsis of all movies with the “Rating” input by the
users when the query is run. (qryMovieRating)

Write down the criteria:__________________________________________________________

Practice:
 Create a query to list the movie title, category code, and synopsis of all movies of which length
is greater than 120 minutes and rating is “PG”. Sort the result by title. (qryMoviePG)

Write down the criteria:__________________________________________________________

 Create a query to list the movie title, length, synopsis, and format of those videos that have at
least 3 copies. (qryVideo3Copies)

Write down the criteria:__________________________________________________________

 Create a query to list the video rentals that are two weeks overdue. The list should include the
customer name (last name and first name), customer’s phone number, movie title, video format,
the date the video is rented out and the due date. (qryRentalOverdue)

Write down the criteria:__________________________________________________________

Questions:

1. What is a parameter query?

COMM 335 Winter 2019 Term 1 Tutorial 3 Page 2


Copyright ©2019 Y.M.Cheung
 Creating Simple Forms Using the Form Wizard

Forms provide an easy-to-use interface for (1) entering and displaying data in a database. In addition,
forms can also be used to (2) create a main menu or switchboard for an application, and (3) create a
dialog box to accept user input.

Bound
1 Control

3 Calculated
Control
2

The Form Wizard asks you detailed questions about the record sources, fields, layout, and format
you want and creates a form based on your answers.

You can modify the form using Design View and Layout View:

 The Layout View allows you to modify the form design while viewing
the data.
 The Design View displays the form design but it does not display data.
You can use either Layout View or Design View to add or delete fields to
the form, modify field control properties, and change the field size to ensure
that the entire field displays without truncation. (The Layout View is not
available in MS Access 2003 or earlier versions.)

Demonstration:
 Create a Customer form to view, enter and update customer information.

Key Steps:
a. Create the form using the query, qryCustomer, which has already been created for you.
b. Select Create  Form Wizard. Select all fields from the query, qryCustomer.

c. Select the Columnar layout (i.e. Single Form View) and any style you like. Save the form as
frmCustomer. Open the form in Form View. Switch to Layout View and then Design View.
Do you notice any differences among Form View, Design View and Layout View?

d. Remove any meaningless field, e.g. AutoNumber field. (For the purpose of this exercise,
please keep the “Member No” in this form.)

COMM 335 Winter 2019 Term 1 Tutorial 3 Page 3


Copyright ©2019 Y.M.Cheung
Key Steps (cont’d):

e. Update the form header to display “Customer Form”.


f. Open the form property window and change the form caption to “Customer Form”. (Note:
form caption is displayed in the title bar of a form in Form View but not in Design View.)

g. Change the text labels on the form to make it meaningful to users if necessary. (If you have
added a caption to each field in the table definition, the caption will be used as the text label
when the form is created.)
h. Move the “Customer Type” field to follow the “First Name” field.

i. Select Design  Tab Order. Change the tab order if necessary. (You may notice that the
tab order of fields in a form corresponds to the sequence in which the fields were entered
into the form.)
j. Adjust the textbox size if necessary.

k. Create an input mask for the “Postal Code”


field.
(If you have added the input mask to the
field in the table definition, the input
mask will be used for that field when the
form is created.)

Do we want to have an input mask for other


fields?_______________________

l. Add a new customer record using the form.


m. Make necessary modifications if the form does not work as expected.
n. Select Design  Button.
o. Add a Delete Record button to the form for deleting records. (Other buttons will be covered
later.)
p. Delete the customer record that you have just created.
q. Add another customer record. Notice that a new AutoNumber is generated.

- End of document -

COMM 335 Winter 2019 Term 1 Tutorial 3 Page 4


Copyright ©2019 Y.M.Cheung

You might also like