Lesson 3
Lesson 3
• Then click (and drag for sizing) where you wish the control be
placed. You will see two controls placed in the form: a label
and a text box.
• For the label one could enter Extended price, and in the text
box you would enter a formula (e.g. for an extended price a
formula would be: =[quantity]*[unitprice]).
Forms: Adding calculation fields
• Adjust the size and location of the controls as
necessary. To do this can be a little tricky. To move a
control you must select the control, and then click
(and drag) the large dot in the control’s upper left
corner:
• As a result MS Access
opens a Query By
Example (QBE) window
Queries
• This window comprises two areas: Relationships
and Grid. The Relationships area will show each
table that needs to be accessed and the
relationships to be used with those tables.
• The Grid area is used to specify:
– fields and tables,
– sort fields,
– fields to be included in the results display,
– criteria fields must meet for a row to be included in the
query result,
– calculations,
– grouping of rows for displaying summary information
Simple query
• The simplest query is one that displays a
complete table – all rows and columns.
Suppose we want to list all books in the library.
The process of creating the query is as follows:
Simple query
• Result:
Simple query
• Add the Paid field from the Orders Table to your query.
• Set the following criteria:
In the Zip Code field, type 27609 to return only records with a zip code
of 27609.
In the Paid field, type Yes to return only customers who have paid.
• Run the query. If you entered the query correctly, your results will include
20 records of customers who live in the zip code 27609 and have paid for
an order. If not, click the View drop-down arrow on the Ribbon to return
to Design view and check your work.
• Save the query with the name Paying Customers in 27609.
ACTIVITY: Create a multi-table query
In Library database.
1. For each loan show the title of the book and the date it
was borrowed. Note that the title is in the Book table and
the date borrowed is in the Loan table.
2. Modify the previous query to produce a listing that is in
order by title and then by date.
3. Produce a list that shows for each loan the book title, the
name of the member who borrowed the book, and the
dates the book was borrowed and then returned. Note
that 3 tables are needed for this query.
ACTIVITY: Create a multi-table query
In Library database.
4. Produce a list of members and the books they
have taken out on loan. Include the
member’s last name, first name, and titles of the
books. The information to be displayed is in 2
tables, but it is necessary to specify 3 tables for
this query:
- Member joins to Loan
- Book joins to loan
ACTIVITY: Create a multi-table query
In Library database.
5. Modify the previous query to produce a listing that is
in order by last name and then by first name.
6. For member id 2, list the person`s name and the titles
borrowed.
7. Produce a list of book titles and member names for
those books that are due back May 18, 2014.
8. Produce a list of book titles and member names for
those books that have not been returned. In this case
you must give the criteria for dateReturned as null.
Null is a special keyword that represents no value.
Activity