Professional Documents
Culture Documents
Comm 335 - Winter 2019 Term 1: Tutorial 10: Microsoft Access - Main Menu, Totals Query and Dcount Function
Comm 335 - Winter 2019 Term 1: Tutorial 10: Microsoft Access - Main Menu, Totals Query and Dcount Function
Tutorial 10: Microsoft Access - Main Menu, Totals Query and DCount Function
You should download the sample database, comm335_T10.accdb, from the UBC Canvas as the
foundation to build and test the forms and queries in this tutorial.
A main menu (switchboard) is a form which contains buttons to open various objects such as forms
and queries in a database. It allows users to open the forms and queries directly from the main menu
(switchboard) rather than searching and opening them in the database window.
The switchboard can be created using the Switchboard Manager. You supply the text of the item, as
it is to appear on the switchboard (e.g. Customer Form), together with the underlying command (e.g.
Open Form in Edit Mode) and the form name (e.g. frmCustomer). Access does the rest. It creates the
switchboard form and an associated Switchboard Items table.
When the switchboard form is opened in Form view, the text appears next to each button. However,
when the switchboard form is opened in Design view, the text for each button is not displayed. This is
the nature of a switchboard because the text for each button is taken from the Switchboard Items table.
When users open (i.e. run) the database, the Navigation Pane should be hidden and the main menu
(switchboard) form should appear automatically. For example, the following is the switchboard you
may create for the video rental system.
Look for Switchboard Manager in Access 2016 Ribbon if you do not have Classic Menu
You will find out that the Switchboard Manager feature disappeared from the Ribbon. In fact the
Switchboard Manager is not listed on the Ribbon. So you may need to customize the Ribbon, and
add Switchboard Manager under the Database Tools in the Ribbon.
h. Select the new group Switchboard (Custom) that you just created.
i. Click Add button to add the Switchboard Manager to this group. (You have to make sure
that the Switchboard Manager is still selected in the command list box.)
Key Steps (Part 1 - Create a switchboard form to open a form and exit from Access):
c. On the Switchboard Manager dialog box, click Edit button to edit the Main
Switchboard.
d. On the Edit Switchboard Page dialog box, change the Switchboard Name as “Video
Rental System”.
e. Click New button to add an item to the switchboard.
f. Add the first switchboard item as follows:
enter “Customer Form” in the Text box.
choose “Open Form in Edit mode” from the Command drop-down box.
choose “frmCustomer” from the Form drop-down box. Click OK.
i. Open the Switchboard form and test the buttons. Does it work?
j. Open the Switchboard form in Design View. Change the font size and color if necessary.
Practice:
Add a new switchboard item to open the New Rental Form.
(Hint: Repeat Steps (a), (c), (e) and (f) for each switchboard item.)
Key Steps (Part 2 – Update the Startup menu to open the Switchboard form):
k. Select File Options to open the Access Options window.
l. Click Current Database at the left pane.
m. In the Application Options section, type the database name, e.g. Video Rental System, in
the “Application Title” text box.
n. Click the “Display Form” drop-down box and select “Switchboard”.
o. In the Navigation section, clear the “Display Navigation Pane” check box.
p. Click OK to close the dialog box. (The next time the database is opened, the switchboard
will be displayed automatically.)
q. Close the database and open it again to check whether the Main Menu (Switchboard) form
is opened automatically. Does it work? (Press F11 to open the Navigation Pane.)
Key Steps:
a. Create a query (qryTotalRental) from tblCustomer and tblRental including MemberNo,
LName and FName fields. (You may either use Query Wizard or Query Design.)
b. Open the query in Design View.
c. Add a calculated field named “Charge” by entering the following expression in a new
column:
Charge:([DateIn]-[DateOut])*[Rate]*(1-[Discount])
d. Save and open the query. Does it work? (Correct any typo errors if you see an error
message or “Enter Parameter Value” window.)
e. Switch to Design View.
f. Click the Totals command in the Ribbon to show the column totals in the query
result. The Total row appears in the design grid.
Use the DCount function to determine the number of records that are in a specified set of records
(a domain.) This function can be used when writing expressions in a form or macro.
where: (1) "[field name]" is the name of a field in a table (or a query) that identifies the field
for which you want to count records.
(2) "table name" is the name of a table (or a query) identifying the set of records that
constitutes the domain.
(3) "criteria" is an optional string expression used to restrict the range of data on which
the DCount function is performed. If criteria are omitted, the DCount function
counts the records against the entire domain.
Demonstration:
Build a macro and use the DCount function to check whether there are any rental records belonging
to a customer before deleting the customer in the Customer Form.
– If there are rental records associated with the customer selected in the Customer Form, then
display a meaningful warning message.
– If there are no rental records associated with the customer, delete the customer record from the
tblCustomer table and display a confirmation message.
– Make sure that the following system error message will not be displayed.
Question:
- end of document -