Professional Documents
Culture Documents
COMM 335 - Winter 2019 Term 1: Tutorial 5: Microsoft Access - Combo Boxes and Two-Levels of Subforms
COMM 335 - Winter 2019 Term 1: Tutorial 5: Microsoft Access - Combo Boxes and Two-Levels of Subforms
You should download the sample database, comm335_T5.accdb, from the UBC Canvas as the
foundation to build and test the combo box and forms in this tutorial.
A combo box is a list of values from which users can select a single value. First, we will learn how to
create a combo box to find a record on a form (i.e. for searching only.) Then we will learn how to
use a combo box to look up a value and store the selected value in a field (i.e. for updating.)
Demonstration:
Add a combo box in the Customer form (frmCustomer) to search a customer by last name
and first name and sort the entries alphabetically.
incl. Last Name and First Name (and
Member No.) even though only Last
Name is displayed.
Key Steps:
a. Open the Customer form (frmCustomer) in
Design view.
Questions:
2. Why is it Unbound? What is the Control Source of a Type III combo box?
Practice:
Add a combo box in the Movie Rental form (frmMovieRentalMain) to search a movie/video
by movie title and format. Sort the entries in the combo box in ascending order. (Hint: Make
sure that the key column is included.)
Questions:
To create a combo box that looks up values and updates a record, you need to decide two things:
Where will the rows for the list come from? (Row Source)
When a user selects an item in the combo box, what will Access do with that value?
(e.g. Store that value in a field.)
a fixed list of values that you enter when you create a combo box (use when the list won't change
very often), e.g. a combo box that contains entries for Mr., Mrs., or Ms. (Type II)
a table or query (use when you'll frequently update the list), e.g. a combo box that displays a
list of customers from the Customer table so that users can pick a customer and add him/her to
the New Rental Form. (Type I)
Type III
Type I
Type II
In this tutorial, we will look at how to use a combo box to look up a list of predefined value and
store the selected value in a field, i.e. Type II combo box. The Type I combo box will be covered
in the next tutorial.
For Type II combo boxes, the rows for a combo box (Row Source) come from a fixed list of values
that you enter when you create a combo box.
Key Steps:
a. Open the Customer form (frmCustomer)
in Design view.
l. Align the combo box with other textboxes. (Is there an easy way to align the form
controls?)
n. Test the combo box in Form View. Add a new record. Test the tab order. Does it work?
Practice:
Add a combo box in the Customer Form (frmCustomer) to enable users to select the value of
the Province field from a list of pre-defined values, e.g. “AB”, “BC”, “MB”, “NB”, etc., and
set the default value to “BC”.
You learnt how to create a main form with a subform to display data from related tables with a one-to-
many relationship. The following shows you how to create a main form with two levels of subforms.
The main (Movie) form has a one-to-many relationship with the first (Video) subform which displays
all the videos (in different formats) of one movie. The Video subform in turn has a one-to-many
relationship with the second (Rental) subform which displays all the rentals for the selected video.
When you click on a different video format (for the same movie) in the Video subform, the Rental
subform will refresh automatically to show all the rentals for all copies of the selected video.
Demonstration:
Video
Subform
Rental
Subform
Calculated
control
To save time, we may create these forms directly from tables. Please take note of the
differences between this method and the method you learnt last week.
Questions:
10. What are the Record Sources of the main form and the two subforms created above?
11. What are the differences between this method (i.e. creating forms directly from tables) and
the method you learnt earlier (i.e. creating forms from queries)?
Demonstration:
Add a command button to display the next movie/video record in the Movie Main Form
(frmMovieRentalMain).
Key Steps:
a. Open the Movie Main Form (frmMovieRentalMain) in Design view.
Practice:
Add the following command buttons in the Movie Main Form (frmMovieRentalMain):
1. to display the previous record, i.e. “Go To Previous Record”; and
2. to close the form.
Questions:
– end of document –