Performing Queries with the Simple Query Wizard

CHAPTER
Performing Queries
perForManCe oBJeCtiVes
Upon successful completion of Chapter 3, you will be able to:
• Design queries to extract specific data from tables
• Modify queries
• Design queries with Or and And criteria
• Use the Simple Query Wizard to create queries
• Create a calculated field
• Use aggregate functions in queries
• Create crosstab, duplicate, and unmatched queries
Tutorials
3.1 Creating a Query in Design View
3.2 Extracting Records Using Criteria
Statements
3.3 Creating a Query in Design View
Using Multiple Tables
3.4 Extracting Records Using AND
Criteria; Sorting Query Results
3.5 Renaming and Deleting Objects
3.6 Extracting Records Using OR
Criteria
3.7 Creating Queries Using the Simple
Query Wizard
3.8 Performing Calculations in a Query
3.9 Using Aggregate Functions
3.10 Creating a Crosstab Query
3.11 Creating a Find Duplicates Query
3.12 Creating a Find Unmatched Query
One of the primary uses of a database is to extract the specific information
needed to answer questions and make decisions. A company might need to know
information such as how much inventory is currently on hand, which products
have been ordered, which accounts are past due, or which customers live in a
particular city. You can extract specific information from a table or multiple tables
by completing a query. You will learn how to perform a variety of queries on
information in tables in this chapter. Model answers for this chapter’s projects
appear on the following pages.
Access
al1C3
Note: Before beginning the projects, copy the AL1C3 subfolder from
the AL1 folder on the CD that accompanies this textbook to your
storage medium and make AL1C3 the active folder.
77
Project 1 Design Queries
Project 1a
Relationships for AL1-C3-Dearborn
Thursday, October 8, 2015
Clients
ClientID
RepID
Client
StreetAddress
City
State
ZipCode
Telephone
Email
Sales
SalesID
ClientID
CalendarYear
Sales
Representatives
RepID
RepName
Telephone
Email
QuotaID
Benefits
RepID
HireDate
Vacation
HealthBenefits
Dearborn Relationships
Client
Fairhaven Developers
Landower Company
Harford Systems
Gallagher Systems
Blue Ridge, Inc.
Alderton Metals
DV Corporation
Wheeling Products
Martin Manufacturing
Valley Construction
AeroTech
Miles & Harrisburg
Haute Contractors
Eagleton Industries
Zinn-Harris Electronics
StreetAddress
City
574 East Raymond Street Indianapolis
1299 Arlington Avenue Indianapolis
9654 Jackson Street
Indianapolis
3885 Moore Avenue
Indianapolis
29 South 25th Street
Indianapolis
103 South Parker Avenue Indianapolis
210 West Michigan Stree Indianapolis
5567 Washburn Avenue Indianapolis
422 West Morris Street Indianapolis
123 46th Street
Indianapolis
9905 West 16th Street Indianapolis
11029 47th Street East Indianapolis
422 Kessler Boulevard
Indianapolis
544 Eastridge Drive
Indianapolis
675 South Holt Road
Indianapolis
State
IN
IN
IN
IN
IN
IN
IN
IN
IN
IN
IN
IN
IN
IN
IN
10/8/2015
ZipCode
46219-3005
46236-1299
46247-9654
47229-1075
46227-1355
47220-1450
46251-4503
46247-5567
46238-4220
46242-1230
46241-9905
46238-1120
46218-4220
47230-5440
47221-0551
QuotaID
3
3
3
3
4
4
4
5
5
Sales
$289,563.00
$101,210.00
$125,436.00
$215,420.00
$199,346.00
$554,120.00
$138,560.00
$141,670.00
$115,423.00
$156,439.00
$222,133.00
$174,319.00
$300,137.00
$151,003.00
$214,000.00
$327,541.00
$144,328.00
$130,239.00
$441,000.00
$221,379.00
$105,000.00
$721,923.00
$200,540.00
$103,400.00
$175,011.00
$222,133.00
$103,435.00
$125,900.00
$265,439.00
$120,890.00
$176,420.00
SalesOver$99999Query
Relationships for AL1-C3-CopperState
Thursday, October 8, 2015
Clients
ClientID
FirstName
LastName
StreetAddress
City
State
ZIP
Telephone
Coverage
LicenseNo
ClientID
Medical
Liability
Comprehensive
UninsMotorist
Collision
Agents
AgentID
OfficeID
FirstName
LastName
Page 1
Telephone
Assignments
ClientID
OfficeID
AgentID
GoldStatus
MarToNov2011HiresQuery
Feb1-28OrdersQuery
Product
Cascade R4 jacket, MXL
Multi-function compass
Ten-piece hiker cookware
Eight-piece stainless steel cookware
Deluxe map compass
SL 20-degrees synthetic sleeping bag, red
SL 20-degrees synthetic sleeping bag, blac
Cascade R4 jacket, WM
Cascade R4 jacket, ML
Cascade R4 jacket, WXL
HT waterproof hiking boots, WS8
HT waterproof hiking boots, WS7
Binoculars, 8 x 42
Thermaline roll-top table
HT waterproof hiking boots, WS9
HT waterproof hiking boots, WS11
Thermaline sleeping pad
Customers Table
Feb1-28OrdersQuery
■
Claims
ClaimID
ClientID
LicenseNo
DateOfClaim
AmountOfClaim
Offices
OfficeID
Address
City
State
ZIP
Telephone
OrderDate
2/2/2015
2/2/2015
2/2/2015
2/2/2015
2/2/2015
2/2/2015
2/2/2015
2/2/2015
2/2/2015
2/2/2015
2/16/2015
2/16/2015
2/16/2015
2/16/2015
2/16/2015
2/16/2015
2/16/2015
ClientID
3120
7335
4300
3120
4852
5645
7521
0214
8223
5665
9879
4852
6478
9775
5645
9897
2768
7139
9872
5982
4875
1574
4786
5231
4567
4868
10/8/2015
Page 1
RepsHiredIn2012Query
FirstName
Spenser
Vernon
Paul
Spenser
10/8/2015
Phillip
Eileen
Fredrick
Alice
Cecilia
Suzanne
Harold
Phillip
Parma
Carla
Eileen
Rachel
Marcus
Donald
Sun
Alan
Michael
Joanne
Lenora
Helena
Bonnie
Eric
LastName
Winters
Cook
Vuong
Winters
Cole
Hanley
Guthrie
Ryckman
Ortiz
Lundberg
McDougal
Cole
Moreno
Waterman
Hanley
Kaelin
LeVigne
Rutledge
Cheong
Couturier
Nicolo
Donnelly
Chisham
Myerson
Metzger
Zadinski
Orders Table
UninsMotorist
RepID
RepName
15
Lee Hutchinson
22
Gina Tapparo
25
Lydia Alvarado
HireDate
2/1/2012
10/1/2012
4/1/2012
BlueRidgeSalesQuery
ClientID
Client
110
Blue Ridge, Inc.
110
Blue Ridge, Inc.
JanClaimsOver$500Query
ClientID
9383
7335
4300
9383
1574
4875
8223
4300
8854
9879
4567
5982
FirstName
Elaine
Vernon
Paul
Elaine
Joanne
Michael
Cecilia
Paul
Edward
Harold
Bonnie
Alan
LastName
Hueneka
Cook
Vuong
Hueneka
Donnelly
Nicolo
Ortiz
Vuong
Bakalarski
McDougal
Metzger
Couturier
10/8/2015
Sales
$17,542.00
$83,210.00
BlueRidgeSalesQuery
Orders Table
10/8/2015
10/8/2015
RepsHiredIn2012Query
UninsMotoristCoverageQuery
Unit 1
Page 1
Page 1
UninsMotoristCoverageQuery
HireDate
3/15/2011
4/12/2011
3/7/2011
Access Level 1
Orders Table
QuotaIDGreaterThanTwoQuery
Customers Table
78
Telephone
(765) 555-4277
(765) 555-8822
(765) 555-4996
QuotaIDGreaterThanTwoQuery
CopperState Relationships
ProductID
250-XL
100-02
202-CW
201-CW
100-05
101-S3R
101-S3B
255-M
250-L
255-XL
299-W4
299-W5
602-XR
590-TL
299-W3
299-W1
560-TL
RepName
Lee Hutchinson
Isabelle Marshall
Lydia Alvarado
RepName
Catherine Singleton
Isabelle Marshall
Maureen Pascual
Linda Foster
Kwan Im
William Ludlow
Lydia Alvarado
Alfred Silva
Gina Tapparo
MarToNov2011HiresQuery
RepName
Alfred Silva
Cecilia Ortega
Isabelle Marshall
101
102
103
105
107
109
10/8/2015
112
113
115
118
119
122
123
125
127
101
10/8/2015 103
104
105
107
108
109
112
115
118
119
121
122
123
125
127
RepsWith765AreaCodeQuery
ClientsIndianapolisQuery
Project 1b
SalesOver$99999Query
ClientID
RepsWith765AreaCodeQuery
ClientsIndianapolisQuery
Customers Table
Quotas
QuotaID
Quota
ClaimID
102394
104366
121039
153001
158954
147858
158962
178545
174223
174589
136695
147851
DateOfClaim AmountOfClaim
1/2/2015
$1,235.00
1/5/2015
$834.95
1/8/2015
$5,230.00
1/17/2015
$535.00
1/19/2015
$1,050.75
1/16/2015
$875.00
1/21/2015
$2,830.50
1/30/2015
$4,858.30
1/23/2015
$950.50
1/26/2015
$752.45
1/10/2015
$1,840.00
1/12/2015
$3,250.50
JanClaimsOver$500Query
10/8/2015
GWClientsQuery
Project 1c
ProductID
442-1B
780-2
250-XL
250-L
101-S3R
101-S3B
299-M3
299-M2
299-M5
299-W4
299-W5
299-W3
299-W1
255-XL
255-M
560-TL
155-35
375-S
375-M
590-TL
209-XL
209-L
210-L
209-XXL
100-05
371-L
202-CW
155-20
201-CW
210-M
100-02
152-H
SupplierID
42
99
60
60
54
54
31
31
31
31
31
31
31
60
60
25
10
68
68
25
68
68
68
68
84
68
15
10
15
68
84
10
OrdersLessThan$1500Query
UnitsOrdered
10
10
10
10
10
10
10
10
10
10
10
10
8
5
5
20
10
20
20
5
25
25
25
20
5
10
5
15
5
15
10
15
Amount
$1,495.00
$1,288.50
$1,285.00
$1,285.00
$1,199.50
$1,137.50
$887.90
$887.90
$887.90
$752.90
$752.90
$752.90
$602.32
$599.50
$599.50
$397.00
$199.50
$199.00
$199.00
$196.25
$180.00
$173.75
$162.25
$145.80
$129.75
$129.50
$124.25
$104.25
$99.75
$97.35
$45.95
$44.85
OfficeID
GW
GW
GW
GW
GW
FirstName
10/8/2015LastName
Carlos
Alvarez
Joanne
Donnelly
Cecilia
Ortiz
Donald
Rutledge
Paul
Vuong
GWClientsQuery
RepName
Andre Kulisek
Andre Kulisek
Lee Hutchinson
Linda Foster
Kwan Im
Linda Foster
Kwan Im
Craig Johnson
Craig Johnson
Catherine Singleton
Lee Hutchinson
Catherine Singleton
Gina Tapparo
Catherine Singleton
Catherine Singleton
David DeBruler
Jaren Newman
David DeBruler
Cecilia Ortega
Alfred Silva
Catherine Singleton
Gina Tapparo
Robin Rehberg
Jaren Newman
Alfred Silva
Cecilia Ortega
Craig Johnson
Edward Harris
William Ludlow
Craig Johnson
Kwan Im
OrdersLessThan$1500Query
10/8/2015
Project 1d
SalesMoreThan$100000Query
Client
HE Systems
HE Systems
Harford Systems
Bering Company
Eagleton Industries
Bering Company
Eagleton Industries
Miles & Harrisburg
Miles & Harrisburg
Gallagher Systems
Harford Systems
Zinn-Harris Electronics
DV Corporation
Gallagher Systems
Zinn-Harris Electronics
AeroTech
Haute Contractors
AeroTech
Dover Industries
Clearwater Service
Franklin Services
DV Corporation
Landower Company
Haute Contractors
Clearwater Service
Dover Industries
Wheeling Products
Karris Supplies
Madison Electrics
Wheeling Products
Fairhaven Developers
10/8/2015
Sales
$721,923.00
$554,120.00
$441,000.00
$327,541.00
$300,137.00
$289,563.00
$265,439.00
$222,133.00
$222,133.00
$221,379.00
$215,420.00
$214,000.00
$200,540.00
$199,346.00
$176,420.00
$175,011.00
$174,319.00
$156,439.00
$151,003.00
$144,328.00
$141,670.00
$138,560.00
$130,239.00
$125,900.00
$125,436.00
$120,890.00
$115,423.00
$105,000.00
$103,435.00
$103,400.00
$101,210.00
RepName
William Ludlow
Robin Rehberg
Kwan Im
Isabelle Marshall
Maureen Pascual
Isabelle Marshall
Catherine Singleton
Lydia Alvarado
Edward Harris
Jaren Newman
Alfred Silva
Lydia Alvarado
Craig Johnson
Kwan Im
Craig Johnson
Lee Hutchinson
Jaren Newman
Maureen Pascual
Lee Hutchinson
Alfred Silva
Alfred Silva
Alfred Silva
Kwan Im
SalesLessThan$100000Query
Client
Madison Electrics
Landower Company
Fairhaven Developers
Providence, Inc.
Blue Ridge, Inc.
Providence, Inc.
Franklin Services
Martin Manufacturing
Karris Supplies
Paragon Corporation
Alderton Metals
Martin Manufacturing
Hoosier Corporation
Milltown Contractors
Hoosier Corporation
Valley Construction
Paragon Corporation
Blue Ridge, Inc.
Valley Construction
Northstar Services
Alderton Metals
Northstar Services
Milltown Contractors
10/8/2015
Sales
$99,450.00
$97,653.00
$95,630.00
$85,628.00
$83,210.00
$75,462.00
$65,411.00
$61,539.00
$61,349.00
$51,237.00
$45,230.00
$35,679.00
$31,935.00
$31,230.00
$24,880.00
$22,478.00
$20,137.00
$17,542.00
$15,248.00
$15,094.00
$9,547.00
$9,457.00
$2,356.00
SalesLessThan$100000Query
RepsWith3WeekVacationsQuery
RepName
Alfred Silva
Cecilia Ortega
Isabelle Marshall
Craig Johnson
Gina Tapparo
Edward Harris
10/8/2015
Vacation
3 weeks
3 weeks
3 weeks
3 weeks
3 weeks
3 weeks
RepsWith3WeekVacationsQuery
SalesMoreThan$100000Query
Page 1
Page 1
Page 1
SalesOver$100000IndianapolisQuery
Project 1e
Suppliers25-31-42Query
Client
Fairhaven Developers
Landower Company
Harford Systems
Harford Systems
Gallagher Systems
Gallagher Systems
DV Corporation
DV Corporation
Wheeling Products
Wheeling10/8/2015
Products
AeroTech
AeroTech
Miles & Harrisburg
Miles & Harrisburg
Haute Contractors
Haute Contractors
Eagleton Industries
Eagleton Industries
Zinn-Harris Electronics
Zinn-Harris Electronics
RepsWith3Or4WeekVacationsQuery
RepName
William Ludlow
Alfred Silva
Cecilia Ortega
Robin Rehberg
Isabelle Marshall
Craig Johnson
Gina Tapparo
Edward Harris
Vacation
4 weeks
3 weeks
3 weeks
4 weeks
3 weeks
3 weeks
3 weeks
3 weeks
RepsWith3Or4WeekVacationsQuery
SupplierName
Freedom Corporation
Freedom Corporation
Freedom Corporation
Freedom Corporation
Freedom Corporation
Freedom Corporation
Freedom Corporation
Freedom Corporation
City
Page 1
Indianapolis
Indianapolis
Indianapolis
Indianapolis
Indianapolis
Indianapolis
Indianapolis
Indianapolis
Indianapolis
Indianapolis
Indianapolis
Indianapolis
Indianapolis
Indianapolis
Indianapolis
Indianapolis
Indianapolis
Indianapolis
Indianapolis
Indianapolis
Sales
$101,210.00
$130,239.00
$215,420.00
$441,000.00
$199,346.00
$221,379.00
$138,560.00
$200,540.00
$115,423.00
$103,400.00
$156,439.00
$175,011.00
$222,133.00
$222,133.00
$174,319.00
$125,900.00
$300,137.00
$265,439.00
$214,000.00
$176,420.00
SalesOver$100000IndianapolisQuery
SkiHatsGlovesOnOrderQuery
OrderID
1017
1009
1008
1012
1013
1016
1015
1014
Product
Gordon wool ski hat, L
Gordon wool ski hat, XL
Gordon wool ski hat, XXL
Tech-lite ski hat, L
Tech-lite ski hat, M
Lite-tech ski gloves, ML
Lite-tech ski gloves, WM
Lite-tech ski gloves, WS
Medical
Liability
UnitsOrdered
25
25
20
25
15
10
20
20
Comprehensive
UninsMotorist
SupplierName
Product
Langley Corporation Thermaline sleeping pad
Langley Corporation Thermaline light-weight cot
Langley Corporation Thermaline camp seat
Langley Corporation Thermaline roll-top table
Sound Supplies
HT waterproof hiking boots, MS13
Sound Supplies
HT waterproof hiking boots, MS12
Sound Supplies
HT waterproof hiking boots, MS11
Sound Supplies
HT waterproof hiking boots, MS10
Sound Supplies
HT waterproof hiking boots, MS9
Sound Supplies
HT waterproof hiking boots, WS11
Sound Supplies
HT waterproof hiking boots, WS10
Sound Supplies
HT waterproof hiking boots, WS9
Sound Supplies
HT waterproof hiking boots, WS8
Sound Supplies
HT waterproof hiking boots, WS7
Sound Supplies
HT waterproof hiking boots, WS6
Fraser Valley Products Polar backpack, 150BR
Fraser Valley Products Polar backpack, 150RW
Fraser Valley Products Polar backpack, 250BR
Fraser Valley Products Polar backpack, 250RW
Suppliers25-31-42Query
BootsSleepingBagsBackpacksQuery
Collision
Page 1
Customers Table
ClientsWithOnlyLiabilityQuery
10/8/2015
Page 1
ClientsWithOnlyLiabilityQuery
LastName
Lazzuri
Bakalarski
Lazzuri
Mardock
Alvarez
SupplierID
25
25
25
25
31
31
31
31
31
31
31
31
31
31
31
42
42
42
42
10/8/2015
SkiHatsGlovesOnOrderQuery
FirstName
Brenda
Edward
Brenda
Bret
Carlos
10/8/2015
Orders Table
ProductID
443-1B
101-S1B
101-S1R
101-S2B
101-S2R
101-S3B
101-S3R
299-M1
10/8/2015
299-M2
299-M3
299-M4
299-M5
299-W1
299-W2
299-W3
299-W4
299-W5
299-W6
442-1A
442-1B
443-1A
10/8/2015
Product
SupplierName
Polar backpack, 250RW
Fraser Valley Products
SL 0-degrees down sleeping bag, black
Manning, Inc.
SL 0-degrees down sleeping bag, red
Manning, Inc.
SL 15-degrees synthetic sleeping bag, blac Manning, Inc.
SL 15-degrees synthetic sleeping bag, red Manning, Inc.
SL 20-degrees synthetic sleeping bag, blac Manning, Inc.
SL 20-degrees synthetic sleeping bag, red Manning, Inc.
HT waterproof hiking boots, MS13
Sound Supplies
HT waterproof hiking boots, MS12
Sound Supplies
HT waterproof hiking boots, MS11
Sound Supplies
HT waterproof hiking boots, MS10
Sound Supplies
HT waterproof hiking boots, MS9
Sound Supplies
HT waterproof hiking boots, WS11
Sound Supplies
HT waterproof hiking boots, WS10 Page 1 Sound Supplies
HT waterproof hiking boots, WS9
Sound Supplies
HT waterproof hiking boots, WS8
Sound Supplies
HT waterproof hiking boots, WS7
Sound Supplies
HT waterproof hiking boots, WS6
Sound Supplies
Polar backpack, 150BR
Fraser Valley Products
Polar backpack, 150RW
Fraser Valley Products
Polar backpack, 250BR
Fraser Valley Products
BootsSleepingBagsBackpacksQuery
Page 1
Chapter 3
■
Performing Queries
79
ClientSalesQuery
Project 1f
ClientID
122
123
123
124
124
125
125
126
126
127
127
ClientSalesQuery
ClientID
101
101
102
102
103
103
104
104
105
105
106
106
107
107
108
108
109
109
110
110
111
111
112
112
113
113
114
114
115
115
116
116
117
117
118
118
119
119
120
120
121
121
122
Client
Bering Company
Bering Company
Fairhaven Developers
Fairhaven Developers
Clearwater Service
Clearwater Service
Landower Company
Landower Company
Harford Systems
Harford Systems
Providence, Inc.
Providence, Inc.
Gallagher Systems
Gallagher Systems
Karris Supplies
Karris Supplies
HE Systems
HE Systems
Blue Ridge, Inc.
Blue Ridge, Inc.
Alderton Metals
Alderton Metals
DV Corporation
DV Corporation
Franklin Services
Franklin Services
Milltown Contractors
Milltown Contractors
Wheeling Products
Wheeling Products
Martin Manufacturing
Martin Manufacturing
Valley Construction
Valley Construction
AeroTech
AeroTech
Miles & Harrisburg
Miles & Harrisburg
Paragon Corporation
Paragon Corporation
Madison Electrics
Madison Electrics
Haute Contractors
Sales
$289,563.00
$327,541.00
$101,210.00
$95,630.00
$125,436.00
$144,328.00
$97,653.00
$130,239.00
$215,420.00
$441,000.00
$85,628.00
$75,462.00
$199,346.00
$221,379.00
$61,349.00
$105,000.00
$554,120.00
$721,923.00
$17,542.00
$83,210.00
$9,547.00
$45,230.00
$138,560.00
$200,540.00
$141,670.00
$65,411.00
$2,356.00
$31,230.00
$115,423.00
$103,400.00
$35,679.00
$61,539.00
$15,248.00
$22,478.00
$156,439.00
$175,011.00
$222,133.00
$222,133.00
$51,237.00
$20,137.00
$99,450.00
$103,435.00
$174,319.00
ClientSalesQuery, Page 1
Client
Haute Contractors
Eagleton Industries
Eagleton Industries
Hoosier10/8/2015
Corporation
Hoosier Corporation
Dover Industries
Dover Industries
Northstar Services
Northstar Services
Zinn-Harris Electronics
Zinn-Harris Electronics
10/8/2015
Project 1h
Sales
$125,900.00
$300,137.00
$265,439.00
$24,880.00
$31,935.00
$151,003.00
$120,890.00
$9,457.00
$15,094.00
$214,000.00
$176,420.00
ClientSalesQuery, Page 2
ProductOrderAmountsQuery
SupplierID
42
25
25
35
99
99
84
84
54
54
54
10
10
10
15
15
68
68
68
68
68
60
60
60
60
31
31
31
31
31
31
31
68
68
68
42
Page 1
SupplierName
ProductID
Amount
Fraser Valley Products 443-1B
$2,397.75
Langley Corporation 560-TL
$397.00
Langley Corporation 590-TL
$196.25
Emerald City Products 602-XR
$2,145.00
KL Distributions
647-1
$2,999.85
KL Distributions
780-2
$1,288.50
Macadam, Inc.
100-02
$45.95
Macadam, Inc.
100-05
$129.75
Manning, Inc.
101-S2R
$1,945.25
Manning, Inc.
101-S3B
$1,137.50
Manning, Inc.
101-S3R
$1,199.50
Hopewell, Inc.
152-H
$44.85
Hopewell, Inc.
155-20
$104.25
Hopewell, Inc.
155-35
$199.50
Bayside Supplies
201-CW
$99.75
Bayside Supplies
202-CW
$124.25
Freedom Corporation 209-L
$173.75
Freedom Corporation 209-XL
$180.00
Freedom Corporation 209-XXL
$145.80
Freedom Corporation 210-L
$162.25
Freedom Corporation 210-M
$97.35
Cascade Gear
250-L
$1,285.00
Cascade Gear
250-XL
$1,285.00
Cascade Gear
255-M
$599.50
Cascade Gear
255-XL
$599.50
Sound Supplies
299-M2
$887.90
Sound Supplies
299-M3
$887.90
Sound Supplies
299-M5
$887.90
Page 2 $602.32
Sound Supplies
299-W1
Sound Supplies
299-W3
$752.90
Sound Supplies
299-W4
$752.90
Sound Supplies
299-W5
$752.90
Freedom Corporation 371-L
$129.50
Freedom Corporation 375-M
$199.00
Freedom Corporation 375-S
$199.00
Fraser Valley Products 442-1B
$1,495.00
ProductOrderAmountsQuery
Page 1
Project 1g
SuppliersNotBCQuery
SupplierName
StreetAddress
Bayside Supplies
6705 North Street
Hadley Company
5845 Jefferson Street
Cascade Gear
540 Broadway
Sound Supplies
2104 Union Street
Emerald City Products 1059 Pike Street
KL Distributions
402 Yukon Drive
SuppliersNotBCQuery
Client
Bering Company
Clearwater Service
Providence, Inc.
Paragon Corporation
Dover Industries
Northstar Services
City
Bellingham
Seattle
Seattle
Seattle
Seattle
Bellingham
10/8/2015
State
IN
IN
IN
IN
IN
IN
ZipCode
47310-5500
47308-1236
47306-3410
47302-4338
47306-4839
47301-7774
ClientsMuncieQuery
PhoenixClientClaimsOver$500Query
ClientID
7335
1331
9879
9775
6478
4868
9879
FirstName
Vernon
Erin
Harold
Carla
Parma
Eric
Harold
LastName
Cook
Hagedorn
McDougal
Waterman
Moreno
Zadinski
McDougal
StreetAddress
1230 South Mesa
4818 Oakes Boulevard
7115 Elizabeth Lane
3979 19th Avenue
610 Sheridan Avenue
1301 North Meridian
7115 Elizabeth Lane
PhoenixClientClaimsOver$500Query
City
Phoenix
Phoenix
Phoenix
Phoenix
Phoenix
Phoenix
Phoenix
State
AZ
AZ
AZ
AZ
AZ
AZ
AZ
ZIP
85018
85018
85009
85031
85031
85031
85009
10/8/2015
ClaimID
104366
198745
174589
241485
200147
210369
247823
PensionContributionsQuery
Salary&PensionQuery
EmpID
101
102
103
104
105
106
108
110
111
112
114
115
116
118
119
121
124
125
126
127
129
130
133
134
135
137
138
139
140
FirstName
Joseph
Walter
Francine
Mary
Corey
Stephanie
Nathan
Thomas
Ray
Noreen
Blaine
Sean
Silas
Glenn
Lucinda
Patricia
Antonio
Debra
Michelle
Kurt
Shilo
Norman
Brett
Sally
Dorothy
Leslie
Susan
Jerry
Kathleen
LastName
Ammons
Irving
Prescott
Vanderhoff
Gadeau
Wendt
Holmes
Byrnes
Bannerman
Blanca
Kaiser
O'Callaghan
Workman
Ishimoto
Larsen
Ochoa
Silvestri
Tapparo
Vincent
Ziegler
Alvarado
Curis
Dupree
Farrell
Griswold
Jacobsen
Masui
Prentiss
Schreiber
Access Level 1
■
Unit Page
11
10/8/2015
AnnualSalary Salary&Pension
$52,350.00
53920.5
$50,750.00
52272.5
$52,500.00
54075
$59,750.00
61542.5
$60,150.00
61954.5
$42,000.00
43260
$53,350.00
54950.5
$42,500.00
43775
$32,600.00
33578
$38,750.00
39912.5
$64,500.00
66435
Page 1
$52,455.00
54028.65
$51,000.00
52530
$68,525.00
70580.75
$38,425.00
39577.75
$59,750.00
61542.5
$51,350.00
52890.5
$40,150.00
41354.5
$39,750.00
40942.5
$65,250.00
67207.5
$45,000.00
46350
$42,450.00
43723.5
$58,550.00
60306.5
$58,000.00
59740
$67,700.00
69731
$48,800.00
50264
$38,500.00
39655
$57,525.00
59250.75
$45,250.00
46607.5
AmountOfClaim
$834.95
$1,797.00
$752.45
$4,500.00
$925.75
$2,675.00
$775.75
Product
OrderID
UnitsOrdered
Two-person tent
1001
10
HT waterproof hiking boots, MS9
1002
10
HT waterproof hiking boots, MS11
1003
10
Polar backpack, 250RW
1004
15
HT waterproof hiking boots, MS12
1005
10
Two-person dome tent
1006
15
Polar backpack, 150RW
1007
10
Gordon wool ski hat, XXL
1008
20
Gordon wool ski hat, XL
1009
25
Shursite portable camp light
1010
10
Lantern hanger
1011
15
Tech-lite ski hat, L
1012
25
Page 1
Tech-lite ski hat, M
1013
15
Lite-tech ski gloves, WS
1014
20
Lite-tech ski gloves, WM
1015
20
Lite-tech ski gloves, ML
1016
10
Gordon wool ski hat, L
1017
25
Shursite angle-head flashlight
1018
15
Cascade R4 jacket, MXL
1019
10
Multi-function compass
1020
10
Ten-piece hiker cookware
1021
5
Eight-piece stainless steel cookware
1022
5
Deluxe map compass
1023
5
SL 20-degrees synthetic sleeping bag, re 1024
10
SL 20-degrees synthetic sleeping bag, bla 1025
10
Cascade R4 jacket, WM
1026
5
SL 15-degrees synthetic sleeping bag, re 1027
15
Cascade R4 jacket, ML
1028
10
Cascade R4 jacket, WXL
1029
5
HT waterproof hiking boots, WS8
1030
10
HT waterproof hiking boots, WS7
1031
10
Binoculars, 8 x 42
1032
5
Thermaline roll-top table
1033
5
HT waterproof hiking boots, WS9
1034
10
HT waterproof hiking boots, WS11
1035
8
Thermaline sleeping pad
1036
20
UnitsOrderedTotalQuery
Page 1
80
10/8/2015
AnnualSalary PensionContribution
$52,350.00
1570.5
$50,750.00
1522.5
$52,500.00
1575
$59,750.00
1792.5
$60,150.00
1804.5
$42,000.00
1260
$53,350.00
1600.5
$42,500.00
1275
$32,600.00
978
$38,750.00
1162.5
$64,500.00
1935
$52,455.00
1573.65
$51,000.00
1530
$68,525.00
2055.75
$38,425.00
1152.75
$59,750.00
1792.5
$51,350.00
1540.5
$40,150.00
1204.5
$39,750.00
1192.5
$65,250.00
1957.5
$45,000.00
1350
$42,450.00
1273.5
$58,550.00
1756.5
$58,000.00
1740
$67,700.00
2031
$48,800.00
1464
$38,500.00
1155
$57,525.00
1725.75
$45,250.00
1357.5
UnitsOrderedTotalQuery
PostalCode
98432
98107
98106
98105
98102
96435
ClientsMuncieQuery
StreetAddress
City
4521 East Sixth Street
Muncie
10385 North Gavin Street Muncie
12490 141st Street
Muncie
4500 Meridian Street
Muncie
4839 Huchins Road
Muncie
5135 West Second Street Muncie
PensionContributionsQuery
LastName
Ammons
Irving
Prescott
Vanderhoff
Gadeau
Wendt
Holmes
Byrnes
Bannerman
Blanca
Kaiser
O'Callaghan
Workman
Ishimoto
Larsen
Ochoa
Silvestri
Tapparo
Vincent
Ziegler
Alvarado
Curis
Dupree
Farrell
Griswold
Jacobsen
Masui
Prentiss
Schreiber
Salary&PensionQuery
10/8/2015
Prov/State
WA
WA
WA
WA
WA
WA
EmpID
FirstName
101
Joseph
102
Walter
103
Francine
104
Mary
105
Corey
106
Stephanie
108
Nathan
110
Thomas
111
Ray
112
Noreen
114
Blaine
115
Sean
10/8/2015
116
Silas
118
Glenn
119
Lucinda
121
Patricia
124
Antonio
125
Debra
126
Michelle
127
Kurt
129
Shilo
130
Norman
133
Brett
134
Sally
135
Dorothy
137
Leslie
138
Susan
139
Jerry
140
Kathleen
10/8/2015
Amount
$1,288.50
$887.90
$887.90
$2,397.75
$887.90
$2,999.85
$1,495.00
$145.80
$180.00
$199.50
$44.85
$162.25
$97.35
$199.00
$199.00
$129.50
$173.75
$104.25
$1,285.00
$45.95
$124.25
$99.75
$129.75
$1,199.50
$1,137.50
$599.50
$1,945.25
$1,285.00
$599.50
$752.90
$752.90
$2,145.00
$196.25
$752.90
$602.32
$397.00
Total
$12,885.00
$8,879.00
$8,879.00
$35,966.25
$8,879.00
$44,997.75
$14,950.00
$2,916.00
$4,500.00
$1,995.00
$672.75
$4,056.25
$1,460.25
$3,980.00
$3,980.00
$1,295.00
$4,343.75
$1,563.75
$12,850.00
$459.50
$621.25
$498.75
$648.75
$11,995.00
$11,375.00
$2,997.50
$29,178.75
$12,850.00
$2,997.50
$7,529.00
$7,529.00
$10,725.00
$981.25
$7,529.00
$4,818.56
$7,940.00
Project 2 Create Aggregate Functions, Crosstab, Find Duplicates,
and Find Unmatched Queries
Project 2b
SumOfAmount
$26,530.27
AmountsQuery
AvgOfAmount
$736.95
MaxOfAmount
$2,999.85
AmountsQuery
SumOfAmountOfClaim
$38,711.95
SumAvgClaimAmountsQuery
10/8/2015
SupplierAmountsQuery
Project 2a
ClientID
1331
1574
4300
4567
4868
4875
5982
6478
7335
8223
10/8/2015
8854
9383
9775
9879
10/8/2015
MinOfAmount
$44.85
CountOfAmount
36
ClaimAmountsQuery
AvgOfAmountOfClaim
$2,037.47
MaxOfAmountOfClaim
$5,230.00
MinOfAmountOfClaim
$535.00
SumOfAmountOfClaim
$1,797.00
$2,696.25
$10,088.30
$1,840.00
$2,675.00
$875.00
$3,250.50
$925.75
$834.95
$2,830.50
$3,100.50
$1,770.00
$4,500.00
$1,528.20
AvgOfAmountOfClaim
$1,797.00
$1,348.13
$5,044.15
$1,840.00
$2,675.00
$875.00
$3,250.50
$925.75
$834.95
$2,830.50
$1,550.25
$885.00
$4,500.00
$764.10
SumOfAmount
$348.60
$224.00
$593.25
$5,524.72
$2,145.00
$3,892.75
$4,282.25
$3,769.00
$1,286.65
$175.70
$4,288.35
Project 2c
OrdersBySupplierByProductQuery
SupplierID
10
15
25
31
35
42
54
60
68
84
99
10/8/2015
SupplierName
Hopewell, Inc.
Bayside Supplies
Langley Corporation
Sound Supplies
Emerald City Products
Fraser Valley Products
Manning, Inc.
Cascade Gear
Freedom Corporation
Macadam, Inc.
KL Distributions
SupplierAmountsQuery
SumAvgClaimAmountsQuery
ClaimAmountsQuery
AvgOfAmount
$116.20
$112.00
$296.63
$789.25
$2,145.00
$1,946.38
$1,427.42
$942.25
$160.83
$87.85
$2,144.18
10/8/2015
SupplierName
Total Of AmountBinoculars, 8 x 42
Cascade R4 jacket,
Cascade
ML R4 jacket,
Cascade
MXL R4 jacket,
Cascade
WM R4 jacket,
Deluxe
WXLmap compass
Eight-piece stainless steel cookware
Bayside Supplies
$224.00
$99.75
OrdersBySupplierByProductQuery
10/8/2015
Cascade Gear
$3,769.00
$1,285.00
$1,285.00
$599.50
$599.50
Emerald City Products
$2,145.00
$2,145.00
Fraser Valley Products
$3,892.75
Gordon wool skiGordon
hat, L wool skiGordon
hat, XL wool skiHT
hat,
waterproof
XXL
hiking
HT waterproof
boots, MS11
hiking
HT waterproof
boots, MS12
hiking
HT waterproof
boots, MS9
hiking
HT waterproof
boots, WS11
hiking
HT waterproof
boots, WS7
hiking
HT waterproof
boots, WS8
hiking boots, WS9
Freedom Corporation
$1,286.65
Hopewell, Inc.
KL Distributions
Langley Corporation
Macadam, Inc.
Manning, Inc.
Sound Supplies
$348.60
$4,288.35
$593.25
$175.70
$173.75
$4,282.25
$5,524.72
$180.00
$129.75
$145.80
OrdersBySupplierByProductQuery
10/8/2015
Lantern hanger Lite-tech ski gloves,
Lite-tech
ML ski gloves,
Lite-tech
WM ski gloves,
Multi-function
WS
compass
Polar backpack, Polar
150RW
backpack, Shursite
250RW angle-head
Shursite
flashlight
portableSLcamp
15-degrees
light synthetic sleeping bag, red
$1,495.00 $752.90
$2,397.75
OrdersBySupplierByProductQuery
$752.90
$752.90 Page 1
$887.90
$887.90
$887.90
$602.32
$129.50
$199.00
$199.00
$44.85
Page
1
10/8/2015
$104.25
$199.50
SL 20-degrees synthetic
SL 20-degrees
sleeping
synthetic
Tech-lite
bag, black
sleeping
ski hat,Tech-lite
Lbag, red ski hat,Ten-piece
M
hiker cookware
Thermaline roll-top
Thermaline
table sleeping
Two-person
pad
dome
Two-person
tent
tent
$124.25
$45.95
$1,945.25
Page 1
$162.25
$97.35
$2,999.85
$196.25
$1,137.50
Page 1
$1,288.50
$397.00
$1,199.50
OrdersBySupplierByProductQuery
Page 1
Page 2
ClaimsByClaimIDByClientIDQuery
ClaimID
102394
104366
121039
136695
147851
147858
153001
158954
158962
174223
174589
178545
198745
200147
210369
211458
241485
247823
248210
Total Of AmountOfClaim
1331
$1,235.00
$834.95
$5,230.00
$1,840.00
$3,250.50
$875.00
$535.00
$1,050.75
$2,830.50
$950.50
$752.45
$4,858.30
$1,797.00
$1,797.00
$925.75
$2,675.00
$1,645.50
$4,500.00
$775.75
$2,150.00
1574
4300
4567
ClaimsByClaimIDByClientIDQuery
10/8/2015
4868
4875
6478
5982
8223
8854
9383
$1,235.00
9775
10/8/2015
9879
$834.95
Page 3
$5,230.00
7335
$1,840.00
$3,250.50
$875.00
$535.00
$1,050.75
Page 4
$2,830.50
$950.50
$752.45
$4,858.30
$925.75
$2,675.00
$1,645.50
$4,500.00
$775.75
$2,150.00
ClaimsByClaimIDByClientIDQuery
Project 2d
DuplicateSuppliersQuery
SupplierName
SupplierID
StreetAddress
City 1
Page
Langley Corporation 25
805 First Avenue
Burnaby
Langley Corporation 29
1248 Larson Avenue Burnaby
Prov/State PostalCode
EmailAddress
BC
V3J 1C9
langley@emcp.net
BC
V5V 9K2
lc@emcp.net
10/8/2015
Telephone
(604) 555-1200
(604) 555-1200
Page 2
DuplicateSuppliersQuery
Chapter 3
■
Performing Queries
81
Project 2f
Project 2e
SupplierName Field
Bayside Supplies
Cascade Gear
Fraser Valley Products
Freedom Corporation
Hopewell, Inc.
KL Distributions
Langley Corporation
Macadam, Inc.
Manning, Inc.
Sound Supplies
SupplierOrdersCountQuery
10/8/2015
NumberOfDups
2
4
2
8
3
2
2
2
3
7
ProductID
558-C
559-B
570-TL
580-TL
602-XT
602-XX
648-2
651-1
652-2
804-50
804-60
897-L
897-W
901-S
917-S
100-01
100-03
100-04
101-S1B
101-S1R
101-S2B
155-30
155-45
155-55
200-CW
210-XL
250-M
250-XXL
255-L
299-M1
299-M4
Products Without Matching Orders
Product
ICE snow goggles, clear
ICE snow goggles, bronze
Thermaline light-weight cot
Thermaline camp seat
Binoculars, 10.5 x 45
Binoculars, 10 x 50
Three-person dome tent
K-2 one-person tent
K-2 two-person tent
AG freestyle snowboard, X50
AG freestyle snowboard, X60
Lang blunt snowboard
Lang blunt snowboard, wide
Solar battery pack
Silo portable power pack
Wrist compass
Lenspro plastic compass
Lenspro metal compass
SL 0-degrees down sleeping bag, black
SL 0-degrees down sleeping bag, red
SL 15-degrees synthetic sleeping bag, blac
Shursite aluminum flashlight
Shursite propane lantern
Shursite waterproof headlamp
Four-piece titanium cookware
Tech-lite ski hat, XL
Cascade R4 jacket, MM
Cascade R4 jacket, MXXL
Cascade R4 jacket, WL
HT waterproof hiking boots, MS13
HT waterproof hiking boots, MS10
SupplierID
68
68
25
25
35
35
99
99
99
70
70
70
70
38
38
84
84
84
54
54
54
10
10
10
15
68
60
60
60
31
31
10/8/2015
UnitsInStock
UnitsOnOrder
ReorderLevel
18
0
15
22
0
20
8
0
5
12
0
10
5
0
4
7
0
5
5
0
10
8
0
10
12
0
10
7
0
10
8
0
5
8
0
7
4
0
3
16
0
15
8
0
10
12
0
10
6
0
5
8
0
5
16
0
15
17
0
15
21
0
15
8
0
5
12
0
10
7
0
5
6
0
5
22
0
20
6
0
5
5
0
0
6
0
5
8
0
10
7
0
10
Page 1
SupplierOrdersCountQuery
Project 1 Design Queries
Products Without Matching Orders
8 Parts
You will design and run a number of queries including queries with fields from
one table and queries with fields from more than one table. You will also use the
Simple Query Wizard to design queries.
Extracting Data with Queries ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■
Being able to extract (pull out) specific data from a table is one of the most
important functions of a database. extracting data in Access is referred to as
performing
a query. The word query means “question” and to perform a query
Page 1
means to ask a question. Access provides several methods for performing a query.
You can design your own query, use a simple query wizard, or use complex query
wizards. In this chapter, you will learn to design your own query; use the Simple
Query Wizard; create a calculated field; use aggregate functions in a query; and use
the Crosstab, Find Duplicates, and Unmatched Query wizards.
the first step in
designing a query is to
choose the fields that
you want to display
in the query results
datasheet.
Query Design
82
Access Level 1
■
Designing Queries ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■
Designing a query consists of identifying the table from which you are gathering
data, the field or fields from which the data will be drawn, and the criteria for
selecting the data. To design a query and perform the query, open a database, click
the CreATe tab, and then click the Query Design button in the Queries group.
This displays a query window in the work area and also displays the Show Table
dialog box, as shown in Figure 3.1.
Unit 1
Figure 3.1 Query Window with Show Table Dialog Box
Click the table name you want
included in the query and
then click the Add button.
Click the table name in the Show Table dialog box that you want included in
the query and then click the Add button or double-click the desired table. This
inserts a field list box for the table. Add any other tables required for the query.
When all tables have been added, click the Close button. In the query window,
click the down-pointing arrow at the right of the first Field row field in the query
design grid and then click the desired field from the drop-down list. Figure 3.2
displays a sample query window.
Quick Steps
To establish a criterion, click inside the Criteria row field in the column containing
the desired field name in the query design grid and then type the criterion. With
the fields and criteria established, click the run button in the results group on the
QUerY TOOLS DeSIGN tab. Access searches the specified tables for records that
match the criteria and then displays those records in the query results datasheet. If
you plan to use the query in the future, save the query and name it. If you will not
need the query again, close the query results datasheet without saving it.
To insert a field in the query design grid, click the down-pointing arrow at
the right side of a Field row field and then click the desired field at the drop-down
list. You can also double-click a field in a table field list box to insert the field in
the first available Field row field in the query design grid. For example, suppose
you want to find out how many purchase orders were issued on a specific date.
To do this, double-click PurchaseOrderID in the table field list box (which inserts
PurchaseOrderID in the first Field row field in the query design grid) and then
double-click OrderDate in the table field list box (which inserts OrderDate in the
second Field row field in the query design grid). In this example, both fields are
needed, so the purchase order ID is displayed along with the specific order date.
After inserting the fields, you insert the criterion. The criterion for this example is
something like #1/15/2015#. After you insert the criterion, click the run button in
the results group and the results of the query display in the query results datasheet.
Chapter 3
■
Design a Query
1. Click Create tab.
2. Click Query Design
button.
3. at show table dialog
box, click desired
table, and then click
add button.
4. add any additional
tables.
5. in query design grid,
click down-pointing
arrow in Field row
field and click desired
field from drop-down
list.
6. insert criterion.
7. Click run button.
8. save query.
Run
Performing Queries
83
Figure 3.2 Query Window
table field list box
query design grid
A third method for inserting a field in the query design grid is to drag a field
from the table field list box to the desired field in the query design grid. To do
this, position the mouse pointer on the desired field in the table field list box, hold
down the left mouse button, drag to the desired Field row field in the query design
grid, and then release the mouse button.
establishing Query Criteria
Quick Steps
Establish a Query
Criterion
1. at query window, click
in desired Criteria row
field in query design
grid.
2. type criterion and
then press enter.
3. Click run button.
insert fields in the Field
row fields in the query
design grid in the order
in which you want the
fields to display in the
query results datasheet.
access inserts quotation
marks around text
criteria and pound
symbols around date
criteria.
84
Access Level 1
■
Performing a query does not require specific criteria to be established. In the
example described on the previous page, if the criterion for the date was not
included, the query would return all purchase order numbers with the dates.
(Return is the term used for the results of the query.) While this information
may be helpful, you could easily find this information in the table. The value of
performing a query is to extract specific information from a table. To do this, you
must insert a criterion like the one described in the example.
Access makes writing a criterion fairly simple by inserting the necessary
symbols in the criterion. If you type a city name, such as Indianapolis, in the
Criteria row field and then press enter, Access changes the criterion to
"Indianapolis". The quotation marks are inserted by Access and are necessary for
the query to run properly. You can either let Access put the proper symbols in the
Criteria row field, or you can type the criterion with the symbols. Table 3.1 shows
some examples of criteria, including what is typed and what is returned.
In the criteria examples, the asterisk is used as a so-called wildcard character,
or a symbol that can be used to indicate any character. This is consistent with
many other software applications. Two of the criteria examples in Table 3.1
use less-than and greater-than symbols. You can use these symbols for fields
containing numbers, values, dates, amounts, and so forth. In the next several
projects, you will design queries to extract specific information from different
tables in databases.
Unit 1
Table 3.1 Criteria Examples
Typing This Criterion
Returns This Result
"Smith"
Field value that matches Smith
"Smith" Or "Larson"
Field value that matches either Smith or Larson
Not "Smith"
Field value that is not Smith (the opposite of “Smith”)
"s*"
Field value that begins with S or s and ends in anything
"*s"
Field value that begins with anything and ends in S or s
"[A-D]*"
Field value that begins with A, B, C, or D and ends in anything
#01/01/2015#
Field value that matches the date 01/01/2015
<#04/01/2015#
Field value that is less than (before) 04/01/2015
>#04/01/2015#
Field value that is greater than (after) 04/01/2015
Between #01/01/2015#
And #03/31/2015#
Field value that is between 01/01/2015 and 03/31/2015
Project 1a
Performing Queries on Tables
Part 1 of 8
1. Open AL1-C3-Dearborn.accdb from the AL1C3 folder on your storage medium and enable
the contents.
2. Create the following relationships and enforce referential integrity (and cascade fields and
records) for each relationship:
a. Create a one-to-many relationship with the ClientID field in the Clients field list box the
“one” and the ClientID field in the Sales field list box the “many.”
b. Create a one-to-one relationship with the RepID field in the Representatives field list box
the “one” and the RepID field in the Benefits field list box the “one.”
c. Create a one-to-many relationship with the RepID field in the Representatives field list box
the “one” and the RepID field in the Clients field list box the “many.”
d. Create a one-to-many relationship with the QuotaID field in the Quotas field list box the
“one” and the QuotaID field in the Representatives field list box the “many.”
3. Click the Save button on the Quick Access toolbar.
4. Print the relationships by completing the following steps:
a. Click the relationship report button in the Tools group on the reLATIONSHIP
TOOLS DeSIGN tab.
b. At the relationship report window, click the Landscape button in the Page Layout group
on the PrINT PreVIeW tab.
c. Click the Print button that displays at the left side of the PrINT PreVIeW tab.
d. At the Print dialog box, click OK.
5. Close the relationship report window without saving the report.
6. Close the relationships window.
Chapter 3
■
Performing Queries
85
7. extract records of those clients located in Indianapolis by completing the following steps:
a. Click the CreATe tab.
b. Click the Query Design button in the Queries group.
c. At the Show Table dialog box with the Tables tab selected (see Figure 3.1), click Clients
Step
7a
Step
7b
in the list box, click the Add button, and then click the Close button.
d. Insert fields from the Clients field list box to the Field row fields in the query design grid
by completing the following steps:
1) Click the down-pointing arrow located at the right of the first Field row field in the
query design grid and then click Client in the drop-down
Step
7d1
list.
2) Click inside the next Field row field (to the right of
Client) in the query design grid, click the down-pointing
arrow, and then click StreetAddress in the drop-down list.
3) Click inside the next Field row field (to the right of
StreetAddress), click the down-pointing arrow, and then
click City in the drop-down list.
4) Click inside the next Field row field (to the right of
City), click the down-pointing arrow, and then click State
in the drop-down list.
5) Click inside the next Field row field (to the right of State),
click the down-pointing arrow, and then select ZipCode
in the drop-down list.
Step
7d2
86
Access Level 1
■
Unit 1
Step
7d3
Step
7d4
Step
7d5
e. Insert the criterion text telling Access to display only those suppliers located in
Indianapolis by completing the following steps:
Step
1) Click in the Criteria row field in the
7e2
City column in the query design grid.
(This positions the insertion
point in the field.)
2) Type Indianapolis and then press
enter. (This changes the criterion to
“Indianapolis”.)
f. return the results of the query by
clicking the run button in the results
group on the QUerY TOOLS
DeSIGN tab. (This displays the results
in the query results datasheet.)
g. Save the results of the query by
completing the following steps:
Step
1) Click the Save button on the
7f
Quick Access toolbar.
2) At the Save As dialog box, type ClientsIndianapolisQuery and then press enter or
click OK. (See Project 1a query results on page 78.)
h. Print the query results datasheet by clicking the FILe tab, clicking the Print option, and
then clicking the Quick Print button.
i. Close ClientsIndianapolisQuery.
8. extract those records with quota identification numbers greater than 2 by completing the
following steps:
a. Click the CreATe tab and then click the Query Design button in the Queries group.
b. Double-click Representatives in the Show Table dialog box and then click the Close button.
c. In the query window, double-click RepName. (This inserts the field in the first Field row
field in the query design grid.)
d. Double-click QuotaID. (This inserts the field in the second Field row field in the query
design grid.)
e. Insert the query criterion by completing the following steps:
1) Click in the Criteria row field in the QuotaID
column in the query design grid.
2) Type >2 and then press enter. (Access will
automatically insert quotation marks around 2
since the data type for the field is identified as
Short Text [rather than Number].)
f. return the results of the query by clicking the run
Step
button in the results group.
8e2
g. Save the query and name it QuotaIDGreaterThanTwoQuery.
(See Project 1a query results on page 78.)
h. Print and then close the query.
9. extract those sales greater than $99,999 by completing the following steps:
a. Click the CreATe tab and then click the Query Design button.
b. Double-click Sales in the Show Table dialog box and then click the Close button.
c. At the query window, double-click ClientID. (This inserts the field in the first Field row
field in the query design grid.)
d. Insert the Sales field in the second Field row field.
Chapter 3
■
Performing Queries
87
e. Insert the query criterion by completing the following
steps:
1) Click in the Criteria row field in the Sales column
in the query design grid.
2) Type >99999 and then press enter. (Access will
not insert quotation marks around 99999 since
Step
the field is identified as Currency.)
9e2
f. return the results of the query by clicking the run
button in the results group.
g. Save the query and name it SalesOver$99999Query. (See Project 1a query results on
page 78.)
h. Print and then close the query.
10. extract records of those representatives with a telephone number that begins with the 765
area code by completing the following steps:
a. Click the CreATe tab and then click the Query Design button.
b. Double-click Representatives in the Show Table dialog box and then click the Close button.
c. Insert the RepName field in the first Field row field.
d. Insert the Telephone field in the second Field row field.
e. Insert the query criterion by completing the following steps:
1) Click in the Criteria row field in the Telephone
column.
2) Type "(765*" and then press enter. (You
need to type the quotation marks in this
criterion because the criterion contains a left
parenthesis.)
f. return the results of the query by clicking the
Step
run button in the results group.
10e2
g. Save the query and name it RepsWith765AreaCodeQuery. (See Project 1a query
results on page 78.)
h. Print and then close the query.
In Project 1a, you performed several queries on specific tables. You can also
perform queries on fields from more than one table. In Project 1b, you will perform
queries on related tables.
When completing steps in Project 1b, you will be instructed to open
AL1-C3-CopperState.accdb. Two of the tables in the database contain yes/no
check boxes. When designing a query, you can extract records that contain a check
mark or records that do not contain a check mark. If you want to extract records
that contain a check mark, click in the Criteria row field in the desired column
in the query design grid, type a 1, and then press enter. When you press the
enter key, Access changes the 1 to True. If you want to extract records that do not
contain a check mark, type 0 in the Criteria row field and then press enter. Access
changes the 0 to False.
You can use the Zoom box when entering a criterion in a query to provide a
larger area for typing. To display the Zoom box, press Shift + F2 or right-click in
the desired Criteria row field and then click Zoom at the shortcut menu. Type the
desired criterion in the Zoom box and then click OK.
88
Access Level 1
■
Unit 1
Project 1b
Performing Queries on Related Tables
Part 2 of 8
1. With AL1-C3-Dearborn.accdb open, extract
information on representatives hired between
March 2011 and November 2011 and include the
representatives’ names by completing the
following steps:
a. Click the CreATe tab and then click
Step
the Query Design button.
1d
b. Double-click Representatives in the Show
Table dialog box.
c. Double-click Benefits in the Show Table
dialog box and then click the Close button.
d. At the query window, double-click RepName in
the Representatives field list box.
e. Double-click HireDate in the Benefits field list
box.
f. Insert the query criterion in the Zoom box by
completing the following steps:
1) Click in the Criteria row field in the HireDate column.
2) Press Shift + F2 to display the Zoom box.
3) Type Between 3/1/2011 And 11/30/2011.
Step
Step
(Make sure you type zeros and not capital Os.)
1f3
1f4
4) Click OK.
g. return the results of the
query by clicking the run
button in the results group.
h. Save the query and name it
MarToNov2011HiresQuery.
(See Project 1b query results
on page 78.)
i. Print and then close the query.
2. extract records of those representatives who were hired in 2012 by completing the
following steps:
a. Click the CreATe tab and then click the Query Design button.
b. Double-click Representatives in the Show Table dialog box.
c. Double-click Benefits in the Show Table dialog box and then click the Close button.
d. At the query window, double-click the RepID field in the Representatives field list box.
e. Double-click RepName in the Representatives field list box.
f. Double-click HireDate in the Benefits field list box.
g. Insert the query criterion by completing
the following steps:
1) Click in the Criteria row field in the
HireDate column.
2) Type *2012 and then press enter.
h. return the results of the query by clicking
Step
the run button in the results group.
2g2
i. Save the query and name it RepsHiredIn2012Query.
(See Project 1b query results on page 78.)
j. Print and then close the query.
Chapter 3
■
Performing Queries
89
3. Suppose you need to determine sales for a company but you can only remember that the
company name begins with Blue. Create a query that finds the company and identifies the
sales by completing the following steps:
a. Click the CreATe tab and then click the Query Design button.
b. Double-click Clients in the Show Table dialog box.
c. Double-click Sales in the Show Table dialog box and then click the Close button.
d. At the query window, insert the ClientID field from the Clients field list box in the first
Field row field in the query design grid.
e. Insert the Client field from the Clients field list box in the second Field row field.
f. Insert the Sales field from the Sales field list box in the third
Field row field.
g. Insert the query criterion by completing the following steps:
Step
3g2
1) Click in the Criteria row field in
the Client column.
2) Type Blue* and then press enter.
h. return the results of the query
by clicking the run button in the
results group.
i. Save the query and name it
BlueRidgeSalesQuery. (See Project
1b query results on page 78.)
j. Print and then close the query.
4. Close AL1-C3-Dearborn.accdb.
5. Display the Open dialog box with the AL1C3 folder on your storage medium active.
6. Open AL1-C3-PacTrek.accdb and enable the contents.
7. extract information on products ordered between February 1, 2015, and February 28,
2015, by completing the following steps:
a. Click the CreATe tab and then click the Query Design button.
b. Double-click Products in the Show Table dialog box.
c. Double-click Orders in the Show Table dialog box and then click the Close button.
d. At the query window, insert the ProductID field from the Products field list box in the first
Field row field.
e. Insert the Product field from the Products field list box in the second Field row field.
f. Insert the OrderDate field from the Orders field list box in the third Field row field.
g. Insert the query criterion by completing the following steps:
1) Click in the Criteria row field in the
OrderDate column.
2) Type Between 2/1/2015 And
2/28/2015 and then press enter. (Make
sure you type zeros and not capital Os.)
h. return the results of the query by clicking
the run button in the results group.
Step
i. Save the query and name it Feb17g2
28OrdersQuery. (See Project 1b query results on page 78.)
j. Print and then close the query.
8. Close AL1-C3-PacTrek.accdb.
9. Open AL1-C3-CopperState.accdb and enable the contents.
10. Display the relationships window and create the following additional relationships
(enforce referential integrity and cascade fields and records):
a. Create a one-to-many relationship with the AgentID field in the Agents field list box the
“one” and the AgentID field in the Assignments field list box the “many.”
90
Access Level 1
■
Unit 1
11.
12.
13.
14.
b. Create a one-to-many relationship with the OfficeID field in the Offices field list box the
“one” and the OfficeID field in the Assignments field list box the “many.”
c. Create a one-to-many relationship with the OfficeID field in the Offices field list box the
“one” and the OfficeID field in the Agents field list box the “many.”
Save and then print the relationships.
Close the relationship report without saving it and then close the relationships window.
extract records of clients that have uninsured motorist coverage by completing the
following steps:
a. Click the CreATe tab and then click the Query Design button.
b. Double-click Clients in the Show Table dialog box.
c. Double-click Coverage in the Show Table dialog box and then click the Close button.
d. At the query window, insert the ClientID field from the Clients field list box in the first Field
row field.
e. Insert the FirstName field from the Clients field list box in the second Field row field.
f. Insert the LastName field from the Clients field list box in the third Field row field.
g. Insert the UninsMotorist field from the Coverage field list box in the fourth Field row field.
(You may need to scroll down the Coverage field list box to display the UninsMotorist field.)
h. Insert the query criterion by
clicking in the Criteria row field in
the UninsMotorist column, typing
Step
1, and then pressing the enter key.
13h
(Access changes the 1 to True.)
i. Click the run button in the results group.
j. Save the query and name it UninsMotoristCoverageQuery. (See Project 1b query results on
page 78.)
k. Print and then close the query.
extract records of claims in January over $500 by completing the following steps:
a. Click the CreATe tab and then click the Query Design button.
b. Double-click Clients in the Show Table dialog box.
c. Double-click Claims in the Show Table dialog box and then click the Close button.
d. At the query window, insert the ClientID field from the Clients field list box in the first Field
row field.
e. Insert the FirstName field from the Clients field list box in the second Field row field.
f. Insert the LastName field from the Clients field list box in the third Field row field.
g. Insert the ClaimID field from the Claims field list box in the fourth Field row field.
h. Insert the DateOfClaim field from the Claims field list box in the fifth Field row field.
i. Insert the AmountOfClaim field from the Claims field list box in the sixth Field row field.
j. Click in the Criteria row field in the DateOfClaim column, type Between 1/1/2015 And
1/31/2015, and then press enter.
k. With the insertion point positioned in the Criteria row field in the AmountOfClaim
column, type >500 and then press enter.
l. Click the run button in the results group.
m. Save the query and name it JanClaimsOver$500Query.
(See Project 1b query results on page 78.)
n. Print and then close the query.
Step
14j
Chapter 3
Step
14k
■
Performing Queries
91
Quick Steps
Sort Fields in
a Query
1. at query window, click
in Sort row field in
query design grid.
2. Click down arrow in
Sort row field.
3. Click Ascending or
Descending.
sorting and showing or Hiding Fields in a Query
When designing a query, you can specify the sort order of a field or fields. Click
inside one of the columns in the Sort row field and a down-pointing arrow displays
at the right of the field. Click this down-pointing arrow and a drop-down list
displays with the choices Ascending, Descending, and (not sorted). Click Ascending to
sort from lowest to highest or click Descending to sort from highest to lowest. You
can hide specific fields in the query result by removing the check mark from the
check box in the Show row in the design grid for the field you do not want
to show.
arranging Fields in a Query
Insert Columns
With buttons in the Query Setup group on the QUerY DeSIGN TOOLS tab,
you can insert a new field column in the query design grid and delete a field
column from the query design grid. To insert a field column, click in a field
in the column you want to display immediately right of the new column and
then click the Insert Columns button in the Query Setup group on the QUerY
DeSIGN TOOLS tab. To remove a column, click in a field in the column you
want to delete and then click the Delete Columns button in the Query Setup
group. Complete similar steps to insert or delete a row in the query design grid.
Delete Columns
You can also rearrange columns in the query design grid by selecting the
desired field column and then dragging the column to the desired position. To
select a column in the query design grid, position the mouse pointer at the top
of the column until the pointer turns into a small, black, down-pointing arrow
and then click the left mouse button. Position the mouse pointer toward the top
of the selected column until the mouse displays as a pointer, hold down the left
mouse button, drag to the desired position in the design grid, and then release
the mouse button. As you drag the column, a thick, black, vertical line displays
identifying the location where the column will be inserted.
Project 1c
Performing Queries on Related Tables and Sorting in Field Values
Part 3 of 8
1. With AL1-C3-CopperState.accdb open, extract information on clients with agents from
the West Bell road Glendale office and sort the information alphabetically by client last
name by completing the following steps:
a. Click the CreATe tab and then click the Query Design button.
b. Double-click Assignments in the Show Table dialog box.
c. Double-click Clients in the Show Table dialog box and then click the Close button.
d. At the query window, insert the OfficeID field from the Assignments field list box in the
first Field row field.
e. Insert the AgentID field from the Assignments field list box in the second Field row field.
f. Insert the FirstName field from the Clients field list box in the third Field row field.
g. Insert the LastName field from the Clients field list box in the fourth Field row field.
92
Access Level 1
■
Unit 1
h. Click in the Criteria row field in the OfficeID column, type GW, and then press enter.
i. Sort the LastName field in ascending alphabetical order (A–Z) by completing the
following steps:
1) Click in the Sort row field in the LastName column. (This causes a down-pointing
arrow to display at the right side of the field.)
2) Click the down-pointing arrow at the right side of the Sort row field and then click
Ascending.
j. Specify that you do not want
the AgentID field to show in
the query results by clicking
in the check box in the Show
row field in the AgentID
Step
Step
Step
column to remove the check
1h
1j
1i2
mark.
k. Click the run button in the results group.
l. Save the query and name it GWClientsQuery. (See Project 1c query results on page 79.)
m. Print and then close the query.
2. Close AL1-C3-CopperState.accdb.
3. Open AL1-C3-PacTrek.accdb.
4. extract information on orders less than $1,500 by completing the following steps:
a. Click the CreATe tab and then click the Query Design button.
b. Double-click Products in the Show Table dialog box.
c. Double-click Orders in the Show Table dialog box and then click the Close button.
d. At the query window, insert the ProductID field from the Products field list box in the first
Field row field.
e. Insert the SupplierID field from the Products field list box in the second Field row field.
f. Insert the UnitsOrdered field from the Orders field list box in the third Field row field.
g. Insert the Amount field from the Orders field list box in the fourth Field row field.
h. Insert the query criterion by completing the following steps:
1) Click in the Criteria row
field in the Amount column.
2) Type <1500 and then
press enter. (Make sure
you type zeros and not
capital Os.)
Step
i. Sort the Amount field values from highest to lowest by
4h2
completing the following steps:
1) Click in the Sort row field in the Amount column. (This causes a downpointing arrow to display at the right side of the field.)
2) Click the down-pointing arrow at the right side of the Sort
field and then click Descending.
j. return the results of the query by clicking the run button in
the results group.
k. Save the query and name it OrdersLessThan$1500Query.
Step
(See Project 1c query results on page 79.)
4i2
l. Print and then close the query.
5. Close AL1-C3-PacTrek.accdb.
6. Open AL1-C3-Dearborn.accdb.
7. Design a query by completing the following steps:
a. Click the CreATe tab and then click the Query Design button.
b. Double-click Representatives in the Show Table dialog box.
Chapter 3
■
Performing Queries
93
8.
9.
10.
11.
12.
13.
14.
15.
16.
94
c. Double-click Clients in the Show Table dialog box.
d. Double-click Sales in the Show Table dialog box and then click the Close button.
e. At the query window, insert the RepID field from the Representatives field list box in the
first Field row field.
f. Insert the RepName field from the Representatives field list box in the second Field row
field.
g. Insert the ClientID field from the Clients field list box in the third Field row field.
h. Insert the Sales field from the Sales field list box in the fourth Field row field.
Move the RepName field by completing the following steps:
Step
a. Position the mouse pointer at the top of the
8a
RepName column until the pointer turns into
a small, black, down-pointing arrow and then
click the left mouse button. (This selects the
entire column.)
b. Position the mouse pointer toward the top of
the selected column until the pointer turns
Step
into a white arrow.
8c
c. Hold down the left mouse
button; drag to the
right until a thick, black
horizontal line displays
between the ClientID
column and the Sales
column; and then release
the mouse button.
Delete the RepID field by clicking in a field in the column and then clicking the
Delete Columns button in the Query Setup group.
Insert a new field column and insert a new field in the column by completing the
following steps:
a. Click in the Sales field and then click the Insert
Step
Columns button in the Query Setup group.
10b
b. Click the down-pointing arrow at the right
side of the new field and then click
Clients.Client at the drop-down list.
Hide the ClientID field so it does not display
in the query results by clicking the Show check
box in the ClientID column to remove the
check mark.
Insert the query criterion that extracts
information on sales over $100,000 by
completing the following steps:
a. Click in the Criteria row field in the Sales column.
b. Type >100000 and then press enter. (Make sure you type zeros and not capital Os.)
Sort the Sales field values from highest to lowest by completing the following steps:
a. Click in the Sort row field in the Sales column.
b. Click the down-pointing arrow at the right side of the Sort row field and then click Descending.
return the results of the query by clicking the run button in the results group.
Save the query and name it SalesMoreThan$100000Query. (See Project 1c query results on
page 79.)
Print and then close the query.
Access Level 1
■
Unit 1
Modifying a Query
You can modify a saved query and use it for a new purpose. For example, suppose
that after designing the query that displays sales of more than $100,000, you decide
that you want to find sales that are less than $100,000. rather than design a new
query, open the existing query, make any needed changes, and then run the query.
To modify an existing query, double-click the query in the Navigation pane.
(This displays the query in Datasheet view.) Click the View button to display the
query in Design view. You can also open a query in Design view by right-clicking
the query in the Navigation pane and then clicking Design View at the shortcut
menu. Make the desired changes and then click the run button in the results
group. Click the Save button on the Quick Access toolbar to save the query with
the same name. If you want to save the query with a new name, click the FILe tab,
click the Save As option, click the Save Object As option, and then click the Save As
button. At the Save As dialog box, type a name for the query and then press enter.
If your database contains a number of queries, you can group and display
them in the Navigation pane. To do this, click the down-pointing arrow in the
Navigation pane menu bar and then click Object Type at the drop-down list. This
displays objects grouped in categories, such as Tables and Queries.
Quick Steps
Modify a Query
1. Double-click query in
navigation pane.
2. Click View button.
3. Make desired changes
to query.
4. Click run button.
5. Click save button.
save time designing
a new query by
modifying an existing
query.
renaming and Deleting a Query
If you modify a query, you may want to rename it. To do this, right-click the query
name in the Navigation pane, click Rename at the shortcut menu, type the new
name, and then press enter. If you no longer need the query in the database, delete
it by clicking the query name in the Navigation pane, clicking the Delete button
in the records group on the HOMe tab, and then clicking the Yes button at the
message asking if you want to permanently delete the query. Another method is to
right-click the query in the Navigation pane, click Delete at the shortcut menu, and
then click the Yes at the message. If you are deleting a query from your computer’s
hard drive, the message asking if you want to permanently delete the query will
not display. This is because Access automatically sends the deleted query to the
recycle Bin, where it can be retrieved if necessary.
Project 1d
Modifying Queries
Part 4 of 8
1. With AL1-C3-Dearborn.accdb open, find sales less than $100,000 by completing the
following steps:
a. Double-click SalesMoreThan$100000Query in the Queries group in the Navigation pane.
b. Click the View button in the Views group to switch to Design view.
c. Click in the Criteria row field containing the text >100000 and then edit the text so it
displays as <100000.
Step
1c
d. Click the run button in the results group.
Chapter 3
■
Performing Queries
95
2. Save the query with a new name by completing the following steps:
a. Click the FILe tab, click the Save As option, click
the Save Object As option, and then click the Save
Step
As button.
2b
b. At the Save As dialog box, type
SalesLessThan$100000Query and then press
enter. (See Project 1d query results on page 79.)
c. Print and then close the query.
3. Modify an existing query and find employees with
three weeks of vacation by completing the following
steps:
a. right-click MarToNov2011HiresQuery in the
Queries group in the Navigation pane and
then click Design View at the shortcut menu.
b. Click in the Field row field containing the
text HireDate.
c. Click the down-pointing arrow that displays
at the right side of the field and then click
Vacation at the drop-down list.
Step
d. Select the current text in the Criteria row
3d
field in the Vacation column, type 3 weeks,
and then press enter.
e. Click the run button in the results group.
f. Save and then close the query.
4. rename the query by completing the following steps:
a. right-click MarToNov2011HiresQuery in the Navigation pane and then click Rename
at the shortcut menu.
b. Type RepsWith3WeekVacationsQuery and then press enter. (See Project 1d query
results on page 79.)
c. Open, print and then close the query.
5. Delete the SalesOver$99999Query by right-clicking the query name in the Navigation pane
and then clicking Delete at the shortcut menu. If a message displays asking if you want to
permanently delete the query, click Yes.
Designing Queries with Or and And Criteria
The query design grid contains an or row that you can use to design a query
that instructs Access to display records matching any of the criteria. Multiple
criterion statements on different rows in a query become an Or statement, which
means that any of the criterion can be met for a record to be displayed in the query
results datasheet. For example, to display a list of employees with three weeks of
vacation or four weeks of vacation, type 3 weeks in the Criteria row field for the
Vacation column and then type 4 weeks in the field immediately below 3 weeks in the
or row. Other examples include finding clients that live in Muncie or Lafayette and
finding representatives with quotas of 1 or 2.
you can design a query
that combines And and
Or statements.
96
Access Level 1
■
You can also select records by entering criteria statements into more than
one Criteria field. Multiple criteria all entered in the same row become an And
statement, for which each criterion must be met for Access to select the record. For
example, you can search for clients in the Indianapolis area with sales greater than
$100,000.
Unit 1
Project 1e
Designing Queries with Or and And Criteria
Part 5 of 8
1. With AL1-C3-Dearborn.accdb open, modify an existing query and find employees with
three weeks or four weeks of vacation by completing the following steps:
a. Double-click the RepsWith3WeekVacationsQuery.
b. Click the View button in the Views group to
switch to Design view.
c. Click in the empty field below "3 weeks" in the or
row, type 4 weeks, and then press enter.
d. Click the run button in the results group.
2. Save the query with a new name by completing the
Step
following steps:
1c
a. Click the FILe tab, click the Save As option, click the Save Object As
option, and then click the Save As button.
b. At the Save As dialog box, type RepsWith3Or4WeekVacationsQuery and
then press enter. (See Project 1e query results on page 79.)
c. Print and then close the query.
3. Design a query that finds records of clients in the Indianapolis area with sales over
$100,000 by completing the following steps:
a. Click the CreATe tab and then click the Query Design button.
b. Double-click Clients in the Show Table dialog box.
c. Double-click Sales in the Show Table dialog box and then click the Close button.
d. At the query window, insert the Client field from the Clients field list box in the first Field row
field.
e. Insert the City field from the Clients field list box in the second Field row field.
f. Insert the Sales field from the Sales field list box in the third Field row field.
g. Insert the query criteria by completing the following steps:
1) Click in the Criteria row field in the City column.
2) Type Indianapolis and
then press enter.
3) With the insertion point
positioned in the Criteria
row field in the Sales
column, type >100000
and then press enter.
Step
Step
3g2
3g3
h. Click the run button in the
results group.
i. Save the query and name it SalesOver$100000IndianapolisQuery. (See Project 1e query
results on page 79.)
j. Print and then close the query.
4. Close AL1-C3-Dearborn.accdb.
5. Open AL1-C3-PacTrek.accdb.
6. Design a query that finds products available from supplier numbers 25, 31, and 42 by
completing the following steps:
a. Click the CreATe tab and then click the Query Design button.
b. Double-click Suppliers in the Show Table dialog box.
c. Double-click Products in the Show Table dialog box and then click the Close button.
d. At the query window, insert the SupplierID field from the Suppliers field list box in the
first Field row field.
Chapter 3
■
Performing Queries
97
e. Insert the SupplierName field from the Suppliers field list box in the second Field row
field.
f. Insert the Product field from the Products field list box in the third Field row field.
g. Insert the query criteria by completing the following steps:
1) Click in the Criteria row field in the SupplierID column.
2) Type 25 and then press
the Down Arrow key on
your keyboard. (This makes
Step
6g2
active the field below 25.)
3) Type 31 and then press
the Down Arrow key on
Step
your keyboard. (This makes
6g3
active the field below 31.)
Step
4) Type 42 and then press
6g4
enter.
h. Click the run button in the
results group.
i. Save the query and name it Suppliers25-31-42Query. (See Project 1e query results on
page 79.)
j. Print and then close the query.
7. Design a query that finds ski hats or gloves on order and the numbers ordered by
completing the following steps:
a. Click the CreATe tab and then click the Query Design button.
b. Double-click Orders in the Show Table dialog box.
c. Double-click Suppliers in the Show Table dialog box.
d. Double-click Products in the Show Table dialog box and then click the Close button.
e. At the query window, insert the OrderID field from the Orders field list box in the first Field
row field.
f. Insert the SupplierName field from the Suppliers field list box in the second Field row field.
g. Insert the Product field from the Products field list box in the third Field row field.
h. Insert the UnitsOrdered field from the Orders field list box in the fourth Field row field.
i. Insert the query criteria by completing the following steps:
1) Click in the Criteria row field in the Product column.
2) Type *ski hat* and then
press the Down Arrow key
on your keyboard. (You
Step
7i2
need to type the asterisk
before and after ski hat so
the query will find any
product that includes
the words ski hat in the
description, no matter
what text comes before or
Step
after the words.)
7i3
3) Type *gloves* and then
press enter.
j. Click the run button in the results group.
k. Save the query and name it SkiHatsGlovesOnOrderQuery. (See Project 1e query results on
page 79.)
l. Print and then close the query.
98
Access Level 1
■
Unit 1
8. Design a query that finds boots, sleeping bags, or backpacks and the suppliers that
produce them by completing the following steps:
a. Click the CreATe tab and then click the Query Design button.
b. Double-click Products in the Show Table dialog box.
c. Double-click Suppliers in the Show Table dialog box and then click the Close button.
d. At the query window, insert the ProductID field from the Products field list box in the first
Field row field.
e. Insert the Product field from the Products field list box in the second Field row field.
f. Insert the SupplierName field from the Suppliers field list box in the third Field row field.
g. Insert the query criteria by completing the following steps:
1) Click in the Criteria row field in the Product column.
2) Type *boots* and then press the Down Arrow key on your keyboard.
3) Type *sleeping bag* and then press the Down Arrow key on your keyboard.
4) Type *backpack* and then press enter.
Step
8g2
Step
8g4
Step
8g3
h. Click the run button in the results group.
i. Save the query and name it BootsSleepingBagsBackpacksQuery. (See Project 1e query
results on page 79.)
j. Print and then close the query.
9. Close AL1-C3-PacTrek.accdb.
10. Open AL1-C3-CopperState.accdb.
11. Design a query that finds clients that have only liability auto coverage by completing the
following steps:
a. Click the CreATe tab and then click the Query Design button.
b. Double-click Clients in the Show Table dialog box.
c. Double-click Coverage in the Show Table dialog box and then click the Close button.
d. At the query window, insert the ClientID field from the Clients field list box in the first
Field row field.
e. Insert the FirstName field from the Clients field list box in the second Field row field.
f. Insert the LastName field from the Clients field list box in the third Field row field.
g. Insert the Medical field from the Coverage field list box in the fourth Field row field.
h. Insert the Liability field from the Coverage field list box in the fifth Field row field.
i. Insert the Comprehensive field from the Coverage field list box in the sixth Field row field.
j. Insert the UninsMotorist field from the Coverage field list box in the seventh Field
row field. (You may need to scroll down the Coverage field list box to display the
UninsMotorist field.)
k. Insert the Collision field from the Coverage field list box in the eighth Field row field.
(You may need to scroll down the Coverage field list box to display the Collision field.)
Chapter 3
■
Performing Queries
99
l. Insert the query criteria by completing the following steps:
1) Click in the Criteria row field in the Medical column, type 0, and then press enter.
(Access changes the 0 to False.)
2) With the insertion point in the Liability column, type 1 and then press enter.
(Access changes the 1 to True.)
3) With the insertion point in the Comprehensive column, type 0 and then press enter.
4) With the insertion point in the UninsMotorist column, type 0 and then press enter.
5) With the insertion point in the Collision column, type 0 and then press enter.
Step
11l1
Step
11l2
Step
11l3
Step
11l4
Step
11l5
m. Click the run button in the results group.
n. Save the query and name it ClientsWithOnlyLiabilityQuery. (See Project 1e query results
on page 79.)
o. Print the query in landscape orientation.
p. Close the query.
12. Close AL1-C3-CopperState.accdb.
Performing Queries with the Simple Query Wizard ■ ■ ■ ■
The Simple Query Wizard provided by Access guides you through the steps for
preparing a query. To use this wizard, open the database, click the CreATe tab, and
then click the Query Wizard button in the Queries group. At the New Query dialog
box, make sure Simple Query Wizard is selected in the list box and then click the OK
button. At the first Simple Query Wizard dialog box, shown in Figure 3.3, specify
the table(s) in the Tables/Queries option box. After specifying the table(s), insert the
fields you want included in the query in the Selected Fields list box and then click the
Next button.
Query Wizard
Figure 3.3 First Simple Query Wizard Dialog Box
Specify the table(s)
in the Tables/Queries
option box.
Click the One Field button to insert the
selected field in the Available Fields list
box into the Selected Fields list box.
Click the All Fields button to insert all
of the fields in the Available Fields list
box into the Selected Fields list box.
Insert in the Selected Fields list box the
fields you want included in the query.
100
Access Level 1
■
Unit 1
At the second Simple Query Wizard dialog box, specify whether you want a
detail or summary query and then click the Next button. At the third (and last)
Simple Query Wizard dialog box, shown in Figure 3.4, type a name for the
completed query or accept the name provided by the wizard. At this dialog box,
you can also specify that you want to open the query to view the information or
modify the query design. If you want to extract specific information, be sure to
choose the Modify the query design option. After making any necessary changes,
click the Finish button.
If you do not modify the query design in the last Simple Query Wizard dialog
box, the query displays all records for the fields identified in the first Simple Query
Wizard dialog box. In Project 1f, you will perform a query without modifying the
design, and in Project 1g, you will modify the query design.
Quick Steps
Create a Query with
the Simple Query
Wizard
1. Click Create tab.
2. Click Query Wizard
button.
3. Make sure Simple
Query Wizard is
selected in list box
and then click oK.
4. Follow query steps.
Figure 3.4 Last Simple Query Wizard Dialog Box
Type a name for the query
in this text box or accept the
name provided by the wizard.
Click this option if
you want to modify
the query design.
Project 1f
Performing Queries with the Simple Query Wizard
Part 6 of 8
1. Open AL1-C3-Dearborn.accdb and then use the
Simple Query Wizard to create a query that displays
client names along with sales by completing the
following steps:
a. Click the CreATe tab and then click the Query
Wizard button in the Queries group.
b. At the New Query dialog box, make sure Simple Query
Wizard is selected in the list box and then click OK.
c. At the first Simple Query Wizard dialog box, click
the down-pointing arrow at the right of the Tables/
Queries option box and then click Table: Clients.
Step
1c
Chapter 3
■
Performing Queries
101
d. With ClientID selected in
the Available Fields list box,
click the One Field button
(the button containing the
greater-than symbol, >). This
inserts the ClientID field in
the Selected Fields list box.
e. Click Client in the Available
Fields list box and then click
the One Field button.
f. Click the down-pointing
arrow at the right of the
Tables/Queries option box and
then click Table: Sales.
g. Click Sales in the Available Fields list
box and then click the One Field
button.
h. Click the Next button.
i. At the second Simple Query Wizard
dialog box, click the Next button.
j. At the last Simple Query Wizard
dialog box, select the name in the
What title do you want for your query?
text box, type ClientSalesQuery,
and then press enter.
Step
1j
2.
3.
4.
5.
102
Steps
1d-1e
Step
1f
Step
1g
Step
1h
k. When the results of the query display, print the results.
(See Project 1f query results on page 80.)
Close the query.
Close AL1-C3-Dearborn.accdb.
Open AL1-C3-PacTrek.accdb.
Create a query that displays the products on order, order amounts, and supplier names
by completing the following steps:
a. Click the CreATe tab and then click the Query Wizard button.
b. At the New Query dialog box, make sure Simple Query Wizard is selected in the list box
and then click OK.
Access Level 1
■
Unit 1
Step
c. At the first Simple Query
5c
Wizard dialog box, click the
down-pointing arrow at the
right side of the Tables/Queries
option box and then click
Table: Suppliers.
d. With SupplierID selected in
the Available Fields list box,
click the One Field button.
(This inserts the SupplierID
field in the Selected Fields list
box.)
e. With SupplierName selected
in the Available Fields list box,
click the One Field button.
f. Click the down-pointing
arrow at the right of the Tables/Queries option box and then click Table: Orders.
g. Click ProductID in the Available Fields list box and then click the One Field button.
h. Click Amount in the Available Fields list box and then click the One Field button.
i. Click the Next button.
j. At the second Simple Query Wizard dialog box, click the Next button.
Steps
5d-5e
Steps
5g-5h
Step
5f
Step
5i
k. At the last Simple Query Wizard dialog box, select the text in the What title do you want
for your query? text box, type ProductOrderAmountsQuery, and then press enter.
l. When the results of the query
display, print the results. (See
Project 1f query results on
page 80.)
m. Close the query.
Step
5k
Chapter 3
■
Performing Queries
103
To extract specific information when using the Simple Query Wizard, tell the
wizard that you want to modify the query design. This displays the query window
with the query design grid, where you can insert query criteria.
Project 1g
Performing and Modifying Queries with the Simple Query Wizard
Part 7 of 8
1. With AL1-C3-PacTrek.accdb open, use the Simple Query Wizard to create a query that
displays suppliers outside British Columbia by completing the following steps:
a. Click the CreATe tab and then click the Query Wizard button.
b. At the New Query dialog box,
make sure Simple Query
Step
Wizard is selected and then
1c
click OK.
c. At the first Simple Query
Wizard dialog box, click
the down-pointing arrow at
the right side of the Tables/
Queries option box and
then click Table: Suppliers.
d. Insert the following fields
in the Selected Fields list
Step
box:
1d
SupplierName
StreetAddress
City
Prov/State
PostalCode
e. Click the Next button.
f. At the last Simple Query
Step
1e
Wizard dialog box, select
the current text in the
Step
1f
What title do you want for your
query? text box and then type
SuppliersNotBCQuery.
g. Click the Modify the query design
option and then click the Finish
button.
h. At the query window, complete the
following steps:
1) Click in the Criteria row field
in the Prov/State column in the
query design grid.
2) Type Not BC and then press
enter.
Step
1g
104
Access Level 1
■
Unit 1
i. Specify that the fields are to be sorted in descending order by postal code by completing
the following steps:
1) Click in the Sort row field in the PostalCode column.
2) Click the down-pointing arrow that displays at the right side of the field and then
click Descending.
Step
1i2
j. Click the run button in the results group. (This displays suppliers that are not located
in British Columbia and displays the records sorted by postal code in descending order.
See Project 1g query results on page 80.)
k. Save, print, and then close the query.
2. Close AL1-C3-PacTrek.accdb.
3. Open AL1-C3-Dearborn.accdb.
4. Use the Simple Query Wizard to create a query that displays clients in Muncie by
completing the following steps:
a. Click the CreATe tab and then click the Query Wizard button.
b. At the New Query dialog box, make sure Simple Query Wizard is selected and then click OK.
c. At the first Simple Query Wizard dialog box, click the down-pointing arrow at the right
of the Tables/Queries option box and then click Table: Clients. (You may need to scroll up
the list to display this table.)
d. Insert the following fields in the Selected Fields list box:
Client
StreetAddress
City
State
ZipCode
e. Click the Next button.
f. At the last Simple Query Wizard dialog box, select the current text in the What title do
you want for your query? text box and then type ClientsMuncieQuery.
g. Click the Modify the query design option and then click the Finish button.
h. At the query window, complete the following steps:
1) Click in the Criteria row field in the City column in the query design grid.
2) Type Muncie and then press enter.
Step
4h2
i. Click the run button in the results group. (This displays clients located in Muncie.
See Project 1g query results on page 80.)
j. Save, print, and then close the query.
Chapter 3
■
Performing Queries
105
5. Close AL1-C3-Dearborn.accdb.
6. Open AL1-C3-CopperState.accdb.
7. Use the Simple Query Wizard to display clients that live in Phoenix with claims over $500
by completing the following steps:
a. Click the CreATe tab and then click the Query Wizard button in the Queries group.
b. At the New Query dialog box, make sure Simple Query Wizard is selected in the list box
and then click OK.
c. At the first Simple Query Wizard dialog box, click the down-pointing arrow at the right
of the Tables/Queries option box and then click Table: Clients.
d. Insert the following fields in the Selected Fields list box:
ClientID
FirstName
LastName
StreetAddress
City
State
ZIP
e. Click the down-pointing arrow at the right of the Tables/Queries option box and then
click Table: Claims.
f. With ClaimID selected in the Available Fields list box, click the One Field button.
g. Click AmountOfClaim in the Available Fields list box and then click the One Field button.
h. Click the Next button.
i. At the second Simple Query Wizard dialog box, click the Next button.
j. At the last Simple Query Wizard dialog box, select the current text in the What title do
you want for your query? text box and then type PhoenixClientClaimsOver$500Query.
k. Click the Modify the query design option and then click the Finish button.
l. At the query window, complete the following steps:
1) Click in the Criteria row field in the City column in the query design grid.
2) Type "Phoenix" and then press enter. (Type the quotation marks to tell Access that
this is a criterion, otherwise Access will insert the query name
PhoenixClientClaimsOver$500Query in the Criteria field.)
3) Click in the Criteria row field in the AmountOfClaim column. (You may need to scroll
to the right to display this field.)
4) Type >500 and then press enter.
Step
7l2
Step
7l4
m. Click the run button in the results group. (This displays clients located in Phoenix with
claims greater than $500. See Project 1g query results on page 80.)
n. Save the query, print the query in landscape orientation, and then close the query.
8. Close AL1-C3-CopperState.accdb.
106
Access Level 1
■
Unit 1
Creating Calculated Fields ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■
In a query, you can calculate values from a field by inserting a calculated field
in a Field row field in the query design grid. To insert a calculated field, click in
the Field row field, type the desired field name followed by a colon, and then
type the equation. For example, to determine pension contributions as 3% of an
employee’s annual salary, type PensionContribution:[AnnualSalary]*0.03 in the Field
row field. Use brackets to specify field names and use mathematical operators to
perform the equation. Some basic operators include the plus (+) for addition, the
hyphen (-) for subtraction, the asterisk (*) for multiplication, and the forward
slash (/) for division.
Type a calculated field in the field or in the expression Builder dialog box. To
display the expression Builder dialog box, display the query in Design view, click
in the field where you want the calculated field expression inserted, and then click
the Builder button in the Query Setup group on the QUerY TOOLS DeSIGN
tab. You can type field names in the expression Builder and when you click OK,
the equation is inserted in the field with the correct symbols. For example, you
can type AnnualSalary*0.03 in the expression Builder and when you click OK,
Expr1: [AnnualSalary]*0.03 is inserted in the Criteria row field. If you do not type
a name for the field, Access creates the alias Expr1 for the field name. If you want
a specific name for the field, such as PensionContribution, first type that in the
expression Builder, followed by a colon, and then type the expression.
Project 1h
Creating a Calculated Field in a Query
Builder
Part 8 of 8
1. Open AL1-C3-MRInvestments.accdb and enable the contents.
2. Create a query that displays employer pension contributions at 3% of employees’ annual
salary by completing the following steps:
a. Click the CreATe tab and then click the Query Design button.
b. Double-click Employees in the Show Table dialog box and then click the Close button.
c. At the query window, insert the EmpID field from the Employees field list box in the first
Field row field.
d. Insert the FirstName field in the second Field row field.
e. Insert the LastName field in the third Field row field.
f. Insert the AnnualSalary field in the fourth Field row field.
g. Click in the fifth Field row field.
Step
h. Type PensionContribution:[AnnualSalary]*0.03
2h
and then press enter.
i. Click the run button in the results group.
j. Save the query and name it
PensionContributionsQuery. (See Project 1h
query results on page 80.)
k. Print and then close the query.
3. Modify PensionContributionsQuery and use the expression Builder to write an equation
finding the total amount of annual salary plus a 3% employer pension contribution by
completing the following steps:
a. right-click PensionContributionsQuery in the Queries group in the Navigation pane and
then click Design View at the shortcut menu.
b. Click in the field containing PensionContribution:[AnnualSalary]*0.03.
c. Click the Builder button in the Query Setup group on the QUerY TOOLS DeSIGN tab.
Chapter 3
■
Performing Queries
107
d. In the expression Builder, select the existing expression PensionContribution:
[AnnualSalary]*0.03.
e. Type Salary&Pension: [AnnualSalary]*1.03 and then click OK.
4. Click the run button in the results group.
5. Save the query by completing the
following steps:
a. Click the FILe tab, click the Save
As option, click the Save Object As
option, and then click the Save As
button.
Step
b. At the Save As dialog box, type
3e
Salary&PensionQuery and then click
OK. (See Project 1h query results on
page 80.)
6. Print and then close the query.
7. Close AL1-C3-MRInvestments.accdb.
8. Open AL1-C3-PacTrek.accdb.
9. Create a query that displays orders and total order amounts by completing the following steps:
a. Click the CreATe tab and then click the Query Design button.
b. Double-click Products in the Show Table dialog box.
c. Double-click Orders in the Show Table dialog box and then click the Close button.
d. At the query window, insert the Product field from the Products field list box in the first
Field row field.
e. Insert the OrderID field from the Orders field list box in the second Field row field.
f. Insert the UnitsOrdered field from the Orders field list box in the third Field row field.
g. Insert the Amount field from the Orders field list box in the fourth Field row field.
h. Click in the fifth Field row field.
i. Click the Builder button in the Query Setup group on the
Step
9j
QUerY TOOLS DeSIGN tab.
j. Type Total:Amount*UnitsOrdered
in the expression Builder and then
click OK.
k. Click the run button in the results
group.
l. Adjust the width of the columns to
fit the longest entries.
m. Save the query and name it UnitsOrderedTotalQuery. (See Project 1h query results on
page 80.)
n. Print and then close the query.
Project 2 Create Aggregate Functions, Crosstab, Find
6 Parts
Duplicates, and Find Unmatched Queries
You will create an aggregate functions query that determines the total, average,
minimum, and maximum order amounts and then calculate total and average
order amounts grouped by supplier. You will also use the Crosstab, Find
Duplicates, and Find Unmatched query wizards to design queries.
108
Access Level 1
■
Unit 1
Designing Queries with Aggregate Functions ■ ■ ■ ■ ■ ■ ■ ■
You can include an aggregate function—such as Sum, Avg, Min, Max, or
Count—in a query to calculate statistics from numeric field values of all the
records in the table. When an aggregate function is used, Access displays one row
in the query results datasheet with the formula result for the function used. For
example, in a table with a numeric field containing annual salary amounts, you
can use the Sum function to calculate the total of all salary amount values.
To display the aggregate function list, click the Totals button in the Show/Hide
group on the QUerY TOOLS DeSIGN tab. Access adds a Total row to the design
grid with a drop-down list from which you select the desired function. Access also
inserts the words Group By in the Total row field. Click the down-pointing arrow
and then click the desired aggregate function from the drop-down list. In Project 2a,
Step 1, you will create a query in Design view and use aggregate functions to find
the total of all sales, average sales amount, maximum and minimum sales, and total
number of sales. The completed query will display as shown in Figure 3.5. Access
automatically determines the column heading names.
Quick Steps
Design a Query
with an Aggregate
Function
1. at query window,
click totals button.
2. Click down-pointing
arrow in Total row
field.
3. Click desired
aggregate function.
Totals
Figure 3.5 Query Results for Project 2a, Step 1
Access automatically
determines the column
heading names.
Project 2a
The aggregate functions
calculate the order amounts
in the Amount column in the
Orders table.
Using Aggregate Functions in Queries
Part 1 of 6
1. With AL1-C3-PacTrek.accdb open, create a query with aggregate functions that
determines total, average, maximum, and minimum order amounts, as well as the total
number of orders, by completing the following steps:
a. Click the CreATe tab and then click the Query Design button.
b. At the Show Table dialog box, make sure
Step
Orders is selected in the
1c
list box, click the Add
button, and then click
the Close button.
c. Insert the Amount field
in the first, second,
third, fourth, and fifth
Field row fields. (You
may need to scroll down the Orders field list
box to display the Amount field.)
d. Click the Totals button in the Show/Hide
group on the QUerY TOOLS DeSIGN
tab. (This adds a Total row to the design grid
Step
between Table and Sort with the default option
1d
of Group By.)
Chapter 3
■
Performing Queries
109
e. Specify a Sum function for the first Total row
Step
1e3
field by completing the following steps:
1) Click in the first Total row field.
2) Click the down-pointing arrow that displays
Step
at the right side of the field.
1e2
3) Click Sum at the drop-down list.
f. Complete steps similar to those in Step 1e to
insert Avg in the second Total row field.
g. Complete steps similar to those in Step 1e to
insert Max in the third Total row field.
h. Complete steps similar to those in Step 1e to
insert Min in the fourth Total row field.
i. Complete steps similar to those in Step 1e to insert Count in the fifth Total row field.
Step
1f
Step
1g
Step
1h
Step
1i
j. Click the run button in the results group. (Notice the headings that Access assigns
to the columns.)
k. Automatically adjust the widths of the columns.
l. Save the query and name it AmountsQuery. (See Project 2a query results on page 81.)
m. Print and then close the query.
2. Close AL1-C3-PacTrek.accdb.
3. Open AL1-C3-CopperState.accdb.
4. Create a query with aggregate functions that determines total, average, maximum, and
minimum claim amounts by completing the following steps:
a. Click the CreATe tab and then click the Query Design button.
b. At the Show Table dialog box, double-click Claims.
c. Click the Close button to close the Show Table dialog box.
d. Insert the AmountOfClaim field in the first, second, third, and fourth Field row fields.
e. Click the Totals button in the Show/Hide group.
f. Click in the first Total row field, click the down-pointing arrow that displays at the right
side of the field, and then click Sum at the drop-down list.
Step
4f
110
Access Level 1
■
Unit 1
g. Click in the second Total row field, click the down-pointing arrow, and then click Avg at
the drop-down list.
h. Click in the third Total row field, click the down-pointing arrow, and then click Max at
the drop-down list.
i. Click in the fourth Total row field, click the down-pointing arrow, and then click Min at
the drop-down list.
j. Click the run button in the results group. (Notice the headings that Access chooses for
the columns.)
k. Automatically adjust the widths of the columns.
l. Save the query and name it ClaimAmountsQuery. (See Project 2a query results on
page 81.)
m. Print the query in landscape orientation and then close the query.
Using the Group By option in the Total field, you can add a field to the
query on which you want Access to group records for statistical calculations.
For example, to calculate the total of all orders for a specific supplier, add the
SupplierID field to the design grid with the Total field set to Group By. In Project
2b, Step 1, you will create a query in Design view and use aggregate functions
to find the total of all order amounts and the average order amounts grouped by
supplier number.
Project 2b
Using Aggregate Functions and Grouping Records
Part 2 of 6
1. With AL1-C3-CopperState.accdb open, determine the sum and average of client claims
by completing the following steps:
a. Click the CreATe tab and then click the Query Design button.
b. At the Show Table dialog box, double-click Clients in the list box.
c. Double-click Claims in the list box and then click the Close button.
d. Insert the ClientID field from the Clients field list box to the first Field row field.
e. Insert the AmountOfClaim field from the Claims field list box to the second Field row
field.
f. Insert the AmountOfClaim field from the Claims field list box to the third Field row field.
g. Click the Totals button in the Show/Hide group.
h. Click in the second Total row field, click
the down-pointing arrow, and then click
Sum at the drop-down list.
i. Click in the third Total row field, click the
down-pointing arrow, and then click Avg at
the drop-down list.
j. Make sure Group By displays in the first
Step
Step
Step
1j
1h
1i
Total row field.
k. Click the run button in the results group.
l. Automatically adjust column widths.
m. Save the query and name it SumAvgClaimAmountsQuery. (See Project 2b query results on
page 81.)
n. Print and then close the query.
2. Close AL1-C3-CopperState.accdb.
Chapter 3
■
Performing Queries
111
3. Open AL1-C3-PacTrek.accdb.
4. Determine the total and average order amounts for each supplier by completing the
following steps:
a. Click the CreATe tab and then click the Query Design button.
b. At the Show Table dialog box, make sure Orders is selected in the list box and then click
the Add button.
c. Click Suppliers in the list box, click the Add button, and then click the Close button.
d. Insert the Amount field from the Orders field list box to the first Field row field. (You may
need to scroll down the Orders field list box to display the Amount field.)
e. Insert the Amount field from the Orders field list box to the second Field row field.
f. Insert the SupplierID field from the Suppliers field list box to the third Field row field.
g. Insert the SupplierName field from the Suppliers field list box to the fourth Field row field.
h. Click the Totals button in
the Show/Hide group.
i. Click in the first Total row
field, click the down-pointing
arrow, and then click Sum at
the drop-down list.
j. Click in the second Total row
Step
Step
Step
field, click the down-pointing
4i
4j
4k
arrow, and then click Avg at
the drop-down list.
k. Make sure Group By displays
in the third and fourth Total row fields.
l. Click the run button in the results group.
m. Automatically adjust column widths.
n. Save the query and name it SupplierAmountsQuery. (See Project 2b query results on page 81.)
o. Print and then close the query.
Creating Crosstab Queries ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■
Quick Steps
Create a Crosstab
Query
1. Click Create tab.
2. Click Query Wizard
button.
3. Double-click Crosstab
Query Wizard.
4. Complete wizard
steps.
112
Access Level 1
■
A crosstab query calculates aggregate functions, such as Sum and Avg, in which
field values are grouped by two fields. A wizard is included that guides you
through the steps to create the query. The first field selected causes one row to
display in the query results datasheet for each group. The second field selected
displays one column in the query results datasheet for each group. A third field
is specified that is the numeric field to be summarized. The intersection of
each row and column holds a value that is the result of the specified aggregate
function for the designated row and column group.
Create a crosstab query from fields in one table. If you want to include fields
from more than one table, you must first create a query containing the desired
fields, and then create the crosstab query. For example, in Project 2c, Step 2, you
will create a new query that contains fields from each of the three tables in AL1-C3PacTrek.accdb. Using this query, you will use the Crosstab Query Wizard to create
a query that summarizes the order amounts by supplier name and product ordered.
Figure 3.6 displays the results of that crosstab query. The first column displays the
supplier names, the second column displays the total amount for each supplier, and
the remaining columns display the amounts by suppliers for specific items.
Unit 1
Figure 3.6 Crosstab Query Results for Project 2c, Step 2
Order amounts are grouped
by supplier name and
individual product.
Project 2c
Creating Crosstab Queries
Part 3 of 6
1. With AL1-C3-PacTrek.accdb open, create a query containing fields from the three tables
by completing the following steps:
a. Click the CreATe tab and then click the Query Design button.
b. At the Show Table dialog box with Orders selected in the list box, click the Add button.
c. Double-click Products in the list box.
d. Double-click Suppliers in the list box and then click the Close button.
e. Insert the following fields to the specified Field row fields:
1) From the Orders field list box, insert the ProductID field in the first Field row field.
2) From the Products field list box, insert the Product field in the second Field row field.
3) From the Orders field list box, insert the UnitsOrdered field in the third Field row field.
4) From the Orders field list box, insert the Amount field in the fourth Field row field.
5) From the Suppliers field list box, insert the SupplierName field in the fifth Field row
field.
6) From the Orders field list box, insert the OrderDate field in the sixth Field row field.
Step
1e
f. Click the run button to run the query.
g. Save the query and name it ItemsOrderedQuery.
h. Close the query.
Chapter 3
■
Performing Queries
113
2. Create a crosstab query that
summarizes the orders by supplier
Step
name and by product ordered by
2b
completing the following steps:
a. Click the CreATe tab
and then click the Query
Wizard button.
b. At the New Query dialog
box, double-click Crosstab
Step
Query Wizard in the list
2c
box.
c. At the first Crosstab
Query Wizard dialog box,
click the Queries option in
the View section and then
click Query: ItemsOrderedQuery
in the list box.
d. Click the Next button.
Step
e. At the second Crosstab Query
2e
Wizard dialog box, click
SupplierName in the Available
Fields list box and then
click the One Field button.
(This inserts SupplierName
in the Selected Fields list box
and specifies that you want
SupplierName for the row
Step
headings.)
2g
f. Click the Next button.
g. At the third Crosstab Query
Wizard dialog box, click
Product in the list box. (This
specifies that you want Product for
the column headings.)
h. Click the Next button.
i. At the fourth Crosstab Query
Wizard dialog box, click Amount
Step
2i
in the Fields list box and then click
Sum in the Functions list box.
j. Click the Next button.
k. At the fifth Crosstab Query Wizard
Step
dialog box, select the current text
2k
in the What do you want to name
your query? text box and then type
OrdersBySupplierByProductQuery.
l. Click the Finish button. (See Project
2c query results on page 81.)
3. Display the query in Print Preview, change the orientation to landscape, change the
left and right margins to 0.5 inch, and then print the query. (The query will print on
four pages.)
114
Access Level 1
■
Unit 1
4.Close the query.
5.Close AL1-C3-PacTrek.accdb.
6.Open AL1-C3-CopperState.accdb.
7.Create a crosstab query from fields in one table that summarizes clients’ claims by
completing the following steps:
a.Click the Create tab and then click the Query Wizard button.
b.At the New Query dialog box, double-click Crosstab Query Wizard in the list box.
c.At the first Crosstab Query Wizard dialog box, click Table: Claims in the list box.
d.Click the Next button.
e.At the second Crosstab Query Wizard dialog box, click the One Field button. (This inserts
the ClaimID field in the Selected Fields list box.)
f. Click the Next button.
g.At the third Crosstab Query Wizard dialog, make sure ClientID is selected in the list box
and then click the Next button.
h.At the fourth Crosstab Query Wizard dialog box, click AmountOfClaim in the Fields list
box and click Sum in the Functions list box.
i. Click the Next button.
j. At the fifth Crosstab Query Wizard dialog box, select the current text in the What do you
want to name your query? text box and then type ClaimsByClaimIDByClientIDQuery.
k.Click the Finish button. (See Project 2c query results on page 81.)
8.Change the orientation to landscape and then print the query. The query will print on two pages.
9.Close the query.
10. Close AL1-C3-CopperState.accdb.
Creating Find Duplicates Queries ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■
Use a find duplicates query to search a specified table or query for duplicate field
values within a designated field or fields. Create this type of query, for example,
if you suspect a record (such as a product record) has inadvertently been entered
twice (perhaps under two different product numbers). A find duplicates query
has many applications. Here are a few other examples of how you can use a find
duplicates query:
• In an orders table, find records with the same customer number so you can
identify loyal customers.
• In a customers table, find records with the same last name and mailing
address so you can send only one mailing to a household and save on
printing and postage costs.
• In an employee expenses table, find records with the same employee
number so you can see which employee is submitting the most claims.
Access provides the Find Duplicates Query Wizard to build the query based
on the selections made in a series of dialog boxes. To use this wizard, open the
desired database, click the Create tab, and then click the Query Wizard button.
At the New Query dialog box, double-click Find Duplicates Query Wizard in the list
box and then complete the steps provided by the wizard.
Quick Steps
Create a Find
Duplicates Query
1.Click Create tab.
2.Click Query Wizard
button.
3.Double-click Find
Duplicates Query
Wizard.
4.Complete wizard
steps.
In Project 2d, you will assume that you have been asked to update the address
for a supplier in AL1-C3-PacTrek.accdb. Instead of updating the address, you
create a new record. You will then use the Find Duplicates Query Wizard to find
duplicate field values in the Suppliers table.
Chapter 3 ■ Performing Queries
115
Project 2d
Creating a Find Duplicates Query
Part 4 of 6
1. Open AL1-C3-PacTrek.accdb and then open the Suppliers table.
2. Add the following record to the table:
SupplierID#
29
SupplierName Langley Corporation
StreetAddress
1248 Larson Avenue
City
Burnaby
Prov/State
BC
PostalCode
V5V 9K2
EmailAddress
lc@emcp.net
Telephone
(604) 555-1200
3. Close the Suppliers table.
4. Use the Find Duplicates Query Wizard to find any duplicate supplier names by completing
the following steps:
a. Click the CreATe tab and then click the Query Wizard button.
b. At the New Query dialog box, double-click Find Duplicates Query Wizard.
c. At the first wizard dialog box,
click Table: Suppliers in the list
box.
d. Click the Next button.
e. At the second wizard dialog
Step
box, click SupplierName in the
4c
Available fields list box and then
click the One Field button.
(This moves the SupplierName
field to the Duplicate-value fields list box.)
f. Click the Next button.
g. At the third wizard dialog box, click the All Fields
button (the button containing the two greaterthan symbols, >>). This moves all the fields to
the Additional query fields list box. You are doing
this because if you find a duplicate supplier name,
you want to view all the fields to determine which
record is accurate.
h. Click the Next button.
Step
i. At the fourth (and last) wizard dialog box, type
4e
DuplicateSuppliersQuery in the What do you want
to name your query? text box.
j. Click the Finish button. (See
Project 2d query results on
page 81.)
k. Change the orientation to
landscape and then print the
query.
Step
5. As you look at the query results,
4i
you realize that an inaccurate record was entered for the Langley
Corporation, so you decide to delete one of the records. To do this,
complete the following steps:
116
Access Level 1
■
Unit 1
a. With the query open, click in the record
Step
selector bar next to the record with a supplier
5b
ID of 29. (This selects the entire row.)
b. Click the HOMe
tab and then click
the Delete button
in the records
group.
c. At the message
asking you to
Step
confirm, click the
5a
Yes button.
d. Close the query.
6. Change the street address for Langley Corporation by completing the following steps:
a. Open the Suppliers table in Datasheet view.
b. Change the address for Langley Corporation from 805 First Avenue to 1248 Larson Avenue.
Leave the other fields as displayed.
c. Close the Suppliers table.
In Project 2d, you used the Find Duplicates Query Wizard to find records
containing the same field.In Project 2e, you will use the Find Duplicates Query
Wizard to find information on the suppliers you order from the most. You could
use this information to negotiate for better prices or to ask for discounts.
Project 2e
Finding Duplicate Orders
Part 5 of 6
1. With AL1-C3-PacTrek.accdb open, create a query with the following fields (in the order
shown) from the specified tables:
SupplierID
SupplierName
ProductID
Product
Suppliers table
Suppliers table
Orders table
Products table
2. run the query.
3. Save the query with the name SupplierOrdersQuery and then close the query.
4. Use the Find Duplicates Query Wizard to
find the suppliers you order from the most
by completing the following steps:
a. Click the CreATe tab and then click
the Query Wizard button.
b. At the New Query dialog box, doubleclick Find Duplicates Query Wizard.
c. At the first wizard dialog box, click the
Queries option in the View section and
then click Query: SupplierOrdersQuery.
Step
4c
(You may need to scroll down the list to
display this query.)
Chapter 3
■
Performing Queries
117
d. Click the Next button.
e. At the second wizard dialog box, click SupplierName in the Available fields list box and
then click the One Field button.
f. Click the Next button.
g. At the third wizard dialog box, click the Next button.
h. At the fourth (and last) wizard dialog
box, type SupplierOrdersCountQuery
in the What do you want to name your
query? text box.
i. Click the Finish button.
Step
j. Adjust the widths of the columns to fit
4h
the longest entries.
k. Print the query. (See Project 2e query results on page 82.)
5. Close the query.
Creating Find Unmatched Queries ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■
Quick Steps
Create a Find
Unmatched Query
1. Click Create tab.
2. Click Query Wizard
button.
3. Double-click Find
Unmatched Query
Wizard.
4. Complete wizard
steps.
Create a find unmatched query to compare two tables and produce a list of the
records in one table that have no matching record in the other table. This type of
query is useful to produce lists such as customers who have never placed orders
and invoices that have no records of payment. Access provides the Find Unmatched
Query Wizard to build the select query by guiding you through a series of
dialog boxes.
In Project 2f, you will use the Find Unmatched Query Wizard to find all
of the products that have no units on order. This information is helpful in
identifying which products are not selling and might need to be discontinued or
returned. To use the Find Unmatched Query Wizard, click the CreATe tab and
then click the Query Wizard button in the Queries group. At the New Query
dialog box, double-click Find Unmatched Query Wizard in the list box and then
follow the wizard steps.
Project 2f
Creating a Find Unmatched Query
Part 6 of 6
1. With AL1-C3-PacTrek.accdb open, use the Find Unmatched Query Wizard to find all
products that do not have units on order by completing the following steps:
a. Click the CreATe tab and then click the Query Wizard button.
b. At the New Query dialog box, double-click Find
Unmatched Query Wizard.
c. At the first wizard dialog box, click Table: Products in
the list box. (This is the table containing the fields
you want to see in the query results.)
d. Click the Next button.
e. At the second wizard dialog box, make sure Table:
Orders is selected in the list box. (This is the table
containing the related records.)
Step
f. Click the Next button.
1c
118
Access Level 1
■
Unit 1
g. At the third wizard dialog
box, make sure ProductID is
selected in both the Fields in
'Products' list box and in the
Fields in 'Orders' list box.
h. Click the Next button.
i. At the fourth wizard dialog
box, click the All Fields button
to move all of the fields from
the Available fields list box to
the Selected fields list box.
j. Click the Next button.
k. At the fifth wizard dialog box,
Step
click the Finish button. (Let
1g
the wizard determine the query
name: Products Without Matching
Orders. See Project 2f query results
on page 82.)
2. Print the query in landscape orientation and then close the query.
3. Close AL1-C3-PacTrek.accdb.
Chapter Summary
■
■
■
■
One of the most important uses of a database is to select the information needed
to answer questions and make decisions. Data can be extracted from an Access
database by performing a query, which can be accomplished by designing a query
or using a query wizard.
Designing a query consists of identifying the table, the field or fields from which
the data will be drawn, and the criteria for selecting the data.
In designing a query, type the criterion (or criteria) for extracting the specific
data. Access inserts any necessary symbols in the criterion when the enter key is
pressed.
In a criterion, quotation marks surround field values and pound symbols (#)
surround dates. Use the asterisk (*) as a wildcard character.
■
You can perform a query on fields within one table or on fields from related tables.
■
When designing a query, you can specify the sort order of a field or fields.
■
You can modify an existing query and use it for a new purpose.
■
■
■
■
enter a criterion in the or row in the query design grid to instruct Access to display
records that match any of the criteria.
Multiple criteria entered in the Criteria row in the query design grid become an
And statement, where each criterion must be met for Access to select the record.
The Simple Query Wizard guides you through the steps for preparing a query.
You can modify a query you create with the wizard.
You can insert a calculated field in a Field row field when designing a query.
Chapter 3
■
Performing Queries
119
■
■
■
■
■
Include an aggregate function (such as Sum, Avg, Min, Max, or Count) to calculate
statistics from numeric field values. Click the Totals button in the Show/Hide
group on the QUerY TOOLS DeSIGN tab to display the aggregate function list.
Use the Group By option in the Total row field to add a field to a query on which
you want Access to group records for statistical calculations.
Create a crosstab query to calculate aggregate functions (such as Sum and Avg),
in which fields are grouped by two. Create a crosstab query from fields in one
table. If you want to include fields from more than one table, create a query first
and then create the crosstab query.
Use a find duplicates query to search a specified table for duplicate field values
within a designated field or fields.
Create a find unmatched query to compare two tables and produce a list of the
Commands Review
FEATURE
120
RIBBON TAB, GROUP
add Total row to query design
QUERY TOOLS DESIGN, Show/Hide
Crosstab Query Wizard
CREATE, Queries
Find Duplicates Query Wizard
CREATE, Queries
Find Unmatched Query Wizard
CREATE, Queries
New Query dialog box
CREATE, Queries
query results
QUERY TOOLS DESIGN, Results
query window
CREATE, Queries
Simple Query Wizard
CREATE, Queries
Access Level 1
■
Unit 1
BUTTON, OPTION
, Crosstab Query Wizard
, Find Duplicates Query Wizard
, Find Unmatched Query Wizard
, Simple Query Wizard
Concepts Check
Test Your Knowledge
records in one table that have no matching records in the other related table.
Completion: In the space provided at the right, indicate the correct term, symbol, or command.
1. The Query Design button is located in the Queries group on
this tab.
_____________________
2. Click the Query Design button and the query window displays
with this dialog box open.
_____________________
3. To establish a criterion for a query, click in this row in
the column containing the desired field name and then type
the criterion.
_____________________
4. This is the term used for the results of the query.
_____________________
5. This is the symbol Access automatically inserts before and after
a date when writing a criterion for the query.
_____________________
6. Use this symbol to indicate a wildcard character when writing
a query criterion.
_____________________
7. This is the criterion you would type to return field values
greater than $500.
_____________________
8. This is the criterion you would type to return field values that
begin with the letter L.
_____________________
9. This is the criterion you would type to return field values that
are not in Oregon.
_____________________
10. You can sort a field in a query in ascending order or in this order.
_____________________
11. Multiple criteria entered in the Criteria row in the query design
grid become this type of statement.
_____________________
12. This wizard guides you through the steps for preparing a query.
_____________________
13. This type of query calculates aggregate functions, in which
field values are grouped by two fields.
_____________________
14. Use this type of query to compare two tables and produce a
list of the records in one table that have no matching records
in the other table.
_____________________
Chapter 3
■
Performing Queries
121
Skills Check
Assess Your Performance
Assessment
1
122
Access Level 1
Design Queries in a legal serViCes DataBase
Grade It
1. Display the Open dialog box with the AL1C3 folder
on your storage medium the active folder.
2. Open AL1-C3-WarrenLegal.accdb and enable the contents.
3. Design a query that extracts information from the Billing table with the
following specifications:
a. Include the fields BillingID, ClientID, and CategoryID in the query.
b. extract those records with the SE category. (Type "SE" in the Criteria row
field in the CategoryID column. You need to type the quotation marks to tell
Access that Se is a criterion and not a built-in Access function.)
c. Save the query and name it SECategoryBillingQuery.
d. Print and then close the query.
4. Design a query that extracts information from the Billing table with the
following specifications:
a. Include the fields BillingID, ClientID, and Date.
b. extract those records in the Date field with dates between 6/8/2015
and 6/15/2015.
c. Save the query and name it June8-15BillingQuery.
d. Print and then close the query.
5. Design a query that extracts information from the Clients table with the
following specifications:
a. Include the fields FirstName, LastName, and City.
b. extract those records with cities other than Kent in the City field.
c. Save the query and name it ClientsNotInKentQuery.
d. Print and then close the query.
6. Design a query that extracts information from two tables with the following
specifications:
a. Include the fields BillingID, ClientID, Date, and RateID from the Billing
table.
b. Include the field Rate from the rates table.
c. extract those records with rate IDs greater than 2.
d. Save the query and name it RateIDGreaterThan2Query.
e. Print and then close the query.
7. Design a query that extracts information from three tables with the following
specifications:
a. Include the fields AttorneyID, FName, and LName from the Attorneys table.
b. Include the fields FirstName and LastName from the Clients table.
c. Include the fields Date and Hours from the Billing table.
d. extract those records with an attorney ID of 12.
e. Save the query and name it Attorney12Query.
f. Print and then close the query.
8. Design a query that extracts information from four tables with the following
specifications:
a. Include the fields AttorneyID, FName, and LName from the Attorneys table.
b. Include the field Category from the Categories table.
c. Include the fields RateID and Rate from the rates table.
■
Unit 1
d. Include the fields Date and Hours from the Billing table.
e. extract those records with an attorney ID of 17 and a rate ID of 4.
f. Save the query and name it Attorney17RateID4Query.
g. Print the query in landscape orientation and then close the query.
9. Open the Attorney17rateID4Query query, click the View button on the
HOMe tab to display the query in Design view, and then modify the query
so it displays records with a rate ID of 4 and attorney IDs of 17 and 19 by
making the following changes:
a. Click below the field value "17 " in the AttorneyID column and then type 19.
b. Click below the field value "4" in the RateID column, type 4, and then press
enter.
c. run the query.
d. Save the query with the new name Attorney17&19RateID4Query. Hint: Do
this at the Save As dialog box. Display this dialog box by clicking the FILE
tab, clicking the Save As option, clicking the Save Object As option, and
then clicking the Save As button.
e. Print the query in landscape orientation and then close the query.
Assessment
2
use tHe siMple Query WiZarD anD Design Queries
Grade It
1. With AL1-C3-WarrenLegal.accdb open, use the Simple
Query Wizard to extract specific information from three
tables with the following specifications:
a. At the first Simple Query Wizard dialog box, include the following fields:
From Attorneys table: AttorneyID, FName, and LName
From Categories table: Category
From Billing table: Hours
b. At the second Simple Query Wizard dialog box, click Next.
c. At the third Simple Query Wizard dialog box, click the Modify the query
design option and then click the Finish button.
d. At the query window, insert 14 in the Criteria row field in the AttorneyID
column.
e. run the query.
f. Save the query with the default name.
g. Print and then close the query.
2. Create a query in Design view with the Billing table with the following specifications:
a. Insert the Hours field from the Billing field list box to the first, second, third,
and fourth Field row fields.
b. Click the Totals button in the Show/Hide group.
c. Insert Sum in the first Total row field.
d. Insert Min in the second Total row field.
e. Insert Max in the third Total row field.
f. Insert Count in the fourth Total row field.
g. run the query.
h. Automatically adjust the widths of the columns.
i. Save the query and name it HoursAmountQuery.
j. Print and then close the query.
3. Create a query in Design view with the following specifications:
a. Add the Attorneys table and Billing table to the query window.
b. Insert the FName field from the Attorneys field list box to the first Field row field.
c. Insert the LName field from the Attorneys field list box to the second Field row
field.
Chapter 3
■
Performing Queries
123
d. Insert the AttorneyID field from the Billing field list box to the third Field
row field. (You will need to scroll down the Billing field list box to display
the AttorneyID field.)
e. Insert the Hours field from the Billing field list box to the fourth Field row field.
f. Click the Totals button in the Show/Hide group.
g. Insert Sum in the fourth Total row field in the Hours column.
h. run the query.
i. Save the query and name it AttorneyHoursQuery.
j. Print and then close the query.
4. Create a query in Design view with the following specifications:
a. Add the Attorneys, Clients, Categories, and Billing tables to the query
window.
b. Insert the AttorneyID field from the Attorneys field list box to the first Field
row field.
c. Insert the ClientID field from the Clients field list box to the second Field
row field.
d. Insert the Category field from the Categories field list box to the third Field
row field.
e. Insert the Hours field from the Billing field list box to the fourth Field row
field.
f. run the query.
g. Save the query and name it AttorneyClientHours.
h. Print and then close the query.
Assessment
3
Create a CrosstaB Query anD use tHe FinD DupliCates
anD FinD unMatCHeD Query WiZarDs
Grade It
1. With AL1-C3-WarrenLegal.accdb open, create a crosstab query
that summarizes the hours by attorney by category with the following
specifications:
a. At the first Crosstab Query Wizard dialog box, click the Queries option in
the View section and then click Query: AttorneyClientHours in the list box.
b. At the second Crosstab Query Wizard dialog box with AttorneyID selected
in the Available Fields list box, click the One Field button.
c. At the third Crosstab Query Wizard dialog box, click Category in the list
box.
d. At the fourth Crosstab Query Wizard dialog box, click Hours in the Fields
list box and click Sum in the Functions list box.
e. At the fifth Crosstab Query Wizard dialog box, select the current name
in the What do you want to name your query? text box and then type
HoursByAttorneyByCategory.
f. Display the query in Print Preview, change to landscape orientation, change
the left and right margins to 0.5 inch, and then print the query.
g. Close the query.
2. Use the Find Duplicates Query Wizard to find those clients with the same last
name with the following specifications:
a. At the first wizard dialog box, click Table: Clients in the list box.
b. At the second wizard dialog box, click LastName in the Available fields list
box and then click the One Field button.
c. At the third wizard dialog box, click the All Fields button.
124
Access Level 1
■
Unit 1
d.At the fourth wizard dialog box, name the query DuplicateLastNamesQuery.
e.Print the query in landscape orientation and then close the query.
3.Use the Find Unmatched Query Wizard to find all clients who do not have
any billing hours with the following specifications:
a.At the first wizard dialog box, click Table: Clients in the list box.
b.At the second wizard dialog box, click Table: Billing in the list box.
c.At the third wizard dialog box, make sure ClientID is selected in both the
Fields in 'Clients' list box and in the Fields in 'Billing' list box.
d.At the fourth wizard dialog box, click the All Fields button to move all fields
from the Available fields list box to the Selected fields list box.
e.At the fifth wizard dialog box, click the Finish button. (Let the wizard
determine the query name: Clients Without Matching Billing.)
4.Print the query in landscape orientation and then close the query.
Assessment
4
Design and Hide Fields in a Query
1.You can use the check boxes in the query design grid Show row to show or
hide fields in the query. Experiment with these check boxes and then with
AL1-C3-WarrenLegal.accdb open design the following query:
a.At the Show Table dialog box, add the Clients table, the Billing table, and
the Rates table.
b.At the query window, insert the following fields in Field row fields:
Clients table: FirstName
LastName
Billing table:Hours
Rates table: Rate
c.Insert in the fifth Field row field the calculated field Total:[Hours]*[Rate].
d.Hide the Hours and Rate fields.
e.Run the query.
f. Save the query and name it ClientBillingQuery.
g.Print and then close the query. (The query will print on two pages.)
2.Close AL1-C3-WarrenLegal.accdb.
Visual Benchmark
Demonstrate Your Proficiency
Creating Relationships and Designing a Query
1.Open AL1-C3-MRInvestments.accdb from the AL1C3 folder on your
storage medium and, if necessary, enable the contents.
2.Display the Relationships window and then create the relationships shown
in Figure 3.7. Enforce referential integrity and cascade fields and records.
(The tables in Figure 3.7 have been rearranged in the Relationships window
so you have a better view of the relationships.)
3.Save and then print the relationships.
4.Close the relationship report without saving it and then close the
Relationships window.
5.Design the query shown in Figure 3.8.
Chapter 3 ■ Performing Queries
125
6. run the query.
7. Save the query with an appropriate name and then print the query.
8. Close AL1-C3-MRInvestments.accdb.
Figure 3.7 Visual Benchmark Relationships Window
Figure 3.8 Visual Benchmark Query
126
Access Level 1
■
Unit 1
Case Study
Part
1
Apply Your Skills
You work for the Skyline Restaurant in Fort Myers, Florida. Your supervisor
is reviewing the restaurant’s operations and has asked for a number of query
reports. Before running the queries, you realize that the tables in the restaurant
database, AL1-C3-Skyline.accdb, are not related. Open AL1-C3-Skyline.
accdb, enable the contents, and then create the following relationships (enforce
referential integrity and cascade fields and records):
Field Name “One” Table “Many” Table
EmployeeIDEmployees Banquets
ItemID InventoryOrders
SupplierIDSuppliers Orders
SupplierIDSuppliers Inventory
EventIDEvents Banquets
Save and then print the relationships. Close the relationship report without saving
it and then close the Relationships window.
Part
2
As part of the review of the restaurant’s records, your supervisor has asked you for
the following information. Create a separate query for each bulleted item listed
below and save, name, and print the queries. (You determine the query names.)
• Suppliers in Fort Myers: From the Suppliers table, include the supplier
identification number, supplier name, city, and telephone number.
• Suppliers not located in Fort Myers: From the Suppliers table, include
the supplier identification number and supplier name, city, and telephone
number.
•Employees hired in 2012: From the Employees table, include the employee
identification number, first and last names, and hire date.
•Employees signed up for health insurance: From the Employees table,
include employee first and last names and the health insurance field.
• Wedding receptions (event identification "WR") booked in the banquet
room: From the Banquets table, include the reservation identification
number; reservation date; event identification; and first name, last name,
and telephone number of the person making the reservation.
• Banquet reservations between 6/14/2015 and 6/30/2015 and the employees
making the reservations: From the Banquets table, include the reservation
identification number; reservation date; and first name, last name,
and telephone number of the person making the reservation; from the
Employees table include the employee first and last names.
• Banquet reservations that have not been confirmed and the employees
making the reservations: From the Banquets table, include the reservation
identification number; reservation date; confirmed field; and first and last
names of person making the reservation; from the Employees table, include
employee first and last names.
• Banquet room reserved by someone whose last name begins with the letters
Wie: From the Employees table, include the first and last names of the
employee who booked the reservation; from the Banquets table, include
the first and last names and telephone number of the person making the
reservation.
Chapter 3 ■ Performing Queries
127
Part
3
• A query that inserts a calculated field that multiplies the number of
units ordered by the unit price for all orders for supplier number 2: From
the Orders table, include the order identification number, the supplier
identification number, the units ordered, and the unit price; from the
Inventory table, include the item field.
Use the Find Duplicates Query Wizard to find duplicate items in the Orders table
with the following specifications:
• At the first wizard dialog box, specify the Orders table.
• At the second wizard dialog box, specify ItemID as the duplicate value field.
• At the third wizard dialog, specify that you want all of the fields in the
query.
• At the fourth wizard dialog box, determine the query name.
• Print and then close the query.
Use the Find Unmatched Query Wizard to find all of the employees who have not
made banquet reservations with the following specifications:
• At the first wizard dialog box, specify the Employees table.
• At the second wizard dialog box, specify the Banquets table.
• At the third wizard dialog box, specify the EmployeeID field in both list boxes.
• At the fourth wizard dialog box, specify that you want all of the fields in
the query.
• At the fifth wizard dialog box, determine the query name.
• Print the query in landscape orientation with 0.5-inch left and right
margins and then close the query.
Use the Crosstab Query Wizard to create a query that summarizes order amounts
by supplier with the following specifications:
Part
4
128
• At the first wizard dialog box, specify the Orders table.
• At the second wizard dialog box, specify the SupplierID field for row
headings.
• At the third wizard dialog box, specify the ItemID field for column headings.
• At the fourth wizard dialog box, click UnitPrice in the Fields list box and
click Sum in the Functions list box.
• At the fifth wizard dialog box, determine the query name.
• Automatically adjust the columns in the query. (You will need to scroll to
the right to view and adjust all of the columns containing data.)
• Print the query in landscape orientation and then close the query.
Design three additional queries that require fields from at least two tables. Run
the queries and then save and print the queries. In Microsoft Word, write the
query information (including specific information about each query) and format
the document to enhance the visual appearance. Save the document and name it
AL1-C3-CS-Queries. Print and then close AL1-C3-CS-Queries.docx. Close
AL1-C3-Skyline.accdb.
Access Level 1 ■ Unit 1
Download PDF