Vous êtes sur la page 1sur 397

rial

a te
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea

Microsoft® Office Access 2003 - Level 1


Pl
Re
Microsoft® Office Access 2003 -
Level 1

rial
a te
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re
Microsoft® Office Access 2003 -
Level 1

al
Part Number: 1631EBEE
Course Edition: 1.1

ACKNOWLEDGMENTS

ri
Project Team
Curriculum Developer and Technical Writer: Michael Sullivan • Content Manager: Cheryl Russo • Content Editors: Angie J.

te
French, Christy D. Johnson and Laura Thomas • Sr. Material Editors: Lance Anderson, Elizabeth M. Fuller and Frank Wosnick •
Graphic Designer: Julie Popken • Project Technical Specialist: Michael Toscano

NOTICES

a
y
DISCLAIMER: While Element K Courseware LLC takes care to ensure the accuracy and quality of these materials, we cannot guarantee their accuracy, and all materials are provided without any warranty
whatsoever, including, but not limited to, the implied warranties of merchantability or fitness for a particular purpose. The name used in the data files for this course is that of a fictitious company. Any

op
resemblance to current or future companies is purely coincidental. We do not believe we have used anyone’s name in creating this course, but if we have, please notify us and we will change the name in
eM
the next revision of the course. Element K is an independent provider of integrated training solutions for individuals, businesses, educational institutions, and government agencies. Use of screenshots,
photographs of another entity’s product, or another entity’s product name or service in this book is for editorial purposes only. No such use should be construed to imply sponsorship or endorsement of
the book by, nor any affiliation of such entity with Element K. This courseware may contain links to sites on the Internet that are owned and operated by third parties (the “External Sites”). Element K is
not responsible for the availability of, or the content located on or through, any External Site. Please contact Element K if you have any concerns regarding such links or External Sites.

TRADEMARK NOTICES: Element K and the Element K logo are trademarks of Element K LLC.

tC
Microsoft® Access 2004 is a registered trademark of Microsoft Corporation in the U.S. and other countries; the Microsoft products and services discussed or described may be trademarks of Microsoft
Corporation. All other product names and services used throughout this book may be common law or registered trademarks of their respective proprietors.

Copyright © 2004 Element K Content LLC. All rights reserved. Screenshots used for illustrative purposes are the property of the software proprietor. This publication, or any part thereof, may not be
reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, storage in an information retrieval system, or otherwise, without express written
permission of Element K, 500 Canal View Boulevard, Rochester, NY 14623, (585) 240-7500, (800) 434-3466. Element K Courseware LLC’s World Wide Web site is located at
www.elementkcourseware.com.
No
c
This book conveys no rights in the software or other products about which it was written; all use or licensing of such software or other products is the responsibility of the user according to terms and
conditions of the owner. Do not make illegal copies of books or software. If you believe that this book, related materials, or any other Element K materials are being reproduced or transmitted without
permission, please call 1-800-478-7788.
n
Do
e
se
r
fe
ea
Pl
Re

ii Microsoft® Office Access 2003 - Level 1


rial
This logo means that this courseware has been approved by the Microsoft® Office Specialist Program to be among the finest available for learning Microsoft Access 2003. It also means that upon

te
completion of this courseware, you may be prepared to take an exam for Microsoft Offices Specialist qualification.

What is a Microsoft Office Specialist? A Microsoft Office Specialist is an individual who has passed exams for certifying his or her skills in one or more of the Microsoft Office desktop applications such
as Microsoft Word, Microsoft Excel, Microsoft PowerPoint, Microsoft Outlook, Microsoft Access, or Microsoft Project. The Microsoft Office Specialist Program typically offers certification exams at the
“Core” and “Expert” skill levels. The Microsoft Office Specialist Program is the only program in the world approved by Microsoft for testing proficiency in Microsoft Office desktop applications and
Microsoft Project. This testing program can be a valuable asset in any job search or career advancement.

To learn more about becoming a Microsoft Office Specialist, visit www.microsoft.com/officespecialist. To learn more about other Microsoft Office Specialist approved courseware from Element K,
visit www.elementkcourseware.com.

a
y
*The availability of Microsoft Office Specialist certification exams varies by application, application version, and language. Visit www.microsoft.com/officespecialist for exam availability.

Microsoft, the Microsoft Office Logo, PowerPoint, and Outlook are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries, and the Microsoft Office

op
Specialist Logo is used under license from owner.
eM
Element K is independent from Microsoft Corporation, and not affiliated with Microsoft in any manner. This publication may be used in assisting students to prepare for a Microsoft Office Specialist
exam. Neither Microsoft, its designated program administrator or courseware reviewer, nor Element K warrants that use of this publication will ensure passing the relevant exam.

tC
No
n c
Do
e
se
r
fe
ea
Pl
Re

iii
NOTES

rial
a te
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re

iv Microsoft® Office Access 2003 - Level 1


CONTENTS
MICROSOFT® OFFICE ACCESS 2003 -
LEVEL 1

ial
LESSON 1 - AN OVERVIEW OF ACCESS 2003

r
A. Understand Relational Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

te
Database Terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
B. Examine the Access Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
C. Open the Database Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

a
y
Access Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

op
eM
Naming Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
D. Examine an Access Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Table Datasheet View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
9

tC
Table Design View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

LESSON 2 - MANAGING DATA


No
c
A. Examine an Access Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
n
Do

B. Add and Delete Records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22


C. Sort Records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
e

D. Display Recordsets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
se

Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
r

E. Update Records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
fe

F. Run a Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
ea

LESSON 3 - ESTABLISHING TABLE RELATIONSHIPS


Pl
Re

A. Identify Table Relationships . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38


B. Identify Primary and Foreign Keys in the Relationships Window . . . . . . . . 41
Primary Keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Foreign Keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

Contents v
CONTENTS
C. Work with Subdatasheets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Subdatasheets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43

al
LESSON 4 - QUERYING THE DATABASE
A. Create a Select Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
The Query Design Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50

i
B. Add Criteria to a Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56

r
Comparison Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56

te
Conditional Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
C. Add a Calculated Field to a Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
Arithmetic Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61

a
Access Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61

y
The Expression Builder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62

op
eM
D. Perform a Calculation on a Record Grouping . . . . . . . . . . . . . . . . . . . . . . . 67

tC
LESSON 5 - DESIGNING FORMS
A. Examine Form Design Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
AutoForms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
No
c
The Form Wizard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
B. Create a Form Using AutoForm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
n

C. Create a Form Using the Form Wizard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78


Do

D. Modify the Design of a Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81


e

Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
Selecting Form Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
se
r

Sizing Form Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85


fe

Aligning and Spacing Form Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88


ea

Moving Form Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89


Pl

LESSON 6 - PRODUCING REPORTS


Re

A. Create an AutoReport . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
AutoReport . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96

vi Microsoft® Office Access 2003 - Level 1


CONTENTS
B. Create a Report by Using the Wizard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
The Report Wizard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
C. Examine a Report in Design View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104

al
Report Design View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
D. Add a Calculated Field to a Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
The Toolbox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107

i
E. Modify the Format Properties of a Control . . . . . . . . . . . . . . . . . . . . . . . . . . . 110

r
F. AutoFormat a Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112

te
G. Adjust the Width of a Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114

LESSON 7 - PLANNING A DATABASE

a
A. Design a Relational Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120

y
B. Identify Database Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122

op
eM
C. Review Existing Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
D. Determine Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128

tC
E. Group Fields into Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
F. Normalize the Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
G. Designate Primary and Foreign Keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
No
c
LESSON 8 - BUILDING THE STRUCTURE OF A DATABASE
n

A. Create a New Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144


Do

B. Create a Table Using a Wizard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153


e

C. Create Tables in Design View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157


D. Create Relationships between Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
se
r

One-to-One Relationship . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163


fe

One-to-Many Relationship . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164


ea

Enforce Referential Integrity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164


Pl

LESSON 9 - CONTROLLING DATA ENTRY


Re

A. Restrict Data Entry with Field Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172


Field Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172

Contents vii
CONTENTS
B. Create an Input Mask . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
Input Masks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
C. Create a Lookup Field. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183

al
Lookup List Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183

LESSON 10 - FINDING AND JOINING DATA

i
A. Find Data with Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192

r
Types of Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192

te
B. Create Query Joins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198
Query Joins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198
Inner Join . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198

a
Outer Join . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199

y
C. Join Unrelated Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205

op
eM
D. Relate Data Within a Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208
Self Joins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208

tC
LESSON 11 - CREATING FLEXIBLE QUERIES
A. Set Select Query Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216
No
c
Select Query Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216
B. Create Parameter Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222
n

Parameter Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222


Do

The Like Operator and Wildcards. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223


e

C. Create Action Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229


Action Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229
se
r

LESSON 12 - IMPROVING YOUR FORMS


fe
ea

A. Enhance the Appearance of a Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244


Form Design View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
Pl
Re

viii Microsoft® Office Access 2003 - Level 1


CONTENTS
B. Restrict Data Entry in Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253
Control Wizards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254
Combo Box Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254

al
List Box Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254
Option Group Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
C. Add Command Buttons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266

i
Command Buttons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266

r
D. Create a Subform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269

te
Subforms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269

LESSON 13 - CUSTOMIZING YOUR REPORTS

a
A. Organize Report Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278

y
Report Design Enhancements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278

op
eM
Report Design View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279
B. Set Report Control Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285

tC
Display Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
C. Control Report Pagination . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290
Keep Together Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290
No
c
Force New Page Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290
D. Summarize Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294
n

E. Add a Subreport to an Existing Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300


Do

Subreports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300
e

F. Create Mailing Labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306


se
r

LESSON 14 - EXPANDING THE REACH OF YOUR DATA


fe

A. Publish Access Data as a Word Document . . . . . . . . . . . . . . . . . . . . . . . . . . 314


ea

Office Links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314


B. Analyze Access Data in Excel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316
Pl
Re

Excel Office Links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316


C. Export Data to a Text File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321
Exporting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321

Contents ix
CONTENTS
D. Merge Access Data with a Word Document. . . . . . . . . . . . . . . . . . . . . . . . . 326

APPENDIX A - MICROSOFT OFFICE SPECIALIST PROGRAM

al
APPENDIX B - MICROSOFT OFFICE SPECIALIST PROGRAM
LESSON LABS

i
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343

r
SOLUTIONS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359

te
INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377

a
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re

x Microsoft® Office Access 2003 - Level 1


INTRODUCTION

rial
ABOUT THIS COURSE

te
Most organizations maintain and manage large amounts of information. One of the most effi-
cient and powerful information management computer applications is the relational database.

a
Information can be stored, linked, and managed using a single relational database application
and its associated tools. In this course, you will be introduced to the concept of the relational

y
database by using the Microsoft® Office Access 2003 relational database application and its

op
information management tools.
eM
Managing large amounts of complex information is common in today’s business environment
and, if done properly, can provide any business an edge over the competition. However, mis-
managed and lost information can cause you to fall behind. An implementation of the Access

tC
2003 database application can give your business that positive edge.

Course Description
No
c
Target Student
n

This course is designed for students who wish to learn the basic operations of the Access 2003
Do

database program to perform their day-to-day responsibilities, and to understand the advantages
that using a relational database program can bring to their business processes. The Level 1
e

course is for the individual whose job responsibilities include working with tables to create and
maintain records, locate records, and produce reports based on the information in the database.
It also provides the fundamental knowledge and techniques needed to advance to more techni-
se

cal Access responsibilities, such as creating and maintaining new databases and using
r

programming techniques that enhance Access applications.


fe
ea

Course Prerequisites
To ensure the successful completion of Microsoft® Offıce Access 2003 - Level 1 we recom-
mend completion of one of the following New Horizons courses, or equivalent knowledge
Pl
Re

from another source:


• Windows 2000 - Level 1
• Windows XP - Level 1
• Windows XP Professional - Level 1
• Windows XP Professional - Level 2

Introduction xi
INTRODUCTION
How to Use This Book
As a Learning Guide

al
Each lesson covers one broad topic or set of related topics. Lessons are arranged in order of
increasing proficiency with Access 2003; skills you acquire in one lesson are used and devel-
oped in subsequent lessons. For this reason, you should work through the lessons in sequence.
We organized each lesson into results-oriented topics. Topics include all the relevant and sup-

i
porting information you need to master Access 2003, and activities allow you to apply this

r
information to practical hands-on examples.
You get to try out each new skill on a specially prepared sample file. This saves you typing

te
time and allows you to concentrate on the skill at hand. Through the use of sample files,
hands-on activities, illustrations that give you feedback at crucial steps, and supporting back-
ground information, this book provides you with the foundation and structure to learn Access
2003 quickly and easily.

a
y
As a Review Tool

op
eM
Any method of instruction is only as effective as the time and effort you are willing to invest
in it. In addition, some of the information that you learn in class may not be important to you
immediately, but it may become important later on. For this reason, we encourage you to
spend some time reviewing the topics and activities after the course. For additional challenge

tC
when reviewing activities, try the “What You Do” column before looking at the “How You Do
It” column.

As a Reference
No
c
The organization and layout of the book make it easy to use as a learning tool and as an after-
class reference. You can use this book as a first source for definitions of terms, background
information on given topics, and summaries of procedures.
n
Do

This course is one of a series of New Horizons courseware titles that addresses Microsoft
Office Specialist (Office Specialist) skill sets. The Office Specialist program is for individuals
who use Microsoft’s business desktop software and who seek recognition for their expertise
e

with specific Microsoft products. Certification candidates must pass one or more proficiency
exams in order to earn Office Specialist certification.
se
r

Course Objectives
fe
ea

In this course, you will be introduced to the features of the Access 2003 application.
You will:
Pl
Re

• examine the Microsoft® Office Access 2003 database application.


• manage the data in a database.
• examine existing table relationships.
• query the database.
• design simple forms.

xii Microsoft® Office Access 2003 - Level 1


INTRODUCTION
• create and modify Access reports.
• follow the steps required to properly design a simple database.
• create a new database with related tables.
• control data entry by modifying the design of a table to streamline data entry and main-

al
tain data integrity.
• find and retrieve desired data by using filters and joins between tables and within a single
table.
• create flexible queries to display specified records; allow for user-determined query crite-

i
ria; and add, update, and delete data with queries.

r
• enhance the appearance, data entry, and data access capabilities of your forms.
• customize reports to better organize the displayed information and produce specific print

te
layouts such as mailing labels.
• use Access data in other applications, including Microsoft Word and Excel.

a
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re

Introduction xiii
NOTES

rial
a te
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re

xiv Microsoft® Office Access 2003 - Level 1


LESSON 1

al
LESSON 1 Lesson Time
45 minutes

ri
An Overview of Access

te
2003

a
y
op
Lesson Objectives: eM
In this lesson, you will examine the Microsoft® Office Access 2003 database application.

tC
You will:
• Define the relational database concept.
• Examine the Access 2003 program environment.
• Examine an Access database’s environment.
No
c
• Examine a table in an Access database.
n
Do
e
se
r
fe
ea
Pl
Re

Lesson 1: An Overview of Access 2003 1


LESSON 1
Introduction
In most businesses, working with large amounts of varying types of data is a daily
requirement. Understanding the composition of databases—and, in particular, the Access rela-
tional database program—will provide you with a foundation for using Microsoft® Office

al
Access 2003 to organize your data. In this lesson, you will receive an introduction to database
concepts, the Access database application environment, and an actual Access relational
database.
With the Access relational database application installed in your business, you can organize

i
and manage the data you have been tracking on paper. However, with an understanding of the
relational database concept and the Access program, you will know where to begin. Identifying

r
the features of a relational database, becoming familiar with the Access program, and opening
and navigating through an Access database will provide you with the knowledge to begin man-

te
aging your data.

TOPIC A

a
y
Understand Relational Databases

op
eM
There are different types of databases, as well as applications that are sometimes mistakenly
referred to as database programs. Understanding what a real database is and becoming familiar

tC
with the terms used to describe a database is the first step to becoming a competent database
user. In this topic, you will be introduced to the relational database and the terminology that
defines its components. No
When an application, such as Access, is installed on your computer, it is very tempting to dive
right in and start using the program. Gaining an understanding of the application you are about
c
to use and being versed in its terminology is a much better starting point.
n

Database Terminology
Do

Like many other computer programs, database applications have their own language. A few of
the most common terms are listed in the following table.
e
se

Term Meaning
r

Table A group of records stored in rows and columns.


fe

Record A set of data about one person or thing.


ea

Field A category of information that pertains to all records.


Value A single piece of data.
Pl
Re

2 Microsoft® Office Access 2003 - Level 1


LESSON 1
Relational Databases
Definition:
Simply put, a database is a collection of information. A relational database takes that

al
concept one step further. A relational database is a file that stores information in mul-
tiple tables. Each table stores one specific category of information. The relational
database can access these tables and extract, reorganize, and display the information
contained within them in many different ways without altering the original table
structures.

i
A relational database offers several benefits:

r
• Flexbility

te
Simplicity
• Ease of management
• Power

Example:

a
y
A travel agent maintains two client tables. The first table contains information on the
time of year clients prefer to travel, while the second table contains data on the clients’

op
eM
favorite vacation spots. Using a relational database, the travel agent can produce a
report listing their customers’ favorite vacation spots and the time of year they prefer
to travel. The report can be used to send promotions to clients at appropriate times. All
of this is accomplished without altering the original tables.

tC
No
n c
Do
e
se
r
fe
ea
Pl
Re

Figure 1-1: The relational database.

Lesson 1: An Overview of Access 2003 3


LESSON 1
ACTIVITY 1-1
Identifying a Relational Database

al
Activity Time:
5 minutes

i
Scenario:

r
You are attempting to understand what a database is and how it works, and to be more precise,
what a relational database is and how it differs from other database types. Reviewing examples
and characteristics of databases, particularly relational databases, will help you understand

te
these concepts.

What You Do How You Do It

a
1. What are some examples of collections of data that you use in your personal life?

y
op
2.
eM
What are some examples of collections of data that you use in your job?

tC
3. Which of the following is representative of a relational database?
a) Note card
No
c
b) Library file system
c) Index in a book
d) Glossary in a book
n
Do

4. Which of the following is not an advantage of the relational database?


a) Flexibility
e

b) Simplicity
c) Redundancy
se
r

d) Ease of management
fe

e) Power
ea
Pl
Re

4 Microsoft® Office Access 2003 - Level 1


LESSON 1
TOPIC B
Examine the Access Environment

al
Now that you are familiar with the concept of a relational database, it is time to take a look at
the application you will be using. In this topic, you will launch the Access program and exam-
ine the environment used to create new Access database files and interface with existing ones.

i
When you launch Access, you have not yet opened a real database; you’ve only opened the
interface that allows you to create new databases and open and manage existing databases.

r
This is much like entering a house without knowing how to open any of the doors to the
rooms. Unless you understand how to open and close the database files that hold your informa-

te
tion, your relationship to the database is extremely limited. An understanding of the interface
that performs these actions is essential to managing your information.

Access Environment Components

a
y
The Access 2003 environment enables you to open existing databases and create new
databases. There are three primary components of the application environment:

op



eM
The menu bar is where commands are displayed and executed.
The toolbar is a row of icons used to execute commands.
The task pane is where you can search for files and consult the Microsoft Office online

tC
product information.

No
n c
Do
e
se
r
fe
ea

Figure 1-2: The Access 2003 application environment.


Pl
Re

Lesson 1: An Overview of Access 2003 5


LESSON 1
ACTIVITY 1-2
Examining the Access Environment

al
Activity Time:
10 minutes

i
Scenario:

r
Access is installed on your computer. It’s now time to launch the application and explore its
basic features.

te
What You Do How You Do It

1. Launch Access. a. From the Start menu, choose All


Programs→Microsoft Office→Microsoft

a
Office Access 2003.

y
In Windows 2000, choose Start→Programs→

op
2.
eM
Examine the menus on the menu
Microsoft Access.

a. On the menu bar, click File to display the

tC
bar. File menu. The commands are similar to
those in other applications.

b. In the File menu, point to New. When you


No
point to an active command, Access high-
lights the command.
c
c. In the File menu, point to Close. Because
n

this command is inactive, nothing happens


Do

when you point to it.

Inactive items appear grayed out in all of the


e

menus.
se
r

d. On the menu bar, display the other


menus and examine the choices.
fe
ea

e. Click a blank area of the screen to close


the open menu.
Pl
Re

6 Microsoft® Office Access 2003 - Level 1


LESSON 1
3. In the Access application, use the a. On the toolbar, hover the mouse pointer
tooltips to examine the tools on the over the first button on the left to dis-
toolbar. play the tooltip.

Inactive buttons appear grayed out, as did the

al
inactive menu items.

b. Moving from left to right, display the


tooltip for each button.

ri
4. By default, which of the following toolbar options are activated when you launch the
Access application?

te
a) New
b) Open
c) Save
d) Cut

a
e) Microsoft Office Access Help

y
f) Undo

op
g) Code
h) File Search
eM
tC
5. Navigate through the available task a. On the toolbar, click the File Search but-
panes. ton to display the Basic File Search
task pane in which you can search for a
database file. No
c
b. In the task pane’s navigation bar, click
the Home button to return to the
Getting Started task pane.
n
Do

c. Click the Back button to return to


the Basic File Search task pane.
e

d. On the toolbar, click the New button


to display the New File task pane.
se
r

e. In the task pane’s navigation bar, click


fe

the Back button to display the Basic File


ea

Search task pane again.

f. Click the Forward button to display


Pl

the New File task pane.


Re

g. Click the Home button to display the


Getting Started task pane.

Lesson 1: An Overview of Access 2003 7


LESSON 1
TOPIC C
Open the Database Environment

al
You have opened the Access application and looked at a few of its most basic features. In this
topic, you will open an Access database and identify the components that make up the
database.

i
It is, of course, important to understand the relational database concept and the interface that
appears when you launch the Access program. You must also be familiar with the database file

r
structure within Access. Doing so will allow you to open the files that hold your data and
employ the tools to manage it.

te
Access Objects
The Database window displays the Access objects in the left pane. Access objects are the tools

a
that are used to store and work with your data.

y
op
eM
tC
No
n c

Figure 1-3: Selecting an object in the Objects pane on the left side of the Database
Do

window allows you to view all instances of that Access object within the database
file.
e

Although the Objects pane does contain seven Access objects, for the purposes of this course
you will only be concerned with the top four. The following table provides a brief description
of the objects that will be used in this course.
se
r
fe

Object Description
ea

Tables Storage container for the data.


Queries Question that retrieves data from tables. Queries may be saved for reuse.
Queries always display either record level output (list format) or sum-
Pl
Re

mary information (a query cannot display both detail and summary).


Forms Graphical interface used for data entry and/or displaying data and other
objects.
Reports Screen output of data arranged in an order specified by the user.

8 Microsoft® Office Access 2003 - Level 1


LESSON 1
Naming Conventions
Naming conventions are sets of rules that can be applied to Access objects in order to identify
them. The rules call for a unique prefix to be assigned to the beginning of an object name.

al
Common Applications of Naming Conventions
Some, but not all developers use naming conventions at the field level. The two most
common naming conventions are the Leszynski naming convention and the Reddick
naming convention. Naming conventions are optional and the type of naming conven-

i
tion utilized is strictly up to the user. The following table illustrates examples of
commonly used naming conventions.

r
te
Object Prefix Example
Table tbl tblSampleTable
Select Queries qry qrySampleQuery or
qryselSampleQuery

a
Forms frm frmSampleForm

y
Subforms fsub fsubSampleSubform

op
Reports
Subreports
rpt
rsub
eM rptSampleReport
rsubSampleSubReport

tC
How to Open and View an Access Database
Procedure Reference: Open and View a Database
No
To open and view a database:
c
1. Start Access.
Locate the database files.
n

2.
Do

3. Select the database file to open.


4. Click Open.
e

You could also double-click a database file to open it.


se
r
fe
ea
Pl
Re

Lesson 1: An Overview of Access 2003 9


LESSON 1
ACTIVITY 1-3
Opening and Viewing an Access Database

al
Activity Time:
5 minutes

i
Data Files:

r
• Computers.mdb

te
Setup:
Access is running. No files are open.

Scenario:
A consultant has created an inventory database, Computers.mdb, containing information on all

a
of the organization’s computers, including who uses them, in which department they are used,

y
their manufacturer, their price, whether they are under warranty, and their tracking number. By
opening the database and viewing the data it contains, you hope to gain a better understanding

op
eM
of the company’s computer inventory.

tC
No
n c
Do
e
se
r
fe
ea
Pl
Re

10 Microsoft® Office Access 2003 - Level 1


LESSON 1
What You Do How You Do It

1. In the Computers.mdb database, in a. On the Getting Started task pane, click


the Objects pane, verify that the the Open link.
Tables object is highlighted and

al
examine the table objects.
b. From the My Documents folder, locate
and double-click Computers.mdb to open
the database and display the Database
window.

i
c. Examine the Objects pane on the left

r
side of the Computers Database window.

te
d. If necessary, in the Objects pane, click
Tables to display the table objects.

a
y
op
eM
tC
No
c
e. In the right pane, examine the list of
objects. At the top of the list are the
tools to create tables, followed by the list
n

of existing tables in the Computers.mdb


Do

database.
e

2. Display the queries, forms, and a. In the Objects pane, select Queries. The
reports in the Computers.mdb right pane displays a list of query creation
database. tools and queries stored in the Computers.
se
r

mdb database.
fe

b. In the Objects pane, select Forms. The


ea

right pane changes to display a list of


form creation tools and the forms stored
in the database.
Pl
Re

c. In the Objects pane, select Reports. The


right pane displays report creation tools
and a report stored in the database.

Lesson 1: An Overview of Access 2003 11


LESSON 1
3. In the left pane, collapse and a. In the left pane, click Groups to collapse
expand the Objects listing. the Objects listing.

Groups is an advanced feature discussed b. Click Objects to expand the listing again.
in a future course.

al
4. Match the type of Access object with the description of the function(s) that it
performs.
report a. Displays data for editing.

i
table b. Arranges data for printed output.

r
query c. Displays selected data.
form d. Stores data on a single topic.

a te
TOPIC D

y
op
Examine an Access Table
eM
You have toured the Access interface and viewed an MDB database file where your informa-

tC
tion, and the Access objects used to manage it, are stored. Now you will open an Access table
to view some of the data that populates the database.
Understanding the application interface and the structure of the database files is like knowing
the directions to a bank and how the safe deposit boxes are organized. It is essential to know,
No
but not very useful unless you know how to open the safe deposit boxes and access the
c
valuables. Opening an Access table that contains your information and using the Access pro-
gram’s views to work with the tables is like having the keys to the safe deposit boxes.
n
Do

Table Datasheet View


Datasheet view is the default view a user sees when opening a table or using a query. The data
e

is arranged in rows and columns and the format resembles an Excel worksheet.
In Datasheet view:
se
r

• Record selectors appear to the left of each record, allowing users to select an entire record
to copy or delete.
fe

• A navigation bar allows the user to navigate to a specific record.


ea
Pl
Re

12 Microsoft® Office Access 2003 - Level 1


LESSON 1

rial
te
Figure 1-4: Table displayed in Datasheet view.

a
Table Design View

y
Design view is displayed when the user clicks the View button when a table is open in

op
eM
Datasheet view. In Design view, the user is looking at the components that make up the table
from a developer’s perspective. Field names, data types, and field properties are set, defined,
and described within the Design view.

tC
No
n c
Do
e
se
r

Figure 1-5: Table displayed in Design view.


fe
ea

Working with an Access Table in Datasheet and


Design Views
Pl
Re

Datasheet view allows you to work with the data in a table, while Design view allows you to
modify the appearance and manner in which the form operates. It is not possible for an indi-
vidual user of a single database to work with a table in Datasheet view and, simultaneously, to
open the same table in Design view.

Lesson 1: An Overview of Access 2003 13


LESSON 1
ACTIVITY 1-4
Comparing Datasheet and Design Views of an Access

al
Table
Activity Time:
10 minutes

ri
Setup:
Computers.mdb is open.

te
Scenario:
Knowing that there are different ways to view a table, you would like to obtain a better under-
standing of the differences between those views. By viewing the tblEmployees table in
Datasheet view and then in Design view, you can see the differences.

a
y
What You Do How You Do It

op
1.
eM
Open the tblEmployees table. a. In the Database window, with Tables
selected, double-click tblEmployees.

tC
No
n c
Do
e
se
r
fe
ea
Pl
Re

14 Microsoft® Office Access 2003 - Level 1


LESSON 1
2. Using the Tab and arrow keys, the a. Press the Tab key three times to move
mouse pointer, and the table’s navi- through the fields in the table.
gation bar, move through the
tblEmployees table.
b. Hold down the Shift key and press Tab
three times to move back through the

al
fields.

c. Press the arrow keys to move around the


fields in the table.

i
d. Click the record selector (the gray left

r
column) of EmployeeID 0036 to select
Andrea Brown’s entire record.

te
e. In the Record Navigation bar at the bot-
tom of the table, click the First Record
button to select the first record in
the table.

a
y
f. In the Record Navigation bar, click the

op
eM Next Record button
second record in the table.
to select the

g. In the Record Navigation bar, click the

tC
Last Record button to select the
last record in the table, Edward
Bernstein’s record.No
3. Display the tblEmployees table in a. On the far left of the table datasheet’s
c
Design view and examine the prop- toolbar, click the View button to
erties of the EmployeeID field. display the tblEmployees table in Design
view.
n
Do

b. Click the table window’s Maximize but-


ton to maximize the display.
e

c. Press the down arrow to move to the


next field and observe the change in the
se
r

properties in the lower panel.


fe

d. Press the down arrow again to move to


ea

the next fields and observe the properties


in the lower panel.
Pl

e. Press the down arrow a final time to


Re

move to the last field and observe the


properties in the lower panel.

f. In the upper pane, select the EmployeeID


field.

Lesson 1: An Overview of Access 2003 15


LESSON 1
4. What is the data type of the EmployeeID field in tblEmployees?
a) Currency
b) Date
c) Number

al
d) Text

5. What is the data type of the DeptCode field in the tblEmployees table?
a) Currency

i
b) Date

r
c) Number

te
d) Text

6. What is the field size of EmployeeID?


a) 2 characters

a
b) 4 characters

y
c) 20 characters
d) 20 digits

op
7.
eM
Close the table and database. a. Choose File→Close to close the table.

tC
b. Choose File→Close to close the database.

No
c
Lesson 1 Follow-up
n

In this lesson, you were introduced to the composition of databases and the Access relational
Do

database program. In addition, you opened and briefly examined the Access database applica-
tion environment and an Access relational database.
e

1. Why is it important to understand the way the database objects interact?


se
r

2. What kinds of information do you plan to build databases for?


fe
ea
Pl
Re

16 Microsoft® Office Access 2003 - Level 1


LESSON 2

al
LESSON 2 Lesson Time
45 minutes

ri
Managing Data

a te
Lesson Objectives:

y
op
You will:
• Examine an Access 2003 form.
eM
In this lesson, you will manage the data in a database.

tC
• Add and delete records from a table.
• Use different criteria to sort the records in a table.
• Use Select queries to display recordsets.

No
Update the records in a table by working in the table, by using a form, and then by using
c
a query.
• Run a report to display a table’s records in a report format.
n
Do
e
se
r
fe
ea
Pl
Re

Lesson 2: Managing Data 17


LESSON 2
Introduction
Understanding the Access environment is the first step in managing the information in the
database. Knowing how to use the data management tools that are provided with the applica-
tion is the next step. In this lesson, you will work directly within a table to manage the table’s

al
data, then move out of the table and use forms, queries, and reports to indirectly manage the
same data.
The most important component of a relational database is the table, where your information is
stored. Knowing how to use the other components of a database will allow you to reap the

i
benefits of your database and ensure that you have more time to spend on your other
responsibilities.

r
te
TOPIC A
Examine an Access Form

a
y
Now that you have worked in the Access environment, it is time to begin using the data man-

op
eM
agement objects provided by Access. In this topic, you will examine an Access form, an object
that allows you to locate and manage individual records.
You have opened, examined, and toured a table. Now, imagine a table with thousands of

tC
records and each record containing multiple fields. Moving about the table to locate and
modify a single field in an individual record could be a challenging task. The Access form
object simplifies the process by allowing you to manage data through a graphical user
interface.
No
c
Forms
Definition:
n

An Access form is the object that is used to display, add, delete, and edit data in a
Do

table.
e

When using a form, keep in mind that:


• The data is never stored in the form, the form only displays the data stored in the
table.
se
r

• Forms can be based on a table or a query.


• Forms can be viewed in one of three ways: Datasheet view, Design view, or Form
fe

view.
ea

• In addition to displaying table data, forms can include calculations, graphics, and
other objects.
Pl
Re

18 Microsoft® Office Access 2003 - Level 1


LESSON 2
Example:

ial
Figure 2-1: A sample form.

r
Navigation in an Access Form

te
In a form, the navigation bar at the bottom of the form is an easy method of moving from one
record to another. The current record number, the record whose data is currently displayed in
the form, is indicated in the navigation bar. The buttons on the navigation bar are used to
move forward and backward through the records in the table. To move through the data dis-
played in the form, you can use the mouse or the keys and keystroke combinations found in

a
the following table.

y
op
Keystroke Movement
eM
Tab, Enter, right arrow, down Pressing Tab or Enter, or the right or down arrow, moves you to the next
arrow field in the form. If it is the last field in the form, it moves you to the

tC
first field of the next record.
Shift+Tab, left arrow, up Pressing Shift+Tab, or the left arrow or up arrow, will move you to the
arrow previous field in the form. If it is the first field in the form, it moves you
to the last field of the previous record.
No
Page Up Pressing Page Up will move you to the same field in the previous
c
record. (This will only work if the form is built properly.)
Page Down Pressing Page Down will move you to the same field in the next record.
(This will only work if the form is built properly.)
n

Home Pressing Home will move you to the first field of the record you are cur-
Do

rently in.
End Pressing End will move you to the last field of the record you are cur-
e

rently in.
Ctrl+Home Pressing Ctrl+Home will move you to the first field in the first record of
se

the table with which you are working.


r

Ctrl+End Pressing Ctrl+End will move you to the last field in the last record of
the table with which you are working.
fe
ea
Pl
Re

Lesson 2: Managing Data 19


LESSON 2
ACTIVITY 2-1
Navigating in Access Forms

al
Activity Time:
5 minutes

i
Data Files:

r
• UseForms.mdb

te
Scenario:
Your manager has suggested you look at some forms in the UseForms.mdb database so you
can get an understanding of how they appear, how they are used, and what format best suits
the company’s needs.

a
What You Do How You Do It

y
1. On the toolbar, click the File Search a. On the toolbar, click the File Search

op
eM
button and, in the task pane, open
the UseForms.mdb database, then
open the frmCustomers form.
button.

b. In the Basic File Search task pane’s Search

tC
Text text box, type UseForms.mdb

c. Click Go.
No
d. When the UseForms.mdb file list appears,
c
determine which file is in My Documents
then click the My Documents\
UseForms.mdb file.
n
Do

e. Close the Search Results task pane.


e

f. In the Objects pane, select Forms.


se

g. In the Database window’s right pane,


r

double-click frmCustomers to open the


form and display the first record in the
fe

tblCustomers table.
ea

2. How many fields are displayed in the form?


Pl
Re

3. What field is highlighted by default?

20 Microsoft® Office Access 2003 - Level 1


LESSON 2
4. How many records are in the table?

5. Move through the record’s fields, to a. With the CustomerID field selected, press

al
the next record, and then return to the Tab key to move to the
the first record in the table. CustomerName field.

b. Press the Tab key until the Postal Code


field is selected.

ri
te
c. Press the Tab key one more time to
move to the second record in the
tblCustomer table.

a
y
d. Press Shift+Tab to move back to the first

op
eM record in the tblCustomers table.

e. Using the Shift+Tab key combination,


move to record number one’s Fax field.

tC
6. Move to the first field in the record a. With the Fax field of the first record
and then to the last field in the selected, press Home to move to the
record. CustomerID field.
No
c
b. Press End to move to the last field of the
record, Postal Code.
n

7. Move to the last field in the last a. With the last field of the first record
Do

record, move to the Fax field of the selected, press Ctrl+End to move to the
last record, and then return to the last field in the last record in the table.
e

first field in the first record.


b. Press Shift+Tab to move to the Fax field
in the last record.
se
r

c. With the Fax field of the last record


fe

selected, press Ctrl+Home to return to


ea

the first field in the first record.


Pl
Re

Lesson 2: Managing Data 21


LESSON 2
8. Using the navigation bar, move to a. With Record 1 displayed, in the navigation
the second record in the table, the bar located at the bottom of the form,
last record, the next-to-last record, click the Next Record button to move to
and then return to the first record the second record.
in the table.

al
b. In the navigation bar, click the Last
Record button to move to Record 14, the
last record.

i
c. While located in the last record, click the
Previous Record button to move to

r
Record 13.

te
d. Click the First Record button to return to
Record 1.

a
y
TOPIC B

op
eM
Add and Delete Records

tC
Two of the most commonly performed database operations are the addition and deletion of
information. Generally, these are ongoing operations that are performed on a regular basis. In
No
this topic, you will add new records to a table and delete existing records from a table.
c
Having current information in your database is one of the most important qualities of a
database. A database that is incomplete or that contains outdated records is not a reliable
source of information. By conscientiously adding new records and deleting old ones, your table
n

will provide reliable, up-to-the-moment information. It will also prevent the database from
Do

becoming outdated.
e

How to Add and Delete Records


se

Procedure Reference: Add a Record to a Table


r

To add a record and enter the data:


fe

1. On the table’s navigation bar, click the New Record button.


ea

2. Enter the new record data.


3. Press Enter to accept the new record.
Pl
Re

Procedure Reference: Delete a Record from a Table


To delete a record:
1. Select the record to be deleted.
2. Either press Delete or choose Edit→Delete.

22 Microsoft® Office Access 2003 - Level 1


LESSON 2
ACTIVITY 2-2
Adding and Deleting Records in a Table

al
Activity Time:
10 minutes

i
Setup:

r
The UseForms.mdb database is open and the frmCustomers form is displayed on the screen.

te
Scenario:
Adding and deleting records is going to be part of your daily routine and you would like to
determine the most efficient method to complete those operations. By trying several techniques
with the tblCustomers table, you can determine the most efficient method.

a
What You Do How You Do It

y
1. Add a new customer record to the a. In the frmCustomers form’s navigation

op
table. eM bar, click the New Record button
to clear the form in preparation for
entry of a new record.

tC
b. In the blank form, enter the following
data:
• CustomerID: 21998

No
CustomerName: Brave New Shop-
c
pers
• Phone: (456) 777-6668
• Fax: (456) 777-6669
n
Do

• Address: 39 Rosey Blvd.


• City: Camptown
e

• Region: NY
• Country: US
se


r

Postal Code: 13355-0000


fe

c. Close the form.


ea

2. Display tblCustomers and view the a. Display tblCustomers and locate the new
new record. record.
Pl
Re

Lesson 2: Managing Data 23


LESSON 2
3. How many records are in the table?
a) 12
b) 13
c) 14

al
d) 15

4. Delete the Household Helper a. In tblCustomers, verify that the right


record. pointing Current Record Indicator is

i
located in the first record, Household
Helper.

r
b. Choose Edit→Select Record to highlight

te
the Household Helper record.

c. Choose Edit→Delete.

a
d. When prompted to verify the record dele-

y
tion, click Yes to complete the operation.

op
5. eM
Use the navigation bar to add a new
record to the table.
a. In the tblCustomers table’s navigation
bar, click the New Record button.

tC
b. Enter the following data:
• CustomerID: 21999
• CustomerName: Super Savers
• Address: 3669 Windy Way
No
• City: Coalville
c
• Region: UT
• Country: US
n

• Postal Code: 13365-0000


Do

• Phone: (454) 888-6668


e

• Fax: (454) 888-6667

6. a. Close tblCustomers and the UseForms


se

Close the table and the database.


r

database.
fe
ea
Pl
Re

24 Microsoft® Office Access 2003 - Level 1


LESSON 2
TOPIC C
Sort Records

al
You have been asked to locate all of the individuals in a specific department who are listed in
a large table in which the records have been entered over a long period of time. The records
you need to find are located throughout the table. In this topic, you will use several techniques
to order the table’s data and locate the desired records.

i
Viewing and locating specific records in a large table can be difficult and time-consuming. To

r
simplify the process and reduce the time you spend searching, Access provides you with sev-
eral techniques to assist you in sorting and locating the desired records.

te
How to Sort Records
Procedure Reference: Sort Records in a Table

a
y
To sort the records in a table:
1. In the Database window, select Tables.

op
2.
3.
Open the table you wish to sort.
eM
In the table, select a field in the column by which you wish to sort the table.

tC
4. Sort the table:
• From the toolbar, select either the Sort Ascending or Sort Descending option;
• Or, choose either Records→Sort→Sort Ascending or Records→Sort→Sort
Descending.
No
c
ACTIVITY 2-3
n
Do

Sorting Records in a Table


e

Activity Time:
10 minutes
se
r

Data Files:
fe

• SampleTables.mdb
ea

Scenario:
Your sales manager has learned that you have an abundance of information available at your
Pl
Re

fingertips in the database and she would like to take advantage of it. She would like to know
how many orders in the tblCustomers table of the SampleTables.mdb database have been
placed by Zilinski’s Home Store and how many have been placed by Household Helper. With
the Access sorting tools, you’ll accomplish this task in no time.

Lesson 2: Managing Data 25


LESSON 2
What You Do How You Do It

1. From the SampleTables.mdb data- a. Open the SampleTables.mdb database.


base, open the tblCustomers table.
b. Open tblCustomers.

rial
a te
y
op
2. eM
Locate the CustomerID numbers for
Household Helper and Zilinski’s
Home Store.
a. Locate the Household Helper record and
record the CustomerID number
_________________. (It is the lowest
number in the table.)

tC
b. Locate the Zilinski’s Home Store record
and record the CustomerID number
_________________. (It is the highest
No
number in the database).
c
c. Close the table.
n

3. Open tblOrders. a. Open tblOrders.


Do
e
se
r
fe
ea
Pl
Re

4. How is the table sorted?


a) By OrderID
b) By ItemNum
c) By Quantity

26 Microsoft® Office Access 2003 - Level 1


LESSON 2
5. Sort the table in ascending order, a. With the tblOrders table displayed, place
displaying the Household Helper the insertion point in the first field in
orders at the top of the table. the CustomerID column.

b. Choose Records→Sort→Sort Ascending.

al
Examine the results; there are three
Household Helper orders at the top of the
list.

i
6. Sort the table in descending order, a. With the tblOrders table displayed, place
displaying Zilinski’s orders at the the insertion point in the first field in

r
top of the table. the CustomerID column.

te
b. Choose Records→Sort→Sort Descending.
There are 10 Zilinski’s Home Store orders
at the top of the list.

7. Sort the OrderID column in ascend- a. Click in any field in the OrderID column.

a
ing order.

y
b. Click the Sort Ascending button on the

op
to sort the OrderID column in
eM toolbar
ascending order, restoring it to its original
state.

tC
No
TOPIC D
c

Display Recordsets
n
Do

Sorting the records in a table in ascending or descending order, based on the values in a field,
is a very useful operation. However, there are times when you need to extract groups of related
e

records, such as records with the same department name or range of values. In this topic, you
will use the Access query object to locate and display record groupings that meet a specific
se

criteria.
r

You have been asked to locate all employees whose pay rate is between $12.50 and $15.00 per
fe

hour in a table that has several thousand records. You know that doing this in a table’s
ea

Datasheet view will take longer than you have been given and there is a good chance you
would miss some. By using a query, which searches the table for records with values in this
range, you can accomplish the task more quickly and accurately.
Pl
Re

Queries
Definition:
A query displays data from one or more tables in an ordered manner, as defined by the
query’s developer.

Lesson 2: Managing Data 27


LESSON 2
Example:
A valid query is a query that is located in the Queries list in the Database window. Its
name may begin with the qry prefix, but that is not a requirement. When selected and
launched or double-clicked, it is set into action and the results of the query are
displayed.

al
How to Display Sets of Records
Procedure Reference: Display Sets of Records

i
To display a recordset:

r
1. In the Database window, select Tables.

te
2. Open the table you wish to sort.
3. In the table, locate and select a single occurrence of the value you wish to find.
4. Display the recordset:

a
On the toolbar, click the Filter By Selection button;

y
• Or, choose Records→Filter→Filter By Selection.

op
To remove the filter:
1.
eM
Procedure Reference: Remove a Filter

Either click the toolbar’s Remove Filter button or choose Records→Remove

tC
Filter/Sort.

ACTIVITY 2-4
No
c
Displaying Sets of Records
n

Activity Time:
Do

10 minutes
e

Setup:
The SampleTables.mdb database is open and the tblOrders table is displayed.
se
r

Scenario:
fe

The Sales Managers would like a printout of only Zilinski’s Home Store orders and a printout
ea

of only the Household Helper orders. Using the sorting tools, you can group the orders
together, but not pull them out of the table. Fortunately, the consultant who implemented your
application built a simple Select query to display the orders for Household Helper. So, by
using the Filter By Selection tool, you can display only the orders for each customer.
Pl
Re

28 Microsoft® Office Access 2003 - Level 1


LESSON 2
What You Do How You Do It

1. Use the Filter By Selection tool to a. In the CustomerID column, place the
display the Household Helper order insertion point in any field with a 20151
recordset, and then view it in Print value. This is the Household Helper Cus-

al
Preview. tomer ID number.

b. From the toolbar, click the Filter By


Selection button to display the
recordset of Household Helper orders.

ri
a te
2. Use Print Preview to view the a. On the toolbar, click the Print Preview

y
Household Helper recordset. Then, button to preview how the printed
close the Preview window and use recordset would appear.

op
the Remove Filter tool to close the
recordset.
eM
b. Using the Zoom feature, click in the pre-
view to enlarge the display.

tC
c. Press Esc to close the Print Preview win-
dow and return to the table.
No
d. On the toolbar, click the Remove Filter
button to close the recordset display
c
and return to the tblOrders table.
n

3. Locate one of the Zilinski’s Home a. In the CustomerID column, place the
Do

Stores CustomerID fields and apply insertion point in any field with a 21965
a filter to display the recordset of value. This is the Zilinski’s Home Stores
their orders. Customer ID number.
e

b. From the menu, choose Records→


se

Filter→Filter By Selection to display the


r

recordset of Zilinski Home Stores orders.


fe

4. Use Print Preview to display the a. Choose File→Print Preview and size the
ea

Zilinski’s Home Stores recordset. display to the screen to preview how the
Then, close the Print Preview win- printed page would appear.
dow and remove the filter to close
the recordset and return to the
Pl
Re

tblOrders table. b. Press Esc to close the Print Preview


window.

c. Choose Records→Remove Filter/Sort to


view all the records.

Lesson 2: Managing Data 29


LESSON 2
5. Close the open table without sav- a. Close the tblOrders table. Click No when
ing, display the Queries objects, prompted to save the changes.
and select the
qryHouseholdHelperOrders query.
b. With the SampleTables Database window
open, in the Objects pane, select Queries

al
to display any existing queries.

c. Examine the right pane and verify that


the qryHouseholdHelperOrders query is

i
present.

r
d. In the right pane, double-click the
qryHouseholdHelperOrders query to run

te
the query and display the recordset of
Household Helper orders. You will notice
that it was not necessary for any of the
tables to be open when the query was
run.

a
y
e. Close the recordset.

op
eM
tC
TOPIC E No
Update Records
c
In the previous topics, you used a form to view data and a filter to display specific data. In this
topic, you will use the form and query objects together to locate, edit, and update the records
n

in a table that meet specific criteria.


Do

There is little doubt that you will be continually changing and updating records in your
database. The more efficiently you can perform operations, the more time you will have for
e

other responsibilities. By using a query and a form in combination, you will be able to quickly
locate the records you need and, when possible, display them in edit mode.
se
r

How to Update Records


fe
ea

Procedure Reference: Update Records


To update a record:
1. In the Database window, in the Objects pane, select Tables.
Pl
Re

2. From the list of tables, open the table you wish to update.
3. Locate the field with the information that requires updating.
4. Select the value of this field and modify the data.
5. Press the down arrow or Enter to accept the changes.

30 Microsoft® Office Access 2003 - Level 1


LESSON 2
6. Close the table.

ACTIVITY 2-5

al
Updating Records
Activity Time:

i
10 minutes

r
Setup:

te
The SampleTables.mdb database is open.

Scenario:
Your manager has asked you to make several updates to the tblEmployees table in the
SampleTables.mdb database. These include name, phone number, and ZIP Code changes. This

a
is your first attempt at editing fields in a table and there are several editing techniques you can

y
use. By trying several, you can determine which work best for you.

op
What You Do

1. In the tblEmployees table, change


eMHow You Do It

a. Open and maximize the tblEmployees

tC
Shelly Griffith’s ZIP Code from table.
72308 to 99336.
b. Click in the EmployeeID field with a
value of 0057. This is Shelly Griffith’s
record.
No
c
c. Press Tab six times to highlight the ZIP
Code.
n
Do

d. With the ZIP Code selected, type 99336


e

Notice that the Current Record Indicator to the


far left changes to a pencil .
se
r

e. Press the down arrow. The Record Indi-


fe

cator returns to its original state and the


change is accepted.
ea
Pl
Re

Lesson 2: Managing Data 31


LESSON 2
2. Locate Employee ID Number 0078, a. In the EmployeeID column, locate
and correct the spelling of the EmployeeID 0078. This is Carl
name to Ballantine. Ballantyne’s record.

b. Click between the “t” and the “y” in

al
Ballantyne.

c. Type i and delete the “y” to change


Ballantyne to Ballantine.

i
d. Press the down arrow to accept the edit.

r
te
3. Change Lisa Fitzpatrick’s phone a. Position the insertion point in any field
number from (607) 555–3310 to in the LastName column.
(585) 555–5595.
b. Choose Edit→Find to display the Find And
Replace dialog box.

a
y
op
eM
tC
c. Verify that the following criteria are
No
selected:
c
• Look In: LastName
• Match: Whole Field
n

• Search: All
Do

d. In the Find What text box, type


e

Fitzpatrick and then click Find Next to


locate Lisa Fitzpatrick’s record.
se
r

e. Click Cancel to close the Find And


Replace dialog box.
fe
ea

f. With the insertion point located in Lisa


Fitzpatrick’s record, press Tab six times
to the HomePhone field and change the
value to (585) 555–5595
Pl
Re

g. Press the down arrow to accept the


change.

32 Microsoft® Office Access 2003 - Level 1


LESSON 2
4. Use the Find And Replace option to a. Position the insertion point in the
change Lisa Fitzpatrick’s last name LastName column.
to Fitzgerald and close the
database.
b. On the toolbar, click the Find button
to launch the Find And Replace Dia-

al
log Box. Select the Replace tab.

c. With Fitzpatrick in the Find What text


box, type Fitzgerald in the Replace With

i
text box.

r
d. Click Find Next.

te
e. Click Replace.

f. Click Cancel to close the Find And


Replace dialog box.

a
y
g. Close tblEmployees. If prompted to save,
click No.

op
eMh. Close the SampleTables.mdb database.

tC
No
TOPIC F
c

Run a Report
n
Do

You’ve used forms and queries to make working with table data easier and more efficient.
e

You’ve even combined the skills to create an easy-to-use updating technique. Now it’s time to
add the finishing touch. In this topic, you will run a report that displays your data as a profes-
sionally formatted presentation.
se
r

You have been invited to a sales meeting and asked to distribute a listing of company prod-
ucts, organized by product line. This can be done by sorting the table or using different queries
fe

for each product line, but neither displays the data in a format you like. By running an Access
ea

report, you can produce a professionally formatted presentation you will be proud to distribute.

How to Run a Report


Pl
Re

Procedure Reference: Run a Report


To run a report:
1. In the Database window, in the Objects pane, select Reports.
2. Run a report:

Lesson 2: Managing Data 33


LESSON 2
• Double-click the report you wish to run;
• Or, select the report you wish to run and press Enter.
3. Click Close to close the report.

al
ACTIVITY 2-6
Running a Report

ri
Activity Time:

te
5 minutes

Data Files:
• UseReports.mdb

a
Scenario:

y
The consultant who set up your Access database created several reports and stored them in the

op
eM
UseReports.mdb database so you could get started. You will eventually need to create your
own reports, and the consultant was kind enough to show you how to run the reports he
created. By reviewing the tables that the reports pull data from, you can gain an understanding
that will prepare you to create your own reports.

tC
No
n c
Do
e
se
r
fe
ea
Pl
Re

34 Microsoft® Office Access 2003 - Level 1


LESSON 2
What You Do How You Do It

1. In the UseReports.mdb database, run a. Open the UseReports.mdb database.


the rptFinalReport report.

rial
a te
b. With Reports selected in the Objects

y
pane, double-click rptFinalReport to run
the report.

op
eMc. Use the Zoom feature and size the
report so you can read it.

tC
d. Move though the report, then return to
the top of the first page.
No
2. Was it necessary for any of the tables to be open for the report to run?
c

3. a. In the Departmental Inventory report,


n

Record Rachel Middlebrook’s asset


Do

tag, department number, and pur- locate the entry for Rachel Middlebrook.
chase price.
b. From the entry, record the following
e

information:
• Asset Tag: ___________________
se
r

• Department Number:
___________
fe

• Purchase Price:
ea

_______________

c. Close the report.


Pl
Re

Lesson 2: Managing Data 35


LESSON 2
4. Open tblComputers and locate the a. Open tblComputers.
Asset Tag and purchase price you
recorded.
b. Locate the asset tag number you
recorded.

al
c. Locate the purchase price and compare
it with the purchase price you recorded
to verify that they match.

i
d. Close tblComputers.

r
5. Verify that Rachel Middlebrook’s a. Open the tblEmployees table.

te
department number in the report
matches the one in the table.
b. Locate Rachel Middlebrook’s record.

c. Locate the department number and


compare it with the number you

a
recorded to verify that they are the

y
same.

op
eM d. Close tblEmployees.

e. Close the database.

tC
6. Did the information that appeared in the report come from a single table?
No
c
7. Why was it possible for the report to draw information from more than one table?
n
Do
e

Lesson 2 Follow-up
se
r

In this lesson, you worked directly within an Access table to manage the table’s data. You then
fe

used forms, queries, and reports to indirectly manage table data.


ea

1. What types of operations can you perform on a table with an Access form?
Pl
Re

2. How would you display a recordset?

36 Microsoft® Office Access 2003 - Level 1


LESSON 3

al
LESSON 3 Lesson Time
45 minutes

ri
Establishing Table

te
Relationships

a
y
op
Lesson Objectives: eM
In this lesson, you will examine existing table relationships.

tC
You will:
• Examine tables with established relationships.
• Identify a table’s primary and foreign keys.
• Examine and work with a table’s Subdatasheets.
No
n c
Do
e
se
r
fe
ea
Pl
Re

Lesson 3: Establishing Table Relationships 37


LESSON 3
Introduction
As you have learned, the heart of any Access database is the table. Because Access is a rela-
tional database, it allows the data in different tables to be connected. This is a powerful
concept that allows you to make use of the data in various tables, as if they were in a single

al
table. In this lesson, you will learn how tables are connected and about an Access feature that
allows you to create a quick summary of the data from the linked tables.
In a relational database, information you need often resides in several tables. Opening and
searching for information in multiple tables can be time-consuming. However, Access allows

i
tables to be connected and provides you with a feature that allows you to gather and summa-
rize the information from the different tables in one convenient location.

r
te
TOPIC A
Identify Table Relationships

a
y
Using the form, query, and report objects, you have managed the records in a table. But work-

op
eM
ing with the data in a single table only scratches the surface of the Access program. Because
Access is a relational database, separate tables can be connected, allowing the user to make
use of information in multiple tables. In this topic you will be introduced to tables with con-
nections and launch a window with a visual display of the relationships.

tC
Organizing complex data is the job of a relational database. For example, if your business has
five product lines with 50 products in each line, organizing and displaying this in a single table
could become overwhelmingly complex. By creating one table that holds information on the
No
individual products, then connecting it to the appropriate product lines in a second table, you
can manage any individual product in any product line in a simplified manner. Understanding
c
how tables are connected and how to display the connections will allow you to make full use
of the relational concept.
n
Do

Table Relationships and the Relationships Window


e

Definition:
The purpose of relationships between tables is to link one set of information to another
set of information.
se
r

Example:
fe

The Access Relationships window is a graphic display of these relationships. The lines
ea

that connect the tables provide a visual indication of how the relationships work.
Pl
Re

38 Microsoft® Office Access 2003 - Level 1


LESSON 3

rial
te
Figure 3-1: The Relationships window.

a
y
Analogy:
A highway system connecting Chicago, Dallas, New York, Los Angeles, San Francisco,

op
eM
and Miami allows people to travel between the cities. However, from your perspective
the system is not visible. A satellite image displaying the highway connections would
be similar to that of the Relationships window, displaying the links between the tables
in a database.

tC
ACTIVITY 3-1 No
c
Using the Relationships Window to Identify Table
Relationships
n
Do

Activity Time:
5 minutes
e

Data Files:

se

Computers.mdb
r

Scenario:
fe

If you could see a picture of how the tables are connected to one another it would help illus-
ea

trate how a relational database works. By launching the Computers.mdb database and opening
the Relationships window, a visual representation of the table connections will be displayed on
your screen. This is just what you are looking for.
Pl
Re

Lesson 3: Establishing Table Relationships 39


LESSON 3
What You Do How You Do It

1. Open the Computers database and a. Open the Computers database.


the Relationships window.

rial
a te
b. On the toolbar, click the Relationships

y
button to launch the Relationships
window. This displays a graphic represen-

op
eM tation of the links between tables.

c. If necessary, maximize the window and

tC
resize the table displays so all of the
tables and connections in the display are
visible.

2.
No
According to the Relationships window, how many tables are connected in this data-
base?
c
a) One
b) Three
n

c) Five
Do

d) Seven
e

3. How many tables have more than one link to them?


a) One
se
r

b) Two
c) Three
fe

d) Four
ea

4. How many have more than two links?


a) One
Pl
Re

b) Two
c) Three
d) Four

40 Microsoft® Office Access 2003 - Level 1


LESSON 3
5. In the Relationships window, to which table(s) is the tblNotes table linked?
a) tblComputers
b) tblDepartments
c) tblEmployees

al
d) tblManufacturers
e) tblNotes

ri
TOPIC B

te
Identify Primary and Foreign Keys in

a
the Relationships Window

y
op
eM
You have launched the Relationships window and displayed the connections between the tables
in your database. There are field names that are bold and different symbols displayed at the
end points of the connecting lines. In this topic, you will examine the properties of the indi-
vidual links that connect the tables.

tC
Much of the power of a relational database is derived from the ability to connect information
in different tables. The field is the point of connection. In order to establish the proper relation-
ships, the connected fields have a differing status that is displayed in the Relationships
window. In order to access the information in the linked tables, you must identify the status of
No
the keys that make up the table connections.
c
Primary Keys
n
Do

A primary key is a field or combination of fields containing a value that uniquely identifies a
record. Primary keys are set in table Design view and identified by the small key icon to the
left of the field name.
e

Primary Key Characteristics


se

The following list describes several characteristics and functions of primary keys:
r

• Primary keys are not required, but are strongly recommended in each table.
fe

• Table relationships with referential integrity cannot be set without establishing


ea

primary keys.
• When creating subforms or subreports at the same time as a form or report, the
Access wizards rely upon primary keys for form and report creation.
Pl
Re

Foreign Keys
A foreign key is a field in one table that links to a primary key in another table.

Lesson 3: Establishing Table Relationships 41


LESSON 3
How to Identify the Keys in Table Relationships
Procedure Reference: Identify Primary and Foreign Keys
To identify primary and foreign keys in the Relationships window:

al
1. Open the database.
2. On the toolbar, click the Relationships button.
3. Observe the links and keys. At a link’s termination point (on either end), a bold

i
field name represents a primary key, and a non-bold field name represents a for-
eign key.

r
te
ACTIVITY 3-2
Identifying the Keys in Table Relationships

a
y
Activity Time:

op
10 minutes

Setup:
eM
The Computers.mdb database is open and the Relationships window is displayed.

tC
Scenario:
You wish to learn more about the links between the tables, what they mean, and how to read
them. To do so, you will review some examples and identify the different types of keys that
comprise the links.
No
c
What You Do How You Do It
n

1. Identify the Primary and Foreign a. Examine the Relationships window and
Do

keys in the Relationships window. verify that there are links between all of
the tables.
e

2. In tblDepartments, what type of key is DeptCode in the tblDepartments–tblEmployees


relationship?
se
r

a) Primary key
b) Foreign key
fe

c) Primary and foreign key


ea

3. In tblEmployees, what type of key is DeptCode in the tblDepartments–tblEmployees


relationship?
Pl
Re

a) Primary key
b) Foreign key
c) Primary and foreign key

42 Microsoft® Office Access 2003 - Level 1


LESSON 3
4. In the tblComputers–tblNotes relationship, in which table is AssetTag a primary key?
a) tblComputers
b) tblNotes
c) Neither

al
d) Both

A Primary key can consist of multiple fields.

i
5. Close the Relationships window. a. Click Close.

r
b. If prompted, do not save your changes.

a te
y
TOPIC C

op
Work with Subdatasheets
eM
tC
Understanding how tables are linked and what the purpose of the primary and foreign keys are
in a table lets you identify and evaluate the possible relationships between tables. This helps
you comprehend what is going on behind the scenes if you are working in a table and access-
ing the information in a table to which it is linked. In this topic, from an individual record in a
No
table, you will launch a window that displays information from a linked table.
c
Understanding and knowing how Access tables are linked and evaluating the links between
tables is a great starting point. But, if you are working in one table and you need to view the
data in another linked table, how can you display it? The subdatasheet feature allows you to
n

launch a window from any record that is linked to another table and display the data from the
Do

linked table.
e

Subdatasheets
se
r

Definition:
A subdatasheet is a datasheet that is nested within another datasheet and that contains
fe

data related or joined to the first datasheet. The subdatasheet is launched and the data
ea

in the joined table is displayed when the plus sign in the left column is clicked. The
plus sign (+) in the first table is changed to a minus sign (–) when the subdatasheet is
opened and then returns to a plus sign when the subdatasheet is closed.
Pl
Re

Example:
In the following figure, the tblCustomers table is a datasheet that contains ID, name,
and contact information for a company’s customer base. By expanding the
subdatasheet under one of the customer records, that customer’s ordering history
becomes visible.

Lesson 3: Establishing Table Relationships 43


LESSON 3

rial
te
Figure 3-2: A subdatasheet.

a
y
How to Find Data in Subdatasheets

op
eM
Procedure Reference: Find Data in Subdatasheets
To expand and collapse a subdatasheet:

tC
1. Open the table you wish to use.
2. Locate the record you wish to view.
3. Click the plus sign (+) to the left of the record to expand the subdatasheet.
No
4. Click the minus sign (–) to the left of the record to collapse the subdatasheet.
c
5. Close the table.
n
Do
e
se
r
fe
ea
Pl
Re

44 Microsoft® Office Access 2003 - Level 1


LESSON 3
ACTIVITY 3-3
Viewing Data in Subdatasheets

al
Activity Time:
5 minutes

i
Setup:

r
The Computers.mdb database is open.

te
Scenario:
You’ve been asked to locate purchase prices and warranty information on the company’s
computers. The only information you’ve been given are the employee’s names. You thought
there was a report, but there isn’t. The information you need is contained in the tblEmployees
tables.

a
y
What You Do How You Do It

op
1. Open the tblComputers table and
locate the purchase price of Lynne
McMillan’s computer, and then
close the table.
eMa. Open the tblComputers table.

b. Attempt to locate Lynne McMillan’s com-

tC
puter in the table. While the information
you need is in there, there is no way to
identify it.

c. Close tblComputers.
No
n c
Do
e
se
r
fe
ea
Pl
Re

Lesson 3: Establishing Table Relationships 45


LESSON 3
2. Open tblEmployees, locate Lynne a. Open tblEmployees.
McMillan, and record her Employee
ID number. Then, expand her
subdatasheet and record the pur- b. Locate Lynne McMillan’s record.
chase price of her computer.

al
c. From tblEmployees, record her Employee
ID: _______________.

d. In the column to the left, click the plus


sign and expand the subdatasheet.

ri
a te
y
Notice that the plus sign turns to a minus sign indi-
cating it is expanded.

op
eM e. Record the computer’s purchase price:
_______________.

tC
f. Close the table without saving changes.

3. If prompted, open tblComputers and a. Open tblComputers.


No
verify that the purchase price in
c
the table matches the value in the
b. Locate Lynne McMillan’s employee ID.
subdatasheet. Then, close the table
without saving.
n

You can use the Find button and search in the


Do

EmployeeID column.
e

c. Verify that the value in the


PurchasePrice field matches the value
you recorded from the subdatasheet.
se
r

The values displayed in the subdatasheet were


fe

extracted from the tblComputers table.


ea

d. Close tblComputers. If prompted, don’t


save changes.
Pl
Re

e. Close the database.

46 Microsoft® Office Access 2003 - Level 1


LESSON 3
4. Display the tblEmployees table and a. Display the tblEmployees table.
expand the subdatasheets for Eric
Haygood and Norman Grakowsky.
b. In the tblEmployees table, locate Eric
Haygood’s record.

al
c. Click the plus sign in the left column to
display the subdatasheet.

d. Locate Norman Grakowsky’s record.

ri
e. Click the plus sign in the left column to
display the subdatasheet, and notice that

te
all of the subdatasheets you’ve opened
remain open.

f. Close tblEmployees and the Computers


database.

a
y
op
Lesson 3 Follow-up
eM
tC
In this lesson, you launched the Relationships window and displayed and examined the links
that connect the tables in an Access database.
1. What window do you open to display the links between the tables in an Access data-
base, and how are the links represented in the display?
No
c
2. What are the two types of keys that can be used to designate connections between
n

linked tables?
Do
e
se
r
fe
ea
Pl
Re

Lesson 3: Establishing Table Relationships 47


NOTES

rial
a te
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re

48 Microsoft® Office Access 2003 - Level 1


LESSON 4

al
LESSON 4 Lesson Time
1 hour(s), 15 minutes

ri
Querying the Database

a te
Lesson Objectives:

y
op
In this lesson, you will query the database.
You will:

eM
Use the Access Query Wizard to create and name a query.

tC
• Add selection criteria to the query using Design view.
• Add a calculated field to an Access query.
• Modify a query to perform a summary calculation on a record grouping.
No
n c
Do
e
se
r
fe
ea
Pl
Re

Lesson 4: Querying the Database 49


LESSON 4
Introduction
In a previous lesson, you were introduced to the tools used to manage table data. One of the
tools was a query. A query is a question that searches a database for information matching a
specific set of conditions that you define. Queries can be developed and customized to your

al
needs, then saved in the database and used whenever needed. This lesson will expand your
Access knowledge to include creating and customizing queries.
Extracting data is another one of the most common operations performed on a database. Open-
ing a table and searching through it one record at a time is inefficient, not to mention tiring.

i
There’s also the potential of introducing errors into your results. By creating a query you will
have a customized, stored tool that can be used to accurately retrieve database information that

r
meets specified criteria, whenever you need it.

te
TOPIC A

a
Create a Select Query

y
op
eM
There are several different types of queries. Some are quite restricted in what they can do and
you may not have a use for them at this point in your Access career. However, the most com-
monly used query, and the one you have already seen, is the Select query. In this topic, you
will identify the different ways in which Select queries can assist you in performing your daily

tC
database responsibilities. You will also use the Query Design Wizard to create a query.
If you are like most users, after you become comfortable with Access you will begin thinking
about ways to improve your daily operations. Querying databases to locate and manage infor-
No
mation is one of the most common tasks you perform. Having used existing queries, you have
likely thought of ideas for new queries that would make your life easier. By using the Query
c
Design Wizard, you can create those custom queries and bring your dreams to life.
n

The Query Design Environment


Do

A Select query is an Access object that selects and displays data that meets user-defined crite-
ria from a table. The query may be viewed in Datasheet or Design view. When in Design
e

view, the query’s structure, properties, and function may be modified.


se
r
fe
ea
Pl
Re

Figure 4-1: A query displayed in Design view.

50 Microsoft® Office Access 2003 - Level 1


LESSON 4
The Query Design Buttons
The following table describes a few of the buttons on the Query Design toolbar.

Icon Button Name Description

al
Query Type Selects the query type.

Run Runs the query and displays the results.

ri
Show Table Opens the Show Table dialog box.

te
Totals Adds the Totals row to the query in
Design view.

Properties Opens the query property sheet.

a
y
Build Launches the Expression Builder.

op
eM
ACTIVITY 4-1
Examining the Select Query Type
tC
No
c
Activity Time:
5 minutes
n
Do

Data Files:
• SelectQueries.mdb
e

Scenario:
Your manager has asked you to find out which of the company’s computers aren’t covered by
se
r

a warranty. You decide to use a Select query in order to quickly gather this information.
fe
ea
Pl
Re

Lesson 4: Querying the Database 51


LESSON 4
What You Do How You Do It

1. In the SelectQueries database, open a. Open the SelectQueries database.


the qryNoWarranty query and
examine the datasheet, and then

al
switch to Design view.

ri
a te
b. With Queries selected in the Objects

y
pane, double-click qryNoWarranty to
open the query.

op
eM c. Examine the datasheet. There are seven
computers without warranties.

tC
No
n c
Do
e

d. Click the View button to change to


Design view.
se
r
fe
ea
Pl
Re

52 Microsoft® Office Access 2003 - Level 1


LESSON 4
2. In the Warranty column, change the a. In the design grid, in the Criteria row of
criteria from No to Yes and run the the Warranty field, select No.
query.
b. Replace it with Yes

al
c. Click the View button to return to
Datasheet view.

3. How many records are now displayed?

i
a) 7

r
b) 12
c) 19

te
d) 25

4. Close the qryNoWarranty query a. Click Close.


window without saving changes to

a
the design of the query.
b. Click No.

y
op
How to Create a Select Query
eM
tC
Procedure Reference: Create a Select Query
To create a query using the wizard: No
1. In the Database window, in the Objects pane, select Queries.
c
2. Double-click Create Query By Using Wizard.
3. Select the first table (or query) you wish to include in the query.
n

4. Add the fields you wish to include to the Selected Fields list.
Do

5. Repeat steps 3 and 4 if you want to include any additional tables (or queries).
e

6. Click Next.
7. Select whether you want to view detail or summary information.
se
r

8. Click Next.
9. Name the query and select whether you want to open the query in Datasheet view
fe

or Design view.
ea

10. Click Finish.


Pl
Re

Lesson 4: Querying the Database 53


LESSON 4
ACTIVITY 4-2
Creating a Select Query

al
Activity Time:
10 minutes

i
Setup:

r
The SelectQueries.mdb database is open.

te
Scenario:
You have been asked to produce a list of computers that includes the asset tag, manufacturer,
date received, and purchase price. You will need data from fields in the tblComputers and
tblManufacturers tables. By using the Query Wizard, you can create a query to locate and dis-
play the required data.

a
y
What You Do How You Do It

op
1. eM
Launch the Query Wizard. a. With Queries selected in the Objects
pane, double-click Create Query By
Using Wizard.

tC
2. Using tblComputers, add the a. From the Tables/Queries drop-down list,
AssetTag, DateReceived, and select Table: tblComputers.
PurchasePrice fields to the Selected
Fields box.
No
n c
Do
e

b. Click the right-pointing single arrow to


add the AssetTag field to the Selected
Fields box.
se
r

c. In the Available Fields list box, select


fe

DateReceived.
ea

d. Click the right-pointing arrow.


Pl
Re

54 Microsoft® Office Access 2003 - Level 1


LESSON 4
e. In the Available Fields list box, double-
click PurchasePrice.

rial
3. Using the tblManufacturers table, a. From the Tables/Queries drop-down list,
add the Manufacturer field to the select Table: tblManufacturers.

te
query.
b. In the Available Fields list box, double-
click Manufacturer.

c. Click Next.

a
y
4. Verify that you want to see the a. Verify that Detail is selected, and then

op
detail records and continue. click Next.

5. Give your query a title of


qryMyBrands, complete the process
eM
a. In the title text box, enter qryMyBrands
as the name of the query.

tC
and view the results of the query,
and then examine the query in
Design view. b. Verify that Open The Query To View
Information is selected and click Finish.
No
c. In the toolbar, click the View button to
c
change to Design view. The two tables are
displayed and are joined on the
ManufacturerID field. The fields you
n

selected in the wizard are in the design


Do

grid.
e
se
r
fe
ea
Pl
Re

d. Close the query.

Lesson 4: Querying the Database 55


LESSON 4
TOPIC B
Add Criteria to a Query

al
Even though you have now developed a Select query, the surface has just been scratched when
it comes to querying. In this topic, you will look at the comparison operators and conditional
operators that are used in Access queries to make them even more useful.

i
Let’s say you have been asked to locate all of the records with an hourly rate of pay greater
than $40 per hour, all of the records with work hours less than 30, and then a listing of the

r
records for employees who work less than 30 hours and whose pay is greater than $40 per
hour. You know the information is in the database and that a query is the tool you need to

te
extract it, but how do you do it? By incorporating comparison operators and conditional opera-
tors into your query, you’ll be able to access this information.

Comparison Operators

a
y
Including the comparison operators in an expression allows one data value to be compared
against another, using a set of criteria that has been defined by the user. (An expression is a

op
The Comparison Operators
eM
combination of symbols that produces a result. You’ll learn more about them in the next topic.)

The following table summarizes the comparison operators.

tC
Operator Value Example
= Equals = 11/29/1961
No
c
< Less than <K
<= Less than or equal to <= 2500
> Greater than >K
n

>- Greater than or equal to >- 2500


Do

<> Not equal to <> Michigan


Between And Within a range Between 5/1/2001 And 8/31/2001
e

Is Null Null values Is Null (just using “Null” will also


work)
se
r
fe

Conditional Operators
ea

The AND, OR, and NOT conditional operators, also referred to as logical operators and
Booleans, add the ability to evaluate the truth of an expression, thus increasing its flexibility
Pl

and power.
Re

The Conditional Operators


The following table summarizes the conditional operators.

56 Microsoft® Office Access 2003 - Level 1


LESSON 4
Operator Description Example
AND True if both conditions are true > 5 AND <> 100
OR True if either condition is true < 5 OR > 500

al
NOT True if the single instance is not true NOT Between 100 And 200

i
Examples of Conditional Operators
The premise on which conditionals are based is that of truth. If the criteria in the

r
expression are met, it is evaluated to be true. If the criteria is not met, it is evaluated
to be false.

te
The Access query grid provides multiple rows in which one can identify what records
are desired in the results. For example, if you wanted to select all the records where a
price field is greater than $100, you could type >100 in the criteria row that is below
the price field. Using ANDs and ORs would allow you to expand or narrow the search.

a
If you want to select all the records where the price field is greater than $100 AND

y
where the location of the sale is the state of California, you would add the word Cali-
fornia to the criteria row below the State field. Both criteria should be placed on the

op
eM
same line. This automatically creates an AND condition. An AND condition narrows
the search, and the records that are selected must meet all the criteria in order to be
returned.
Putting criteria on a different line creates an OR condition, which expands the search.

tC
Using the previous example, if you were to move the word California down one row
and across from the word or, to the left of the grid area, the query would return all the
records where the price field is greater than $100 as well as all records where the state
field is equal to California. Some prices may well be less than $100—but if they are in
No
California, they meet the criteria. Some sales may be in Michigan, but as long as they
c
are over $100, they meet the criteria.
AND and OR criteria may also be typed directly in the same cell. For example, one
could type California or Michigan in a state criteria row to return all records from
n

either state. Typing California and Michigan in a state criteria row would return no
Do

records, because the value in the state field cannot be equal to both.
e

How to Add Selection Conditions to the Query


se
r

Procedure Reference: Add Selection Conditions to the Query


To add selection criteria:
fe

In the design grid, include the field or fields for which you want to set criteria.
ea

1.
2. Enter the first criterion in the Criteria row for the field.
3. To create an AND or OR condition on a single field, include the appropriate word
Pl
Re

in the criteria.
4. To create an AND condition on more than one field, enter the other criteria in the
same Criteria row.
5. To create an OR condition on more than one field, enter the other criteria in the
Or row.

Lesson 4: Querying the Database 57


LESSON 4
ACTIVITY 4-3
Adding Selection Conditions to the Query

al
Activity Time:
10 minutes

i
Setup:

r
The SelectQueries Database window is displayed.

te
Scenario:
Comparison operators and conditional operators allow you to perform powerful searches, but
can be confusing. Practicing with the queries in the SelectQueries.mdb database and using
comparison operators and conditionals to search for computers that meet specific price, depart-
ment code, or manufacturer criteria, and even looking for Null or blank fields in records will

a
familiarize you with the operation of these features.

y
What You Do How You Do It

op
1.
eM
Run the qryInventory query. a. Double-click qryInventory.

tC
2. How many records are displayed?
a) 11
b) 21
c) 23
No
d) 32
c
3. In Design view, use the > compari- a. Click the Design view button.
n

son operator in the PurchasePrice


Do

field’s Criteria row to determine


b. Scroll to the right to view the
which computers cost more than
PurchasePrice field in the design grid.
$2,000, and then run the query.
e

c. Click in the Criteria row for the


PurchasePrice field.
se
r

d. Type >2000
fe
ea

e. Click the Datasheet view button and


note that six records satisfy the condition.
Pl
Re

58 Microsoft® Office Access 2003 - Level 1


LESSON 4
4. Remove the PurchasePrice criteria a. Switch to Design view.
and set the DeptCode equal to 500,
choose to not display the DeptCode
field in the query datasheet, and b. In the PurchasePrice field, delete the
then run the query. >2000 criteria.

al
You do not have to enter the equal sign =
c. Click in the Criteria row for the
in the criteria, and you do not have to DeptCode field.
display the field you use to set a
condition.
d. Type 500

ri
e. In the Show row, uncheck the box for the
DeptCode field.

te
f. Switch to Datasheet view and observe
the data.

5. Switch to Design view, and in the a. Switch to Design view.

a
Manufacturer field’s Criteria row

y
enter Atlas to add Atlas to the
criteria. Then, return to Datasheet b. Click in the Criteria row for the Manu-

op
view. eM facturer field.

c. Type Atlas

tC
d. Switch to Datasheet view.

e. Examine the results. Only two records


satisfy this condition. By entering two
No
conditions on the same Criteria row in the
c
design grid, you create an AND condition
and records must satisfy both conditions
to be displayed in the query datasheet.
n
Do

6. Switch to Design view and delete a. Switch to Design view.


the existing condition in the Crite-
e

ria row of the Manufacturer field,


click in the Or row of the Manufac- b. In the Criteria row of the Manufacturer
turer field and enter the field, delete the existing condition.
se

manufacturer name Cyber, and


r

then switch to Datasheet view to c. In the Manufacturer field, click in the Or


run the query and examine the row.
fe

results.
ea

d. Type Cyber
Remember that you can create AND and
OR conditions for the same field by
including those operators in the criteria. e. Switch to Datasheet view to run the
Pl
Re

For example, if you wanted to know how query.


many Atlas and Cyber computers you
have, you can enter the criteria “Atlas or
Cyber.”

Lesson 4: Querying the Database 59


LESSON 4
7. How many records are displayed?
a) 5
b) 10
c) 15

al
d) 20

All computers assigned to the Technical Services department are included, as well as
records for Cyber computers assigned to any department.

i
8. Use the Between operator to create a. Switch to Design view.

r
the criteria to determine how many
computers were acquired during
b. Delete the Cyber and 500 criteria.

te
the first quarter of 2001.

Access automatically enters pound signs


c. Click in the Criteria row for the
(#) around date values. DateReceived field.

a
d. Type Between 1/1/2001 And 3/30/2001

y
e. Run the query and verify that six

op
9.
eM
Use the Null operator to create a
records are displayed.

a. Switch to Design view.

tC
criterion in the tblComputers table
to locate records with a blank value
b. In the upper pane, right-click the
and save the query as
qryMyMissingValues. tblDepartments table.
No
c. Choose Remove Table.
c
d. Remove the tblManufacturers table from
the query.
n
Do

e. In the DateReceived field, delete the


criteria.
e

f. In the Criteria row for the ManufacturerID


field, type Is Null
se
r

g. Run the query and note that there are


fe

three records.
ea

h. Save the query as qryMyMissingValues


and click OK.
Pl
Re

i. Close the query window.

60 Microsoft® Office Access 2003 - Level 1


LESSON 4
TOPIC C
Add a Calculated Field to a Query

al
The ability to use Access comparison operators and conditional operators has greatly expanded
your querying capacity. Now let’s start using the values in a record to produce a result that is
not in the record. In this topic, you will use arithmetic operators to create a query to perform a
calculation on a value in a record and then display the results of the calculation in the query’s

i
output.

r
Managing money is an important function in all businesses, and for that matter, in your day-to-
day life. Imagine that your company’s payroll department wants you to calculate the weekly

te
salary for an individual who is paid by the hour. By including a calculated field that uses the
employee’s hourly rate, this is easily accomplished.

Arithmetic Operators

a
y
Arithmetic operators are used to perform operations on table data. The arithmetic operators
used in Access are the same operators used by other programs and applications, and they

op
behave in a similar manner.

The Arithmetic Operators


eM
The following table summarizes the arithmetic operators.

tC
Operator Description Example Result
+ Addition value1 + value2 Value1 is added to value2
No
c
- Subtraction value1 - value2 Value2 is subtracted from value1
* Multiplication value1 * value2 Value1 is multiplied by value2
/ Division value1 / value2 Value1 is divided by value2
n
Do

Access Expressions
e

Simply put, Access expressions are combinations of identifiers, operators, and values that pro-
se

duce a result. Arithmetic expressions are composed of table data and the arithmetic operators +
r

- * / . An expression may be simple or complex, but it usually results in a single value. The
calculations are performed in a specific order, with the order of evaluation taking place from
fe

left to right. Precedence is dictated by the operators, in the following order:


ea

1. Multiplication
2. Division
Pl

3. Addition
Re

4. Subtraction
If a portion of the expression is enclosed in parentheses, that portion is evaluated first. If there
are nested sets of parentheses, the innermost set is evaluated first.

Lesson 4: Querying the Database 61


LESSON 4
ACTIVITY 4-4
Calculating Arithmetic Expressions

al
Activity Time:
5 minutes

i
Scenario:

r
You have been asked to incorporate several calculations in your query. Practicing with order of
operation in expressions will help you accurately incorporate the calculations.

te
What You Do How You Do It

1. What is the answer to: 4 + (3 * 5)?


a) 12

a
b) 14

y
c) 17

op
d) 19
e) 35
eM
tC
2. What is the answer to: (4 + 3) * 5?
a) 35
b) 12 No
c) 19
c
d) 17
e) 60
n
Do
e

The Expression Builder


The Expression Builder is a tool that allows the user to select database objects and then, using
se
r

the application’s built-in operators and functions, build formulas and calculations that are used
with queries and reports.
fe
ea
Pl
Re

62 Microsoft® Office Access 2003 - Level 1


LESSON 4

rial
a te
y
op
Figure 4-2: The Expression Builder. eM
The following table describes the components that comprise the Expression Builder.

tC
Component Function
Expression box The location where the expression is built.
Operator buttons The location where the operators used in the expression are
No
selected.
c
Left box Displays the table, query, form, report object, user-defined
function, and other folders.
Middle box If a left box folder is opened, the middle box will display the
n

elements within that folder.


Do

Right box If a left box folder is opened and a category in the middle box
is selected, the right box will display its related elements.
e
se
r

How to Add a Calculated Field to the Query


fe

Procedure Reference: Add a Calculated Field to a Query


ea

To add an arithmetic calculation:


1. In the query design grid, right-click in the first available blank column.
Pl
Re

2. Choose Build.
3. Using the operator buttons and the lists of fields and functions, select and paste
each component of the expression.
4. Click OK to enter the expression in the design grid.

Lesson 4: Querying the Database 63


LESSON 4
ACTIVITY 4-5
Adding a Calculated Field to the Query

al
Activity Time:
10 minutes

i
Setup:

r
The SelectQueries database is open.

te
Scenario:
You have been asked to modify the qryPayRates query so that it calculates the weekly gross
pay for all employees. By adding a calculated field, you can accomplish this task.

What You Do How You Do It

a
y
1. Open the qryPayRates query in a. Right-click the qryPayRates query.
Design view and run the query.

op
eM b. From the shortcut menu, choose Design
View.

tC
c. Observe the design. It includes a
tblHoursAndRates table and will display a
list of employees and their hours and
rates.
No
c
d. Switch to Datasheet view to run the
query.
n

2. Switch to Design view, right-click in a. Switch to Design view.


Do

the first blank column in the design


grid and use the Expression Builder
b. In the design grid, right-click in the first
to create an arithmetic expression
e

blank column to the right and choose


that multiplies weekly hours by the
Build to open the Expression Builder.
rate of pay, and then run the query
and check the calculation.
se
r

c. In the Expression Builder operator bar,


click the equal sign (=).
fe
ea

d. In the field list (the middle column),


double-click WeeklyHours. Notice that
the field name is added to the expression
and is enclosed in brackets.
Pl
Re

e. In the operator bar, click the multiplica-


tion sign (*).

64 Microsoft® Office Access 2003 - Level 1


LESSON 4
f. In the field list, double-click HourlyRate.

rial
te
g. Click OK to close the Expression Builder.

a
y
h. Run the query.

op
3. What is Rob Abbott’s weekly pay?
a) 56
eM
tC
b) 250
c) 760
d) 2,500 No
Notice that the calculated field has a column heading of Expr1 and the values have a gen-
c
eral number format.

4. Open the Zoom dialog box, change a. Switch to Design view.


n

the name of the calculated field to


Do

WeeklyGross, and then run the


b. Right-click the calculated field and
query.
choose Zoom.
e

c. Select Expr1 and type WeeklyGross


se
r

d. Click OK to close the Zoom dialog box.


fe
ea
Pl
Re

Lesson 4: Querying the Database 65


LESSON 4
e. Run the query to verify that WeeklyGross
is displayed as the column heading.

rial
te
5. Switch to Design view, open the a. Switch to Design view.
Field Properties dialog box for the
WeeklyGross field and set the For-
mat property to Currency, and then b. Right-click the WeeklyGross field and
choose Properties.

a
run the query.

y
c. Click in the Format property box.

op
eM d. From the drop-down list, select
Currency.

tC
e. Click the Close button to close the Field
Properties dialog box.

f. Run the query and observe that the cal-


No
culated values are displayed in currency
c
format.

6. Save the query as a. Save the query as qryMyWeeklyGross


n

qryMyWeeklyGross, and then close


Do

it.
b. Click OK.
e

c. Close the select query.


se
r
fe
ea
Pl
Re

66 Microsoft® Office Access 2003 - Level 1


LESSON 4
TOPIC D
Perform a Calculation on a Record

al
Grouping
You now know how to use a query to perform a calculation on a single record. It is also

i
important that you know how to perform a calculation based on a grouping of related records.
In this topic, you will develop a query that selects a group of records and performs a calcula-

r
tion using all of the values in one of the group’s fields.
One common, on-the-job use for Access is calculating payrolls by department. Developing a

te
query that groups employees by department and then performs a payroll calculation on the
departmental grouping will provide the results you need, and as a bonus, you can save the
query and run it whenever necessary.

a
How to Perform a Calculation on a Group of

y
Records

op
eM
Procedure Reference: Perform a Calculation on a Record Grouping
To perform a calculation on a group of records:

tC
1. To the design grid, add the field(s) on which you want to group records and the
field(s) you wish to summarize.
2. Click the Totals button to display the Total row. No
3. Enter any criteria necessary to select the records you wish to view.
c
4. If you need to enter criteria for a field on which you are not grouping records,
include that field in the design grid and, from the Total drop-down list, select
Where.
n
Do

5. For each field, from the Total drop-down list, select Group By or the summary
function.
e

6. Run the query.


se
r
fe
ea
Pl
Re

Lesson 4: Querying the Database 67


LESSON 4
ACTIVITY 4-6
Performing a Calculation on a Group of Records

al
Activity Time:
10 minutes

i
Setup:

r
SelectQueries.mdb is open.

te
Scenario:
You have been asked by your manager to use the qryWeeklyInfo query to provide the average
weekly hours for employees in each department and the total weekly gross payroll for each
department.

a
What You Do How You Do It

y
1. Run the qryWeeklyInfo query. a. Run the qryWeeklyInfo query.

op
2.
eM
Switch to Design view and, on the
toolbar, click the Totals button to
a. Switch to Design view.

tC
add the Total row to the design
b. Click the Totals button .
grid.

c. Examine the Total row that has been


added to the grid.
No
c
3. Remove the LastName and a. In the design grid, place the mouse
FirstName columns from the design pointer over the selector for the
grid. LastName column until it becomes a
n

downward-pointing arrow and click to


Do

select the column.


e

b. Press Delete.

c. Select and delete the FirstName column.


se
r

4. In the Total row for the WeeklyHours a. Click in the Total row for the
fe

field, enter the appropriate sum- WeeklyHours field.


ea

mary function to calculate the


average weekly hours for each
b. From the drop-down list, select Avg.
department.
Pl
Re

68 Microsoft® Office Access 2003 - Level 1


LESSON 4
5. In the Total row for the WeeklyGross a. Click in the Total row for the
field, enter the summary function WeeklyGross field.
to calculate the total weekly payroll
for each department.
b. From the drop-down list, select Sum.

al
c. Run the query.

d. Compare your results to the following


graphic.

ri
a te
y
op
6. Switch to Design view and modify
the format of the WeeklyHours field
to display the average with one
eM
a. If necessary, size the columns so you can
see the full column headings.

tC
decimal place.
b. Switch to Design view.

c. Right-click the WeeklyHours field and


choose Properties.
No
c
d. Click in the Format property box.
n

e. From the drop-down list, select Fixed.


Do

f. From the Decimal Places drop-down list,


e

select 1.

g. Close the Field Properties dialog box.


se
r

7. Run the query, save the query as a. Run the query.


fe

qryMyTotals and close the


ea

datasheet window, and then close


b. Save the file as qryMyTotals and close
the database window.
the datasheet.
Pl
Re

c. Close the database.

Lesson 4: Querying the Database 69


LESSON 4
Lesson 4 Follow-up
In this lesson, you created a query. Working in a query’s Design view, you also customized
queries by adding comparison and conditional operators. You then used the Expression Builder
to add a calculation to a field. Finally, you performed a calculation on a record grouping.

al
1. What are the two views used with a query, and which view can be used to modify the
query?

i
2. What are the three types of operators used to build query expressions, and how are

r
they used?

a te
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re

70 Microsoft® Office Access 2003 - Level 1


LESSON 5

al
LESSON 5 Lesson Time
1 hour(s)

ri
Designing Forms

a te
Lesson Objectives:

y
op
In this lesson, you will design simple forms.
You will:
• Discuss the form design overview.
eM
tC
• Create a form with the AutoForms feature.
• Create a form with a hidden object using the wizard.
• Select and modify objects on a form to change the design of the form.
No
n c
Do
e
se
r
fe
ea
Pl
Re

Lesson 5: Designing Forms 71


LESSON 5
Introduction
You have seen several different ways to manage data. On the job, you may be required to enter
and update data on a regular basis. A custom form stored in your database that can be recalled
each time you are required to perform these tasks can make life much simpler. In this lesson,

al
you will create custom forms, and then modify the forms to meet your specific needs.
When opening a table in Datasheet view, the entire table, including all of the records and
every field in each record, is displayed. In large tables with thousands of records, this can be
overwhelming. Searching for individual records or fields can be time consuming, and the

i
chance of making an error by misreading a value is increased. Creating a customized Access
form that allows you to view and edit one record at a time will expedite the process and

r
reduce errors.

te
TOPIC A

a
Examine Form Design Guidelines

y
op
eM
You have used a form to enter and edit data in a table. Although an unlimited number of
designs can be applied to a newly developed form, there are basic design principles that should
be applied regardless of the use. Any easy-to-use form with an efficient design will be appreci-
ated by all. In this topic, you will identify some of the design principles that should be applied

tC
to any form.
The form is one of the most often used data management tools. A well-designed form allows
the user to view and enter data in a timely manner with a minimum of mistakes. Using the
No
basic form design principles, you can develop forms that help ensure an efficient and error-free
data entry process.
c
AutoForms
n
Do

An AutoForm is a one-click form creation tool that automatically creates a form displaying
every field in all records from the table or query on which it is based.
e
se
r
fe
ea
Pl
Re

Figure 5-1: An AutoForm.

72 Microsoft® Office Access 2003 - Level 1


LESSON 5
The AutoForm Feature
Creating forms from scratch is often time-consuming and unnecessary. While the
results of the AutoForm aren’t necessarily elegant, the user can usually modify the for-
mat of the form in less time than it would take to build it from scratch. The following
list contains several features of the AutoForm:

al
• It can be used directly on a table or query using the New Object: AutoForm
button.
• By default, the AutoForm button places all fields from the underlying table or
query on the form.

i
• When launched with the New Object: AutoForm button, the final form displays

r
one record per page in what is called the columnar layout.
• When working with multiple tables and/or when only specific fields need to be

te
shown from a table, a query should be created first. The AutoForm button can be
created from the query.
• The AutoForm option is also available from within the form object in the Data-
base window by clicking the New button. This option allows the user to select

a
from multiple layout options.

y
The Form Wizard

op

eM
The Form Wizard is a useful tool for creating a more customized form. The Form Wizard:
Uses guided questions to walk users through the form creation process.

tC
• Can build a form based on more than one table.
• Offers design choices for both tabular and datasheet views.

Form Wizard Layouts


No
The four layouts available in the Form Wizard are summarized in the following table.
c

Form Layout Features


n
Do

Columnar • One record appears per page.


• Navigation buttons used to scroll through records.
e

• Field placement easily modified.


• Ability to modify field controls (e.g., fonts, colors, and background).
se

Tabular • Multiple records appear per page.


r

• Navigation typically done using the scroll bar.


fe

• Field placement can be modified and individual field controls can be


ea

formatted.
Datasheet • Multiple records appear per page.
• Looks and feels like a spreadsheet to the user.
Pl
Re

• Designer has minimal control over field placement and formatting.


Justified • One record appears per page.
• Navigation buttons used to scroll through records.
• Field placement is stacked, starting horizontally and then moving vertically
when they do not all fit within the form’s width.

Lesson 5: Designing Forms 73


LESSON 5
How to Identify the Form Design View
When opened in Design view, a form may consist of three general sections:
• The Header section is where information to be displayed at the top of the form is located.

al
The Detail section is where the record data is contained.
• The Footer section is where the information to be displayed at the bottom of the form is
located.

ri
a te
y
op
eM
tC
Figure 5-2: A form displayed in Design view.

ACTIVITY 5-1
No
c

Examining the Form Design Guidelines


n
Do

Activity Time:
5 minutes
e

Scenario:
se
r

Reviewing some common-sense examples of the form design guidelines can assist you when
you develop your first form.
fe
ea

What You Do How You Do It

1. When designing a form, who should you keep foremost in mind?


a) Your boss
Pl
Re

b) Your co-worker
c) The user
d) The consultant

74 Microsoft® Office Access 2003 - Level 1


LESSON 5
2. In Design view, which section of a form would typically contain page numbering infor-
mation?
a) Header
b) Detail

al
c) Footer

3. Which of the Form Wizard layout styles shows multiple records per page?
a) Columnar

i
b) Tabular

r
c) Datasheet
d) Justified

a te
TOPIC B

y
op
Create a Form Using AutoForm
eM
tC
Now that you have learned about some basic form design principles, imagine that you have
been asked to immediately create a form to enter and edit data. Even knowing the design prin-
ciples, developing the perfect form requires time, which you don’t have. Luckily, the
AutoForm tool will allow you to create a usable form in a minimum amount of time.
No
Even the most experienced form designers need time to plan and create custom forms. Until
c
you have experience developing your own forms, it will take even longer. Perhaps there is an
immediate need for the form, or the form will be used on a temporary basis and you don’t
wish to invest the time to plan and create the perfect form. By using the AutoForm feature,
n

you can quickly create a basic default form that can be used with any designated table.
Do

How to Create an AutoForm


e

Procedure Reference: Create an AutoForm


se
r

To create an AutoForm:
1. In the Database window, in the Objects pane, select Tables.
fe

From the table list, select the table for which you want to create an AutoForm.
ea

2.
3. Click the NewObject: AutoForm button.
4. Save the form.
Pl
Re

Lesson 5: Designing Forms 75


LESSON 5
ACTIVITY 5-2
Creating a Form with the AutoForm Feature

al
Activity Time:
5 minutes

i
Data Files:

r
• UseForms.mdb

te
Scenario:
A co-worker has asked if you can create a form to access data in the UseForms database’s
tblCustomers and tblEmployees tables. By using the AutoForms Wizard, you can produce
forms for both tables.

a
What You Do How You Do It

y
1. a. With the UseForms database open, open

op
Open the tblCustomers table.

2.
eM
Create an AutoForm based on the
the tblCustomers table.

a. On the toolbar, click the New Object:

tC
tblCustomers table. AutoForm button .

3. True or False? The number of fields in the form is the same as the number of
fields in the table.
No
c
4. True or False? New records can be added to the table with the AutoForm you
created.
n

5. Close the form and save it as a. Click the Close button to close the
Do

frmMyCustomers. tblCustomers form.


e

b. Click Yes.

c. Type frmMyCustomers
se
r

d. Click OK.
fe
ea

e. Close tblCustomers.

6. Create an AutoForm based on the a. From the list of tables in the UseForms
Pl
Re

tblEmployees table, with a link to Database window, select tblEmployees.


another table that includes a
subdatasheet display.
b. From the toolbar, click the New Object:
AutoForm button.

76 Microsoft® Office Access 2003 - Level 1


LESSON 5
c. Examine the form.

rial
te
This is a combination of a form and a subform. The
relationship between the two is similar to the rela-
tionship between the datasheet and subdatasheet
that was discussed earlier in the course.

a
y
7. True or False? The subdatasheet will expand if you click the plus sign (+) in
the form.

op
8. Expand the subdatasheet, and then
close the subdatasheet.
eM
a. In the first record displayed in the
AutoForm, click the expand indicator (+)
and notice that related data from a third

tC
table is displayed.

b. Click the collapse indicator (-).


No
c
9. Use the mouse pointer to widen the a. Place the mouse pointer over the right
form window, and then attempt to side of the form window until it
widen the datasheet to view the becomes a horizontal double-headed
entire record. arrow.
n
Do

b. Click and drag the right edge of the form


window to the right.
e

c. Place the mouse pointer over the right


se

edge of the datasheet. The horizontal


r

sizing pointer is not displayed; the size of


the datasheet must be adjusted in the
fe

form’s Design view.


ea

Column widths in the datasheet can be


adjusted by dragging the right edge of the col-
umn heading.
Pl
Re

Lesson 5: Designing Forms 77


LESSON 5
10. Save and close the form. a. Save the form as frmMyEmployees and
close the form.

b. Close any open tables.

ial
TOPIC C

r
te
Create a Form Using the Form Wizard
The AutoForm feature, which is actually an Access wizard, is limited in the design of the
forms it produces. The true power of using a form is derived from an interface that presents

a
data in an easily understood format and provides the user with a virtually error-proof data
entry capability.

y
As the person in your business who has received training in Access, you may be looked upon

op
eM
as the resident Access expert and called upon to create custom forms for the users. With the
Access Form Wizard you will be able to accommodate the requests and develop forms that
display only the information needed, in an easy-to-understand format that reduces data entry
errors.

tC
How to Create a Form with the Form Wizard No
Procedure Reference: Create a Form with the Form Wizard
c
To create a form with the wizard:
1. In the Database window, in the Objects pane, select Forms.
n

2. Double-click Create Form By Using Wizard.


Do

3. From the Tables/Queries drop-down list, select the first data source for the form.
e

4. Add the fields you want in the form to the Selected Fields list.
5. Repeat Steps 3 and 4 for any additional data sources and fields. Click Next.
se
r

6. If you have fields from more than one table, decide how you want the wizard to
organize them. Then decide whether you want subforms or linked forms for the
fe

related data. Click Next.


ea

7. Choose the form layout and click Next.


8. Choose the form style and click Next.
Pl

9. Enter a title for the form and, if necessary, the subform. Select the view in which
Re

you want to open the form.


10. Click Finish.
11. Close the form.

78 Microsoft® Office Access 2003 - Level 1


LESSON 5
ACTIVITY 5-3
Creating a Form with the Form Wizard

al
Activity Time:
10 minutes

i
Setup:

r
The UseForms database is open.

te
Scenario:
This time, your manager has asked you to create a more complex form that displays all of the
fields from the tblEmployees table and the AssetTag, DateReceived, PurchasePrice, and War-
ranty fields from the tblComputers table of the UseForms database. He would also like a
particular layout applied to the finished product. The Form Wizard will allow you to complete

a
this task.

y
What You Do How You Do It

op
1. Start the Form Wizard.
eM
a. In the Objects pane, select Forms.

tC
b. Double-click Create Form By Using
Wizard.

2. Add all the tblEmployees fields to a. From the Tables/Queries drop-down list,
the form, and then, from the
No
select Table: tblEmployees.
tblComputers table, add the
c
AssetTag, DateReceived,
PurchasePrice, and Warranty fields. b. Click the right-pointing double arrow to
add all the fields in the table to the
Selected Fields list.
n
Do

c. From the Tables/Queries drop-down list,


select Table: tblComputers.
e

d. In the Available Fields list, verify that


se
r

AssetTag is selected.
fe

e. Click the right-pointing single arrow.


ea

f. In the Available Fields list, select


DateReceived.
Pl
Re

g. Click the right-pointing single arrow.

Lesson 5: Designing Forms 79


LESSON 5
h. Add the PurchasePrice and Warranty
fields to the Selected Fields list.

rial
te
i. Click Next.

a
3. a. Observe the preview of the form. The

y
Preview the form, decide whether
you want a form with subforms or view is by tblEmployees.

op
linked forms, and select the option
eM
that enables you to open only one
form. Continue to the next page of
the wizard.
b. Select by tblComputers and observe the
preview.

tC
c. Select by tblEmployees.

d. Verify that Form With Subform(s) is


selected and observe the preview.
No
c
e. Select Linked Forms and observe the
preview.
n
Do
e
se
r
fe
ea
Pl
Re

f. Select Form With Subform(s).

g. Click Next.

80 Microsoft® Office Access 2003 - Level 1


LESSON 5
4. Observe the Datasheet layout, and a. Observe the preview for the Datasheet
then select Tabular. Continue to layout.
the next page of the wizard.
b. Select Tabular and observe the preview.

al
c. Click Next.

5. Observe the available styles and a. In the list of styles, select each style and
select a style. Continue to the next observe the preview.

i
page of the wizard.

r
b. Select the style you prefer.

te
c. Click Next.

6. Give the form a title of a. In the Form text box, type


frmMyEmployees2, give the frmMyEmployees2
subform a title of

a
sbfMyComputersSubform, and then

y
open the form. b. In the Subform text box, type
sbfMyComputersSubform

op
eM
c. Verify that Open The Form To View Or
Enter Information is selected.

tC
d. Click Finish and examine the form.

7. Close the form. a. Click Close.


No
n c
Do

TOPIC D
e

Modify the Design of a Form


se
r

As with any creation, there are generally improvements that can be made. Imagine that you
have been asked by users to alter the order and alignment of some of the form’s controls, and
fe

change the title of some of the labels. In this topic, you will modify the size, alignment, posi-
ea

tions, and labels of the controls on your form.


The form you created with the wizard is perfectly usable and fulfills its intended function. But,
after using the form for a while, you’ve identified some possible changes in the design and
Pl
Re

several users have also offered helpful suggestions. A custom form can be seen as a living
object; by modifying the design of your form it will become even more efficient and error-
proof, and you will continue to enhance your reputation as the corporate Access expert.

Lesson 5: Designing Forms 81


LESSON 5
Controls
Definition:
A control is an object that allows the user to control the program. Controls are used to

al
display data, allow user input, or perform an action. Controls are commonly used on
forms and reports. Controls can be selected, sized, aligned, and moved to present a
professional appearance. They generally are labeled with context-significant names so
that their purpose is easily identified by the user.

i
Example:

r
Some examples of controls include text boxes, labels, rectangles, combo boxes, lines,
and graphics.

a te
y
op
eM
tC
No
c
Figure 5-3: Examples of controls.
n

Selecting Form Controls


Do

To modify a form’s controls, they must first be selected. There are four methods of selecting
e

controls:
• Click to select a single control.
se


r

Select contiguous controls with the lasso technique.


• Use the appropriate ruler to select all of the controls in a horizontal or vertical line.
fe

• Use the Shift-click technique to select non-contiguous controls.


ea
Pl
Re

82 Microsoft® Office Access 2003 - Level 1


LESSON 5
ACTIVITY 5-4
Selecting Controls

al
Activity Time:
5 minutes

i
Setup:

r
The UseForms.mdb database is open.

te
Scenario:
Your manager wants you to customize your form. First you need to learn how to work in the
form design environment. When you open a form in Design view, you realize that you need
practice selecting the controls that are on the form. Using the different selection techniques to
select controls on the frmSelectControls form will prepare you to move controls on other

a
forms.

y
What You Do How You Do It

op
1. Open the frmSelectControls form in
Design view and select the text box
control holding the CustomerName
eM
a. Open the frmSelectControls form in
Design view.

tC
field, and then select the label con-
trol for the field. b. Click the text box containing the
CustomerName field. Note that the con-
trol has selection handles on all sides.
No
n c
Do

c. Click the label control for the


CustomerName field. The label control
e

has selection handles and the text box has


only a move handle.
se
r
fe
ea

2. Use the lasso technique to select a. Position the mouse pointer above and to
Pl

controls and observe the selection the left of the CustomerName label.
Re

handles, and then deselect the


controls.

Lesson 5: Designing Forms 83


LESSON 5
b. Click and drag to draw a rectangle that
touches the CustomerName label in the
upper-left and the Fax text box in the
lower-right. Note that all the controls
have selection handles.

rial
te
c. Click a blank portion of the form to
deselect the controls.

3. Use the click-in-ruler technique to a. Click the vertical ruler at the 1.75-inch
select the labels and text boxes, mark and observe the selection handles.

a
observe the selection handles, and

y
then deselect the controls.

op
eM
tC
No
c
b. Click a blank portion of the form to
deselect the controls.
n
Do
e
se
r
fe
ea
Pl
Re

84 Microsoft® Office Access 2003 - Level 1


LESSON 5
4. Using the ruler to select the labels a. Click at the 0.5-inch mark on the hori-
and text boxes, observe the selec- zontal ruler.
tion handles and deselect the
controls.

rial
a te
y
b. Click and drag the 0.5-inch mark on the
horizontal ruler to about the 1.5-inch

op
eM mark and observe the selection handles.

c. Deselect the controls.

tC
5. Using the Shift-click technique to a. Click the CustomerID text box.
select controls, observe the selec-
tion handles and deselect the
b. Press and hold the Shift key, and then
controls.
No
click both the Fax text box and the
PostalCode text box.
c
c. Release the Shift key.
n
Do

d. Click a blank area to deselect the


controls.
e
se
r

Sizing Form Controls


fe

Sizing controls to be proportionate to their use is a critical design component. There are three
ea

methods of sizing controls:


• Drag a sizing handle to increase or decrease the size.
• From the menu, choose Format→Size→To Fit.
Pl
Re

• Select multiple controls, choose Format→Size, and choose whichever option is


appropriate.

The same options available from the Format menu are available by right-clicking a selected control and
choosing Size from the shortcut menu.

Lesson 5: Designing Forms 85


LESSON 5
ACTIVITY 5-5
Sizing Controls

al
Activity Time:
5 minutes

i
Setup:

r
The frmSelectControls form of the UseForms database is open in Design view.

te
Scenario:
You’ve found that when you create an AutoForm or a form with the wizard, the controls are
not always the right size. Sometimes they’re bigger than you need or they occupy extra space
on the form. Other times, they’re not big enough and you can’t view all of the data from a
field. You want to make them the correct size.

a
y
What You Do How You Do It

op
1. eM
View the data in three records. a. Switch to Form view.

b. On the navigation bar, click the Next

tC
Record button three times.

2. Which text box controls appear to be too small?


a) Address text box
No
b) Postal Code label
c
c) Postal Code text box
d) Region label
n
Do
e
se
r
fe
ea
Pl
Re

86 Microsoft® Office Access 2003 - Level 1


LESSON 5
3. In Design view, resize the a. In Design view, click the CustomerID text
CustomerID and the Address text box.
boxes.
b. Place the mouse pointer over the sizing
handle in the middle of the right side of

al
the text box until it becomes a horizon-
tal double-headed arrow and click and
drag the sizing handle to the left until
the text box is 0.5 inches wide. View
and use the horizontal ruler to judge the

i
width.

r
a te
y
c. Click the Address text box.

op
eM
d. Using the middle sizing handle on the
right side, click and drag to make the
text box about 2 inches wide.

tC
4. Size the PostalCode text box to fit a. Click the PostalCode text box.
its contents.
No
b. Choose Format→Size→To Fit.
c
5. Make the CustomerID text box the a. Click the CustomerID text box.
height of the CustomerName text
n

box, and then undo the sizing.


b. Press and hold the Shift key and click
Do

the Customer Name text box.


e

c. Choose Format→Size→To Tallest.


se

d. Click the Undo button.


r
fe

6. Make the Fax text box the same a. Select the Fax and Phone text boxes.
ea

size as the Phone text box.


b. Right-click one of the selected text
boxes.
Pl
Re

c. Choose Size→To Narrowest.

Lesson 5: Designing Forms 87


LESSON 5
7. Save the form as frmMyControls, a. Choose File→Save As.
and then view the form.
b. Save the form as frmMyControls

al
c. View the form.

i
Aligning and Spacing Form Controls

r
Aligning controls and adjusting the spacing between them improves the appearance of a form
or report. To do this:

te
• Select the controls you want to align and right-click one of them. From the shortcut
menu, choose Align. You can then choose to align the Left, Right, Top, or Bottom sides,
or to align To Grid.
• To even out horizontal or vertical spacing of controls, select the controls and choose

a
either Format→Horizontal Spacing or Format→Vertical Spacing. You can choose to adjust

y
the spacing by selecting Make Equal, Increase, or Decrease.

op
ACTIVITY 5-6
eM
tC
Aligning and Spacing Controls
Activity Time:
No
5 minutes
c
Setup:
The frmSelectControls form of the UseForms database is displayed.
n
Do

Scenario:
The format of frmSelectControls looks better, but the alignment still needs some work. By
e

using alignment techniques you can improve the appearance.


se

What You Do How You Do It


r

1. With frmSelectControls open in a. In Design view, click the horizontal ruler


fe

Design view, align the right side to select the CustomerID, Phone,
ea

label controls. Address, and City label controls.

b. Right-click one of the selected controls


Pl

and choose Align→Right.


Re

88 Microsoft® Office Access 2003 - Level 1


LESSON 5
2. Align the Phone and Fax labels and a. Use the vertical ruler or the lasso tech-
text boxes so the bottoms of the nique to select the Phone and Fax labels
controls are even. and text boxes.

b. Right-click a selected control and choose

al
Align→Bottom.

3. Make the spacing of the City, a. Select the City, Region, Country, and
Region, Country, and PostalCode PostalCode labels and text boxes.

i
labels and text boxes equal.
b. Choose Format→Horizontal Spacing→

r
Make Equal.

te
4. View and then save and close the a. View the form.
form.
b. Save and close the form.

a
y
op
Moving Form Controls eM
In order to move a control, you need to watch for the correct mouse pointer to be displayed.
This change in the mouse pointer will occur as you point to the move handle of the control

tC
you want to move. There are two conditions for moving controls:
• If you want to move just the text box or label, and not its associated component, the
mouse pointer should look like a hand with a single pointing finger .

No
If you want to move the text box or label and its associated component, or a grouping of
c
controls, the mouse pointer should look like a hand with all of the fingers extended
.
n
Do
e
se
r
fe
ea
Pl
Re

Lesson 5: Designing Forms 89


LESSON 5
ACTIVITY 5-7
Moving Controls

al
Activity Time:
10 minutes

i
Setup:

r
The UseForms database is open.

te
Scenario:
A few final movements of some of the controls will improve your form. You are now in the
area where a lot of the improvements are a matter of taste, so getting some feedback from
users is a good idea.

a
What You Do How You Do It

y
1. Move the CustomerName text box a. In the UseForms Database window, right-

op
closer to its label. eM click frmMoveControls and choose
Design View.

b. Select the CustomerName text box.

tC
c. Place the mouse pointer over the move
handle in the upper-left corner of the
text box until it becomes a hand with a
No
pointing finger.
c
d. Click and drag the text box to the left to
place it closer to the CustomerName
n

label.
Do

2. Move the CustomerID label and text a. Click the CustomerID text box.
e

box to the upper-left corner of the


form.
b. Place the mouse pointer over the top or
se

bottom edge of the text box until it


r

becomes an open hand.


fe

c. Click and drag the label and the text box


ea

to the upper-left corner of the form.


Pl
Re

90 Microsoft® Office Access 2003 - Level 1


LESSON 5
3. Move the Fax label closer to the a. Click the Fax label.
Fax text box.
b. Place the mouse pointer over the move
handle in the upper-left corner of the
label until it becomes a hand with a

al
pointing finger.

c. Click and drag it closer to the Fax text


box.

i
4. a. Use the ruler or lasso technique to

r
Move all the labels and text boxes
containing address information select all of the labels and text boxes
lower on the form. containing address information.

te
b. Place the mouse pointer over all of the
selected controls until it becomes an
open hand.

a
y
c. Click and drag the controls down on the
form.

op
5. Close the form without saving
changes.
eM
a. Click the Close button.

b. Click No.

tC
No
How to Modify a Form
c
Procedure Reference: Modify a Form
n

To modify a form:
Do

1. Display the form in Design view.


e

2. Select the controls you wish to work with.


3. Move the controls.
se

• If you want to move just the text box or label, and not its associated compo-
r

nent, the mouse pointer should look like a hand with a single pointing finger.

fe

If you want to move the text box or label and its associated component, or a
ea

grouping of controls, the mouse pointer should look like a hand with all of
the fingers extended.
4. Size the controls.
Pl


Re

Drag a sizing handle to increase or decrease the size.


• From the menu, choose Format→Size→To Fit.
• Select multiple controls, choose Format→Size, and choose whichever option
is appropriate.

Lesson 5: Designing Forms 91


LESSON 5
The same options available from the Format menu are available by right-clicking a selected
control and choosing Size from the shortcut menu.

5. Align the controls and adjust their spacing.

al
• Select the controls you want to align and right-click one of them. From the
shortcut menu, choose Align. You can then choose to align the Left, Right,
Top, or Bottom sides, or to align To Grid.
• To even out horizontal or vertical spacing of controls, select the controls and

i
choose either Format→Horizontal Spacing or Format→Vertical Spacing. You
can choose to adjust the spacing by selecting Make Equal, Increase, or

r
Decrease.

te
6. If necessary, adjust the tab order of the form fields.
a. In Design view, choose View→Tab Order.
b. In the Tab Order dialog box, click Auto Order.
c. Click OK.

a
7. Apply formatting to text boxes or labels.

y
8. Add a title or other descriptive text.

op
9. eM
Change the size of the form.
10. Save your changes under an appropriate name.

tC
ACTIVITY 5-8 No
Modifying a Form
c
Activity Time:
n

10 minutes
Do

Setup:
e

The UseForms Database window is displayed.

Scenario:
se
r

Your manager has asked you to improve the appearance of a wizard-created form using the
design techniques you have learned. By applying these techniques to the frmGSCCustomers
fe

form, you will turn it into a professional looking creation your organization will be proud of.
ea
Pl
Re

92 Microsoft® Office Access 2003 - Level 1


LESSON 5
What You Do How You Do It

1. Open the frmGSCCustomers form a. Right-click frmGSCCustomers and choose


and size the form to the screen. Design View.

al
b. Place the mouse pointer over the lower-
right corner of the form window until it
becomes an angled double-headed
arrow.

i
c. Drag down and to the right to enlarge

r
the window.

te
d. Place the mouse pointer over the right
edge of the form until it becomes a ver-
tical line with a horizontal double-
headed arrow.

a
e. Click and drag the edge of the form to

y
the 6-inch mark on the right of the
ruler.

op
eM
f. Place the mouse pointer over the bot-
tom edge of the form and drag the edge
down to the 3-inch mark.

tC
2. Using selection, moving, sizing, and a. Move the CustomerName controls up
alignment techniques, arrange the next to the CustomerID controls.
controls on the form so that it is
No
similar to the graphic shown in Step
c
b. Move the Address controls down on the
2d.
form so you have room to arrange the
Phone and Fax controls.
n
Do

c. Size the Phone and Fax text boxes and


move the labels closer to the text
boxes.
e

d. Align the controls so they are similar to


se

the following graphic.


r
fe
ea
Pl
Re

Lesson 5: Designing Forms 93


LESSON 5
3. Switch to Form view and check the a. Switch to Form view.
tab order.
b. Press the Tab key eight times to move
from the first field in the form to the last.
The Phone field would logically follow the

al
CustomerName field in the form’s new
layout, but the tab order is based on the
original layout.

i
4. Return to Design view and correct a. Switch to Design view.
the tab order.

r
b. Choose View→Tab Order.

te
c. In the Tab Order dialog box, click Auto
Order, and then click OK.

5. Return to Form view and check the a. View the form.

a
tab order.

y
b. Press the Tab key to move through the
fields. The tab order has been corrected

op
6. Save the form as
eM
frmMyGSCCustomers, and then
to better suit the form’s new layout.

a. Save the form as frmMyGSCCustomers

tC
close the form.
b. Close the form, then close the database.
No
c
Lesson 5 Follow-up
n
Do

In this lesson, you first created a simple AutoForm and then used the Form Wizard to create a
custom form. You then selected, sized, aligned, and moved controls to modify the form to
meet your specific needs.
e

1. What is the primary difference between creating a form with the AutoForm feature
and the Form Wizard?
se
r
fe

2. What types of forms will you create to work with your data?
ea
Pl
Re

94 Microsoft® Office Access 2003 - Level 1


LESSON 6

al
LESSON 6 Lesson Time
1 hour(s)

ri
Producing Reports

a te
Lesson Objectives:

y
op
You will:
• Create a report with the AutoReport feature.
eM
In this lesson, you will create and modify Access reports.

tC
• Create a report with the wizard.
• Examine a report in Design view.
• Add a calculated field to the report.
• Modify the properties that set the appearance of a control.
No
c
• Modify the format of a report by using the AutoFormat feature.
• Adjust the width of a report.
n
Do
e
se
r
fe
ea
Pl
Re

Lesson 6: Producing Reports 95


LESSON 6
Introduction
One of the most powerful management tools in a database is the report. On the job you will
most likely be asked to produce reports on a regular basis. In this lesson, you will use the
Access report development and design tools to create custom reports.

al
Compiling and analyzing data can allow a business to examine past trends and predict future
directions. In large databases with many tables, each of which may contain thousands of
records, gathering and reporting can be difficult and time consuming. Creating and using cus-
tomized Access reports can provide you with an efficient tool that simplifies your reporting

i
requirements and can be saved for future use.

r
te
TOPIC A
Create an AutoReport

a
y
Much like the AutoForm feature, AutoReport can be used to quickly create a simple report that
contains all of the fields in a specific table. This topic will introduce you to the AutoReport

op
eM
feature and how to use it to quickly create a simple report.
Designing a complex report requires time and planning. You will no doubt encounter situations
when there is not the time for either. Or, perhaps the report will only be used once and there is

tC
no need to create the perfect report. Using the AutoReport tool you can create a report that
displays all of the fields for any given table.

AutoReport
No
c
The AutoReport feature allows the user to create a one-click report with a standardized format.
It is almost instantaneous and often used when timeliness is a factor. The AutoReport feature:
• Launches with the toolbar’s New Object: AutoReports button and works directly with a
n

table or query.
Do

• By default selects all the fields from the underlying table or query and places them on the
report.
e

• Can make use of multiple tables.


• Is also available from within the Report Design Wizard for the three most common layout
se
r

types (columnar, tabular, and justified).


fe

How to Create an AutoReport


ea

Procedure Reference: Create an AutoReport


To create an AutoReport:
Pl
Re

1. In the Database window, select the table or query on which you want to base the
report.
2. On the toolbar, from the New Object drop-down list, select AutoReport.
3. Save the report.

96 Microsoft® Office Access 2003 - Level 1


LESSON 6
ACTIVITY 6-1
Creating a Report with the AutoReport Wizard

al
Activity Time:
10 minutes

i
Data Files:

r
• UseReports.mdb

te
Scenario:
Before an urgent request for printed output of your data arises, you’ve decided to prepare for
the situation and review the results of an AutoReport in Print Preview mode. This way, you’ll
know what to expect before you actually print a report.

a
What You Do How You Do It

y
1. In the UseReports database, run the a. In the UseReports database, double-click

op
qryInventory query and view the
results in Print Preview format.
Print the report.
eM the qryInventory query.

b. Click the Print Preview button.

tC
c. Enlarge the preview to 100%.

d. Using the scroll and navigation bars,


No
modify the display as necessary to view
c
both pages.

The ability to print will depend upon your


n

classroom setup. Your instructor will advise


Do

you on this.
e

e. From the menu, choose File→Print and


click OK to send the output to the
printer.
se
r

f. Examine the printed output.


fe
ea

2. What features does the printed datasheet have?


Pl
Re

3. What disadvantages are there to printing the query datasheet?

Lesson 6: Producing Reports 97


LESSON 6
4. Create an AutoReport. a. Close Print Preview. If necessary, reopen
qryInventory in Datasheet view.

b. From the New Object: AutoForm drop-


down list, choose AutoReport.

al
5. Examine the preview of the AutoReport.

How does the AutoReport compare to the printed datasheet?

ri
6. a. Close the preview window.

te
Close the preview window and save
the report as rptMyAutoReport. If
necessary, close the report Design
b. When prompted to save, click Yes.
window.

c. In the Report Name text box, type

a
rptMyAutoReport

y
op
d. Click OK.
eM e. If necessary, close the report Design
window.

tC
f. If necessary, close the qryInventory
query.
No
n c

TOPIC B
Do
e

Create a Report by Using the Wizard


se
r

Like AutoForms, the AutoReport feature is a wizard, also limited in the scope of the reports it
produces. Similar to using forms, the real advantages gained from reports lies in the custom
fe

report. The custom report can provide the business with a tool to evaluate past and present
ea

activities and to plan for the future. By using the Report Wizard, you can create custom reports
to begin to realize the advantages of database reporting.
At your business, you may be called upon to create custom reports. With the Report Wizard,
Pl

you will be able to develop reports that display the information requested.
Re

The Report Wizard


The Report Wizard is the recommended method for creating reports. The Report Wizard has
the following features:
• It walks users through the report creation process with guided questions.

98 Microsoft® Office Access 2003 - Level 1


LESSON 6
• It will build a report based on more than one table.
• It offers design choices, including the columnar, tabular, and justified views.

How to Create a Report with Wizard

al
Procedure Reference: Create a Report with the Wizard
To create a report with the wizard:

i
1. In the Database window, in the Objects pane, select Reports.

r
2. Double-click Create Report By Using Wizard.
3. From the Tables/Queries drop-down list, select the data source for the report.

te
4. Move the fields you want included in the report from the Available Fields list to
the Selected Fields list by using the arrow buttons.
5. Repeat Steps 3 and 4 for any additional data sources.

a
6. Click Next.

y
7. If necessary, choose the grouping levels and grouping options you want, and click
Next.

op
8.
9.
eM
Select the sort order for the detail records and click Next.
Select the layout for the report and click Next.

tC
10. Select the style for the report and click Next.
11. Enter a title for the report and select whether you want the report displayed in
Print Preview or Design view. No
12. Click Finish.
c

ACTIVITY 6-2
n
Do

Creating a Report with the Report Wizard


e

Activity Time:
se

15 minutes
r

Setup:
fe

The UseReports.mdb database is open.


ea

Scenario:
The Controller of your organization has asked for a report that lists, by department, the current
Pl
Re

computer inventory. You want to organize the information correctly and print it in a legible,
professional-looking format. The Report Wizard will create a report that accomplishes this.

Lesson 6: Producing Reports 99


LESSON 6
What You Do How You Do It

1. Start the Report Wizard. a. In the Database window, display Reports.

b. Double-click Create Report By Using

al
Wizard.

ri
a te
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re

100 Microsoft® Office Access 2003 - Level 1


LESSON 6
2. From Query: qryInventory, select the a. With Query: qryInventory selected in the
fields with which you will be Tables/Queries drop-down list, click the
working. right-pointing double arrow to move all
the available fields to the Selected Fields
list.

rial
a te
y
op
eM
b. In the Selected Fields list, select
ManufacturerID.

c. Click the left-pointing single arrow.

tC
d. Remove the Warranty field from the
Selected Fields list.
No
n c
Do
e
se
r
fe
ea

e. Click Next.
Pl
Re

Lesson 6: Producing Reports 101


LESSON 6
3. View some examples of the avail- a. In the list of views, click By tblEmployees
able views and groupings. Then and view the sample.
click Show Me More Information.
b. In the list of views, click By tblComputers
and view the sample.

al
c. In the list of views, click By
tblManufacturers and view the sample.

i
d. Click Show Me More Information to dis-
play the Report Wizard Tips.

r
te
4. Close the Report Wizard Tips, and a. In the Report Wizard Tips dialog box, click
then choose tblDepartments and Close.
continue through the wizard.
b. If necessary, in the list of views, select
tblDepartments.

a
y
c. Click Next.

op
eM d. Since you don’t need any additional levels
of groups, click Next.

tC
5. Sort the detail records in ascending a. From the drop-down list for the first sort
order, by asset tag number. box, select AssetTag.

b. Click Next.
No
c
6. View the layout samples and apply a. In the Layout section, select each option
the Outline 1 layout. and view the sample.
n

b. Select Outline 1.
Do
e
se
r
fe
ea
Pl
Re

c. Click Next.

7. View the style samples and apply a. In the list of styles, select each style and
the Corporate style. view the sample.

102 Microsoft® Office Access 2003 - Level 1


LESSON 6
b. Select Corporate.

rial
te
c. Click Next.

8. Enter a title of rptMyDepartments a. In the title text box, type


and preview your report. rptMyDepartments

a
y
When previewing a report, you can use b. Verify that Preview The Report is
the Two Pages and Multiple Pages but- selected.

op
tons to get a big-picture look at the
layout of your report.
eM
c. Click Finish.

tC
d. Use the scroll and navigation bars to
view all the data and pages.

9. Close the preview window and close a. In the preview window, click the Close
No
the report. button.
c
If you click Close on the Print Preview b. If necessary, close rptMyDepartments.
toolbar, then the Design view of the
n

report will be displayed. Close that win-


Do

dow as well.
e
se
r
fe
ea
Pl
Re

Lesson 6: Producing Reports 103


LESSON 6
TOPIC C
Examine a Report in Design View

al
As with forms, there are generally improvements that can be made to reports. Imagine that you
have been asked by users to alter the order and alignment of some of the report’s controls and
change the titles of some of the labels. In this topic, you will view the report in Design view
and identify the sections that make up a report.

i
As with the form you created with the Form Wizard, the report you created can also be opened

r
and viewed in Design view. A report is generally more complex to modify than a form.

te
Report Design View
If a professional presentation is your utmost consideration, then Design view may be the pre-
ferred report creation method. However, regardless of how a report is created, the layout of a

a
report can always be modified in Design view. An existing report can be opened in Design

y
view in three ways:
• You can right-click the report in the Database window and choose Design view.

op


eM
With the report selected in the Database window, you can click the Design icon.
With the report opened in preview mode, you can click the View icon.

tC
How to Examine a Report Displayed in Design
View No
Procedure Reference: Identify the Components of a Report in Design View
c
To identify the components of a report in Design view:
1. Select the report to examine.
n

2. Open the report.


Do

3. Click the Design view button.


e

4. Examine the report.


5. Close the report.
se
r
fe
ea
Pl
Re

104 Microsoft® Office Access 2003 - Level 1


LESSON 6
ACTIVITY 6-3
Identifying the Components of a Report Displayed in

al
Design View
Activity Time:
10 minutes

ri
Setup:
The UseReports.mdb database is open.

te
Scenario:
Knowing that you will be called upon to customize reports, you’ve decided to spend a little
time familiarizing yourself with how the report design determines final format. This way, you
will be prepared to create a report.

a
y
What You Do How You Do It

op
1. Open the rptDepartmentalInventory
report, view all the pages, and then
switch to Design view.
eMa. Double-click rptDepartmentalInventory.

b. If necessary, maximize the preview

tC
window.

No
n c
Do
e

c. Use the navigation bar to view all pages.

d. On the preview window toolbar, click


se
r

Close.
fe

e. Open rptDepartmentalInventory in
ea

Design view.

2. Where does the Report Header print?


Pl
Re

a) On the first page of the report.


b) On the last page of the report.
c) At the bottom of each page.
d) At the top of each page.

Lesson 6: Producing Reports 105


LESSON 6
3. What information is in the Report Header?
a) Name and Address
b) Title and Date
c) Page Number

al
d) Date and Time

4. What information does the Page Footer provide?


a) Date

i
b) Time

r
c) Name

te
d) Page Number

5. Determine which controls on the a. On the Report Design toolbar, click the
report are labels and which are text Properties button .
boxes.

a
b. Select the report title “Departmental

y
You can move the property sheet by Inventory” control.
dragging it by the title bar.

op
eM c. Observe the properties dialog box title
bar.

tC
No
n c

This indicates that the control is a label that has


Do

been named Title.


e

d. Select other controls on the report and


view the title bar of the properties dia-
se

log box.
r

6. Close the property sheet. a. In the properties dialog box, click the
fe

Close button.
ea
Pl
Re

106 Microsoft® Office Access 2003 - Level 1


LESSON 6
TOPIC D
Add a Calculated Field to a Report

al
To evaluate past and present business performance and make predictions on future business
trends, the ability to perform calculations is often needed. These calculations can be included
in reports. In this topic, you will add a control to produce a calculated field in your report.

i
Imagine that you have been asked to produce a report that displays a payroll total for the
Research and Development department. You already have a report for this department that con-

r
tains the salary amounts. By adding a control with a calculated field to your report you can
easily produce the requested result.

te
The Toolbox
The toolbox is composed of design tools used to add controls to reports and forms. The same

a
toolbox is used whether a form or report is being developed.

y
The Toolbox Icons

op
Tool Name Usage
eM
The following table displays most of the buttons in the toolbox.

Icon Wizard

tC
Label Adds text only. No

Text Box Adds a graphical box that can contain fields, expres- No
No
sions, and text.
c
Option Group Provides the user with option button choices, which Yes
are buttons that can take on a variety of formats,
from round circles to large rectangular boxes.
n
Do

Toggle Button A graphical button indicating a true/false or yes/no No


value.
e

Option Button This is similar to the option group, but each button No
operates independently. It can be used to designate
true/false values, or multiple option buttons could be
se

used to simulate an option group with multiple selec-


r

tions available.
Check Box A square graphic where a check mark represents a No
fe

true value.
ea

Combo Box A graphical box that can contain fields, expressions, Yes
and text with a drop-down arrow showing additional
choices.
Pl
Re

List Box A graphical box that displays all the choices Yes
available. It is similar to an option group but the
record source can be text.
Command But- Used to place a button on the form, the button can Yes
ton be programmed to perform an action.

Lesson 6: Producing Reports 107


LESSON 6
Icon Tool Name Usage Wizard
Image Used to place a picture on the form or report. No

Unbound Object Used to place a variety of objects, including pictures, No

al
Frame on a form or report.
Bound Object This is used to place an OLE object on a form or No
Frame report.

i
Page Break This inserts a page break wherever this control is No
placed. Using the Page Down key on a form will

r
move the insertion point to the top of a page break.
In a report, a page break will be inserted upon

te
printing.
Tab Control The Tab Control places a graphical object on a form No
or report that positions data within pages accessed by
a tab. Tab Controls are most often used in forms to
maximize use of space.

a
Subform (or) This is used to place a subform or subreport on a Yes

y
Subreport form or report object.

op
Line

Rectangle
eM This places a straight line on the report.

This places a rectangular box on the report and can


be used to cluster similar fields together or to
No

No

tC
enhance the graphical display.

No
How to Add a Calculated Field to a Report
c
Procedure Reference: Add a Calculated Field to a Report
n

To add a calculated field:


Do

1. Open the report in Design view.


2. If necessary, display the Toolbox by clicking the Toolbox button.
e

3. In the Toolbox, click the Text Box tool.


se

4. Click the report design surface where you wish to place the calculated control.
r

5. Click in the text box control to place the insertion point.


fe

6. Type an equal sign (=) and the formula for the calculation.
ea

7. Press Enter or click away from the control.


8. Save the report.
Pl
Re

108 Microsoft® Office Access 2003 - Level 1


LESSON 6
ACTIVITY 6-4
Adding a Calculated Field to a Report

al
Activity Time:
10 minutes

i
Setup:

r
The rptDepartmentalInventory report of the UseReports database is open.

te
Scenario:
You’ve created the report for the Controller using the Report Wizard. Now the Controller
would like you to amortize the cost of the computers over three years and include that calcula-
tion in the report. Adding a calculated field to the report will accomplish the amortization
request.

a
y
What You Do How You Do It

op
1. Add a control containing an amorti-
zation formula.
eMa. If necessary, on the Report Design
toolbar, click the Toolbox button
.

tC
Note that when you place the text box
control, it contains the word Unbound. b. In the Toolbox, click the Text Box tool.
This is because you have not yet desig-
nated the contents of the control.
c. Click in the Detail section to the right of
No
the PurchasePrice control to add the
control.
c
d. Click in the text box control.
n
Do

e. Type = [PurchasePrice]/3
e

The same techniques for selecting and moving controls used in the form design environment work in the report
se

design environment. You can also move the Toolbox by dragging it by the title bar.
r
fe
ea
Pl
Re

Lesson 6: Producing Reports 109


LESSON 6
2. Delete the default label for the con- a. Click the default label control to select
trol, add a label with the caption it.
Amortized to the right of the
PurchasePrice heading, close the
b. Press Delete.
Toolbox, and preview the report.

al
c. In the Toolbox, click the Label tool.

d. In the LastName Header section to the


right of the PurchasePrice label, drag to

i
create the label control.

r
e. Type Amortized

te
f. In the Toolbox, click the Close button.

g. Click the Print Preview button.

a
y
3. Save your report as a. Save the report as
rptMyInventoryReport and close rptMyInventoryReport

op
the preview window.
eM b. Click Close to close the Print Preview
window.

tC
No
TOPIC E
n c

Modify the Format Properties of a


Do

Control
e

You have added a control and a calculated field to your report and the resulting value is dis-
played in the report’s output. You are not pleased with the default display of the value and
se
r

wish to change it. By modifying the format properties of the control that performs the calcula-
tion, you can change the value’s appearance.
fe

Adding a control to a report can greatly enhance the output and the value it has to the
ea

organization. However, the default properties, such as the formatting of output, are not always
what is appropriate. By modifying the format properties of the control, you can produce the
desired presentation.
Pl
Re

How to Modify a Control’s Properties


Procedure Reference: Modify a Control’s Properties
To modify a control’s properties:
1. Open the report in Design view.

110 Microsoft® Office Access 2003 - Level 1


LESSON 6
2. Select the control and click the Properties button, or right-click the control and
choose Properties.
3. If necessary, in the property sheet, select the Format tab.
4. In the Format property box, from the drop-down list, choose the format you want.

al
5. Close the property sheet.
6. Preview the report to see the new format.
7. Save the report.

ri
ACTIVITY 6-5

te
Modifying a Control’s Properties to Change the Output’s
Display

a
Activity Time:

y
10 minutes

op
Setup:
eM
The rptMyInventoryReport report of the UseReports database is open.

tC
Scenario:
The amortized output format of the rptMyInventoryReport needs to be changed to currency.

What You Do How You Do It


No
c
1. Change the format of the new cal- a. In the Detail section, select the control
culated control to currency. containing the formula you entered.
n
Do

b. On the Report Design toolbar, click the


Properties button.
e

c. Select the Format tab.


se
r

d. From the Format drop-down list, select


Currency.
fe
ea

e. Click Print Preview.

2. Change to Design view. In the a. Switch to Design view.


Pl

Report Header section, select the


Re

text box with the Now() function in


its control source and, from the For-
mat drop-down list, select the Short
Date choice. Preview the report,
and then save the report.

Lesson 6: Producing Reports 111


LESSON 6
b. In the Report Header section, select the
control containing the Now() function.

rial
a te
c. In the properties dialog box, from the For-
mat drop-down list, select Short Date.

y
op
eM d. Click Print Preview.

e. Return to Design view and save the


report.

tC
No
c
TOPIC F
n
Do

AutoFormat a Report
e

When you ran the Report Wizard, you probably noticed a list of styles that you could choose
from. Wouldn’t it be convenient if you could change from one report format to another without
re-creating the entire report? The AutoFormat feature allows you to accomplish this. In this
se
r

topic, you will examine the different AutoFormat reports available and apply your selection to
a report.
fe

Imagine that you have created a report that is to be used by several different departments in
ea

the organization. The contents of the report are just what they needed, but you have had sev-
eral requests for different formats. This may seem to be a trivial matter, and you really don’t
wish to redesign the same report over and over. Using the AutoFormat feature, you can easily
Pl

modify the report’s format.


Re

112 Microsoft® Office Access 2003 - Level 1


LESSON 6
How to Apply an AutoFormat Style to a Report
Procedure Reference: Apply an AutoFormat Style to a Report
To AutoFormat a report:

al
1. Open the report in Design view.
2. Choose Edit→Select Report, or click the Report Selector.
3. On the Report Design toolbar, click the AutoFormat button.

i
4. In the Report AutoFormats list box, select the new format.

r
5. Click OK.

te
6. Preview the report to see the new style.
7. Save the report.

ACTIVITY 6-6

a
y
op
Applying an AutoFormat Style to a Report eM
Activity Time:

tC
10 minutes

Setup:
The rptMyInventoryReport report of the UseReports database is open in Design view.
No
c
Scenario:
You are not pleased with the format of the rptMyInventoryReport report. You could attempt to
adjust a number of properties and controls, but time is critical. There is another possibility—
n

the AutoFormat feature may provide the solution.


Do

What You Do How You Do It


e

1. With no controls selected, open the a. In the property sheet dialog box, click the
AutoFormat dialog box and choose a Close button.
se
r

report format you like. Then, apply


the format and preview the report.
b. Click a blank area of the report to dese-
fe

lect all controls.


ea

c. Choose Edit→Select Report.


Pl

d. On the Report Design toolbar, click the


Re

AutoFormat button.

Lesson 6: Producing Reports 113


LESSON 6
e. In the Report AutoFormats list box, select
the Bold format and observe the
preview.

rial
te
f. Preview each of the remaining formats
and select the one you prefer.

a
y
g. Click OK.

op
2.
eM
Switch to Design view. Save and
close the report.
h. Print Preview your report.

a. Switch to Design view.

tC
b. Click Save.

c. Click the Close button.


No
n c
Do

TOPIC G
e

Adjust the Width of a Report


se
r

There are times when a report contains so much information that the information to be dis-
fe

played exceeds the size of the display area and causes blank pages to be printed in your report.
ea

In this topic, you will modify the margin settings to prevent this situation.
Imagine you have been asked to produce a lengthy report for an important business meeting.
When you run and print the report, you find that every other page is a blank page. This is cer-
Pl

tainly not an acceptable format for the presentation. By modifying the report’s margin values
Re

you can eliminate the blank pages.

114 Microsoft® Office Access 2003 - Level 1


LESSON 6
How to Adjust the Margin Settings on a Report
Procedure Reference: Adjust a Report’s Margin Settings
To adjust a report’s margins:

al
1. Open the report in Design view.
2. On the horizontal ruler, note the width of the report.
3. Calculate left and right margin settings that, when added to the report width, are

i
no greater than the width of the paper.

r
4. Choose File→Page Setup and enter the Left and Right margin values.
5. Click OK.

te
6. Preview the report to check your results.
7. Save the report.

a
ACTIVITY 6-7

y
op
Adjusting a Report’s Margin Settings
Activity Time:
eM
tC
15 minutes

Setup:
The UseReports.mdb file is open.
No
c
Scenario:
You’ve spent a lot of time perfecting your report and sent it off to the printer. When you
n

picked it up, every other page is mostly blank. Adjusting the margin settings will fix it.
Do

What You Do How You Do It


e

1. Print Preview rptFixMargins, view- a. In the Database window, right-click


ing two pages side by side. rptFixMargins and choose Print Preview.
se
r

b. On the Print Preview toolbar, click the


fe

Two Pages button.


ea

c. Page down and examine the entire


report. The blank pages alternate
between the printed pages.
Pl
Re

Lesson 6: Producing Reports 115


LESSON 6
2. Why are there blank pages between the printed pages?
a) There is not enough text on the pages.
b) The font is too large.
c) The margin setting is too narrow.

al
d) The margin setting is too wide.

3. In Design view, note the width of a. In Design view, on the horizontal ruler,
the report. Open the Page Setup note the width of the report. It is

i
dialog box and notice the margin approximately 6.75 inches wide.
settings.

r
b. Choose File→Page Setup and note the
margin settings. Each margin is set to 1

te
inch.

4. Why are these settings causing the blank pages?

a
y
op
eM
What do you think your options might be for fixing this problem?

tC
No
5. Change the margins to eliminate a. In the Page Setup dialog box, change the
c
the blank pages. Then, preview the Left and Right margin values to 0.75.
report, save it as rptMyFixMargins,
and close it.
b. Click OK.
n
Do

c. Print Preview all pages of the report.


The blank pages have been removed.
e

d. Close Print Preview.


se
r

e. Save the file as rptMyFixMargins


fe
ea

f. Click the Close button.

6. Close the UseReports database and a. In the Database window, click the Close
close Access. button.
Pl
Re

b. In the Microsoft Access window, click the


Close button.

116 Microsoft® Office Access 2003 - Level 1


LESSON 6
Lesson 6 Follow-up
In this lesson, you created an AutoReport and used the Report Wizard to create a report. Then,
in Design view, you customized the report by adding a calculated field, modifying the format
properties of a control, using the AutoFormat feature to change the report’s format, and adjust-

al
ing the width of the report.
1. What kinds of reports will you create for your data?

i
2. What uses can you think of for calculated fields in your reports?

r
a te
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re

Lesson 6: Producing Reports 117


NOTES

rial
a te
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re

118 Microsoft® Office Access 2003 - Level 1


LESSON 7

al
LESSON 7 Lesson Time
40 minutes

ri
Planning a Database

a te
Lesson Objectives:

y
op
You will:

eM
In this lesson, you will follow the steps required to properly design a simple database.

List and describe the steps of the process involved in designing a relational database.

tC
• Define the purpose of a new database.
• Use existing resources to help identify what data already exists and might be part of your
database.
• List the necessary fields for your database.
No

c
Logically group your fields in tables.
• Apply database design principles to eliminate potential data maintenance problems.
• Designate a primary key for each table, and where applicable, a foreign key.
n
Do
e
se
r
fe
ea
Pl
Re

Lesson 7: Planning a Database 119


LESSON 7
Introduction
You have data that needs to be stored in a database. You have used Microsoft® Office Access
2003 databases before, but using a database and creating one are not the same thing. In this
lesson, you will learn the basics of planning a new database, and in the next lesson, you will

al
create a simple database.
Just as you wouldn’t attempt to build a house without a blueprint, you shouldn’t create a data-
base without a plan. For a simple department intranet database, this design phase might not
take very long or require input from very many stakeholders. A large financial or Human

i
Resources database, on the other hand, would require a lengthy planning phase with input from
numerous groups in your organization.

r
te
TOPIC A
Design a Relational Database

a
y
In order to create a new database effectively you should follow a plan—a process that includes

op
eM
all the phases necessary to create the best database for your needs.
With any complicated activity, following a well-defined process will help you to stay on track,
include all the appropriate inputs, and produce the best possible output. Creating a new Access

tC
database is no different: only by following the phases of a good design process can you be
assured that your database will do what you want it to and be easily maintained.

The Relational Database Design Process


No
c
The relational database design process is a simple process that can be used to produce a design
plan for a relational database. It is composed of the following stages wherein you will: ]
1. Identify the purpose of the database.
n

2. Review existing data.


Do

3. Make a preliminary list of fields.


e

4. Organize the fields into tables.


5. Enter sample data, review for possible data maintenance problems, and revise the table
design as necessary.
se
r

6. Designate primary and foreign keys that can be used to relate your tables together.
fe
ea
Pl
Re

120 Microsoft® Office Access 2003 - Level 1


LESSON 7

rial
a te
y
op
eM
Figure 7-1: The relational database design process.

tC
DISCOVERY ACTIVITY 7-1 No
c
Following the Relational Database Design Process
n

Scenario:
Do

Your colleagues want to know that the database you are creating for them will suit their needs,
be easy to use, and easy to maintain. You need to convey to your colleagues the process you
will use to create the database, so they can be confident in the final result.
e
se
r

1. Place the steps of the relational database design process in the correct order.
Enter sample data, review for possible maintenance problems, and revise the table
fe

design as necessary.
ea

Organize the fields into tables.


Make a preliminary list of fields.
Pl
Re

Identify the purpose of the database.


Identify primary and foreign keys for use in relating the data in the tables.
Review the existing data.

Lesson 7: Planning a Database 121


LESSON 7
TOPIC B
Identify Database Purpose

al
The first step in the design process is to determine what purpose you want the database to
serve.
As with any activity, if you don’t have a clear purpose—a well-defined goal—then you run the

i
risk of going off track: wasting time, doing too much or too little, or creating something
entirely useless. Determining a clear statement of purpose for the database you are designing

r
will keep you on track and help reduce these risks. You can come back to it throughout the
design process to help you answer questions that might arise.

te
Statement of Purpose
Definition:

a
A statement of purpose is a clear statement that defines the scope of a database and

y
helps to guide its design. It should imply the kinds of data that will be included in the
database, but not state specific table or field names. It can describe who the likely

op
eM
types of users of the database will be, but not state specific queries or reports they
intend to run. It is sometimes useful to include a statement of what the database will
not do.

tC
Example:
No
n c
Do
e
se
r

Figure 7-2: A good statement of purpose for an employee benefit plans


fe

database.
ea
Pl
Re

122 Microsoft® Office Access 2003 - Level 1


LESSON 7
Non-Example:

rial
a te
y
op
Figure 7-3: A poor statement of purpose for an employee benefit plans
eM
database.

DISCOVERY ACTIVITY 7-2


tC
Writing a Statement of Purpose
No
c
Scenario:
In your new position as head of Information Management for The Green Supply Co., you’ve
decided you want to create a custom database to track your company’s computers and what
n

employees they are assigned to.


Do
e

1. Given the preceding scenario, write a statement of purpose for the new database.
se
r

2.
fe

What is wrong with this statement of purpose: “The database will have tables for com-
puters, personnel, manufacturers, product sales, salaries, and company suggestions.”
ea

a) The statement of purpose should not attempt to list specific tables.


b) The statement of purpose is too broad.
Pl

c) There is nothing wrong with this statement of purpose.


Re

Lesson 7: Planning a Database 123


LESSON 7
3. What is wrong with this statement of purpose: “The database will allow the user to
generate reports that list the computers used by each employee, as well as queries
that sort records by the date the computer was purchased and the manufacturer of the
computer.”
a) It doesn’t discuss the scope of information to be included in the database.

al
b) It doesn’t mention or imply how its information will be related.
c) It discusses specific features (queries and reports) that you would like to see
provided.
d) There is nothing wrong with this statement of purpose.

ri
te
TOPIC C

a
Review Existing Data

y
op
eM
Now that you know what you intend the database to do, you can start thinking about what data
it will have to contain to fulfill that purpose. This is the second step in the design process.
Although you may think you know exactly what data should be included in the database you

tC
are designing, you’ll be surprised how often you’ll miss something. By considering pre-
existing data sources (paper forms, spreadsheets of data, colleagues in your organization, and
so on) you can reduce the risk of missing essential kinds of data for your database. You might
even save time in collecting the data, by discovering that some of it is already in electronic
format.
No
c
Existing Data
n

Definition:
Do

Existing data is information available for you to review that falls within the scope of
your database as defined in your statement of purpose. This data can be in paper or
e

electronic format.

An existing data source may also contain information that is outside the scope of the planned database.
se
r

Use your statement of purpose to determine this as necessary.


fe

Example: Existing Data in Paper Format


ea

Existing data in paper format could include:


• Internal business forms or documents.
• Third-party or government forms or documents.
Pl
Re

• Printed invoices, bills, or sales slips.

124 Microsoft® Office Access 2003 - Level 1


LESSON 7

rial
a te
y
op
eM
Figure 7-4: Existing data in paper format.

tC
Example: Existing Data in Electronic Format
Existing data in electronic format could include:
• Spreadsheets, such as Microsoft Excel.
No
• Word Processing documents, such as Microsoft Word.
c
• Other Databases, such as Access, SQL Server, or Oracle.
• Web pages.
n
Do
e
se
r
fe
ea
Pl
Re

Lesson 7: Planning a Database 125


LESSON 7

rial
a te
y
op
eM
Figure 7-5: Existing data in electronic format.

tC
DISCOVERY ACTIVITY 7-3 No
c
Gathering and Reviewing Existing Data
Scenario:
n

The statement of purpose for your database is “The database will hold information on the com-
Do

pany’s inventory of computers and their assignment to employees.” In your search for existing
data, you find that the Receiving department fills out a ticket for each item that is delivered.
e

See Figure 7-6.


se
r
fe
ea
Pl
Re

126 Microsoft® Office Access 2003 - Level 1


LESSON 7

rial
a te
y
Figure 7-6: A sample Receiving ticket.

op
1.
eM
What pieces of data from the sample ticket do you think should be included in your
database?

tC
a) Date computer acquired
b) Manufacturer name
c) Asset tag number
d) Department of employee
No
c
2. What other sources of data might you use for determining what data should be
included in the database?
n
Do
e
se
r
fe
ea
Pl
Re

Lesson 7: Planning a Database 127


LESSON 7
TOPIC D
Determine Fields

al
From reviewing the existing data, you have a good start on your field list. You can complete
step three in the design process by questioning potential users of the data about their expecta-
tions and, specifically, what reports or summary information they would like. You can then
reverse-engineer that into specific fields of data.

i
You don’t want to spend a lot of time creating a database and designing beautiful forms and

r
reports only to find out that they don’t meet the needs of the consumers of the information.
You can prevent this by involving these people in the design and getting as much detail as

te
possible about their information needs.

Determining Additional Fields

a
When you appropriately determine additional fields, you will meet your users’ needs while

y
staying within the scope of your statement of purpose.

op
Guidelines:

sure to:

eM
When interviewing the potential users of a database to determine additional fields, be

State your database’s statement of purpose at the beginning of each conversation

tC
to help everyone stay focused.
• Ask questions to gain a better understanding of the fields that will be required.
— What sort of data do you expect the database to contain?
No
— What kinds of reports would you like to be able to generate from the data-
c
base?
— What types of summary information do you expect the database to produce?
n

— What kinds of questions do you want the database to be able to easily


Do

answer?
e

If you are the only potential user of the database you are designing, then you will need to consider
these questions yourself. It is still an essential stage in the process and should not be skipped.
se
r

Example:
You are designing a database for tracking enrollment of employees in benefit plans.
fe

You have reviewed existing data and now need to determine additional fields. In inter-
ea

viewing other members of the Human Resources department you begin by making
clear your statement of purpose. You then ask them what kinds of reports they will
need to run and what kind of summary information they will need to obtain. They
have indicated that they would like to know the number of employees enrolled in a
Pl
Re

particular plan and how many have joined each plan during each month. As a result of
these interviews you know that you will need to include EmployeePlan and
PlanEnrollDate fields.

128 Microsoft® Office Access 2003 - Level 1


LESSON 7
DISCOVERY ACTIVITY 7-4
Completing the List of Fields

al
Scenario:
From the Receiving ticket and other sources you have been able to arrive at the following list
of pre-existing data:

i
• Employee department

r
Date received
• Asset tag number

te
• Manufacturer
• Note about each computer
The manager of Technical Services would like to get a weekly report of all new computers
received and to whom they are assigned so she can arrange to set up the hardware; she would

a
also like to know if the system is covered by a warranty. The Finance manager would like a

y
monthly summary of departmental computer hardware purchases.

op
1.
eM
What additional data will you need to include about each employee?
a) Name

tC
b) Salary
c) Date of birth
d) Computers assigned
No
e) Manager of employee
c
2. What additional fields will you need to include in the database to enable the Technical
Services manager’s weekly reports and the Finance manager’s monthly report?
n

a) Warranty coverage
Do

b) Purchase price
e

c) Software games included


d) Number of current files on the computer
se
r
fe
ea
Pl
Re

Lesson 7: Planning a Database 129


LESSON 7
TOPIC E
Group Fields into Tables

al
Once you’ve identified the fields you need in the database, you can move on to step four of
the design process and decide how to organize them into tables. That’s what you’ll work on
next.

i
As you know, tables are the heart of any Access database. They’re the objects that actually
store your data and are what you use as the basis for queries, forms, and reports. While you

r
can change the design of tables after they’re created, it’s much less work to try to get the right
table design at the start.

te
Group Fields into Tables
Grouping fields into tables will allow you to effectively relate information in your database.

a
y
Guidelines:
Use these guidelines when grouping fields into tables:

op


eM
A table should hold information on only one subject.
Don’t be concerned about having too many tables. It’s much more likely that you
won’t have enough.

tC
• Try to identify tables that correspond to tangible objects such as people, physical
objects, and so on. Such entities have properties that are likely the fields of the
table.
• For intangible subjects, try to identify a collection of logically related information
No
with common characteristics.
c
If five different database designers followed the recommended design process for the same database, it
is entirely possible they would arrive at five slightly different designs. This is because each individual
n

can have a different thought process and may make different assumptions along the way. That’s why
Do

the standard design process is so important. It helps ensure that, whatever the details of the final
design, it will comply with good design principles.
e

Example: Employees and Benefit Plans Tables


In a database for tracking enrollment of employees in benefit plans, you have one table
se
r

for employees and another for benefit plans. These are both entities that have related
properties. Each employee has a name, department, phone number, current plan, and
fe

date of enrollment. Each benefit plan has a plan name, provider, benefits, and
ea

description.
Pl
Re

130 Microsoft® Office Access 2003 - Level 1


LESSON 7

rial
te
Example: Tables for an Ice Cream Business
For a database that holds information about the operation of an ice cream stand, you
would have an IceCream table with flavors and prices. If you sold sundaes as well as

a
cones, you would have a Toppings table that includes the topping name and its addi-

y
tional cost. Then, to associate ice cream and toppings in particular combinations, you
would have a Sundaes table with the name of the sundae and what combination of fla-

op
vor and topping is used to make it. eM
tC
No
n c
Do
e
se
r
fe
ea

Business Rules
The procedures and policies of a company represent its business rules, and these can
Pl
Re

affect the design of a database. For example, if your company has an internal policy
that computers are assigned to departments, rather than to specific employees, this
would affect the way you design the tables in a computer inventory tracking database.
As you look at existing data, talk to potential users, and group fields into tables, you
should be aware of company policies. If you don’t already know the pertinent com-
pany policies, you should inquire about them.

Lesson 7: Planning a Database 131


LESSON 7
Field and Table Names
Access has constraints on field and table names. Names:
• Can be no more than 64 characters.
• Cannot include a period (.), exclamation point (!), an accent grave (′), brackets

al
([]), or double quotation marks (“).
• Cannot have a leading space. (Access permits you to have spaces within table and
field names; however, if there is an internal space, you will have to enclose that
table or field name within brackets when you refer to it in expressions and other

i
places. So, you might want to get in the habit of not using spaces in table and
field names. One option is to use the underscore character in place of a space in a

r
field name.)

te
Names should be brief but descriptive so that another user will know what they mean.
Table names are usually plural.

DISCOVERY ACTIVITY 7-5

a
y
Deciding on Computer Inventory Tables

op
Scenario:
eM
You’re continuing work on designing your computer inventory database, and you’ve decided

tC
that you need the following fields:
• Employee name
• Asset tag number
• Computer manufacturer
No

c
Date received
• Computer note or comment
• Employee department
n


Do

Warranty coverage
• Purchase price
e

Now you need to group them into initial tables.


se
r

1. Based on the information you have now, which two tables would be minimally required
for this database?
fe

a) Computers and Notes


ea

b) Computers and Employees


c) Computers and Departments
Pl
Re

d) Employees and Departments

132 Microsoft® Office Access 2003 - Level 1


LESSON 7
2. With only these two tables as options, which fields would go in an Employee table?
a) Name
b) Computer manufacturer
c) Department

al
d) Warranty coverage

3. Of the remaining fields, of them could go in a Computers table.

ri
te
TOPIC F
Normalize the Data

a
y
Once you’ve drafted the tables and fields you believe you need in your database, the next step

op
ing the data.
eM
is to enter some sample data in the tables and look for any potential problems with maintain-

Identifying possible data maintenance problems before you enter your real data and start work-
ing with your database will save you many headaches and extra work later on. Improperly

tC
designed tables can also result in inaccurate data, and you certainly don’t want to be making
decisions based on data that you can’t trust.

Data Normalization Guidelines


No
c
Data normalization ensures that, when you implement the tables you have planned, the result-
ing database will be able to efficiently provide the queries and reports desired and ongoing
data maintenance will be as simple as possible.
n
Do

Guidelines:
Common data normalization guidelines are as follows:
e

• Each field should contain the smallest meaningful value.


• There should be no repeated groups of fields (similar data belongs in the same
se
r

field).
• There should be no unnecessarily repeated data values.
fe

• When reasonable, all fields in a table should pertain to every record.


ea

Non-Example:
In this example the fields are not normalized. The Name field is not the smallest mean-
Pl
Re

ingful value. There are two email address fields, and the second will not always have a
value.
• Full Name
• Work Phone Number
• Work Email Address 1
• Work Email Address 2

Lesson 7: Planning a Database 133


LESSON 7
• Social Security Number
• Begin Date

Example:

al
In this example, each field has the smallest meaningful value, there are no repeated
groups of fields or repeated data values, and every record in the table will have a value
in each of these fields.
• Employee First Name

i
Employee Last Name
• Work Phone Number

r
• Work Email Address

te
• Social Security Number
• Begin Date

Non-Example:

a
A table containing the following fields would violate the data normalization guidelines.

y
The name field should be split into at least First Name and Last Name, there are
repeated fields for Projects and their Completion Dates, and the Optional Assistant

op

Name
Department
eM
field would by definition not have a value for each record.

tC
• Project 1
• Completion Date 1
• Project 2
• Completion Date 2
No
c
• Optional Assistant

Blank Values
n

Though not a strict rule, In many cases blank values in fields should appear because
Do

that value is temporarily missing or unknown—not because that field does not pertain
to a record. So, for example, if you have a table listing employees that contains a
e

WebSite field, that field would contain a blank value for some employees (assuming
that not everyone has a Web site, or likely ever will). The value isn’t temporarily miss-
ing or unknown; the field just doesn’t apply to every record. That’s a sign that the field
se
r

might belong in a separate table.


fe

In this case it is quite possible that while some employees do not have a Web site, some have more
ea

than one. This would be another reason that this field belongs in a separate table, otherwise you would
end up with two or more redundant fields in the same table.

Data Denormalization
Pl
Re

Definition:
Denormalization occurs when a database designer combines data into one table that the
normalization process indicated should be in two tables. After a database designer has
fully normalized the design of a database, he or she may, on occasion, choose to do
this for any number of reasons:

134 Microsoft® Office Access 2003 - Level 1


LESSON 7
• Performance reasons, such as making queries run faster against very large tables.
• In order to keep similar data together.
• To keep the overall table structure simple, particularly when it is clear that break-
ing normalization guidelines will not negatively affect the ability to run queries or

al
create reports.

Example:
A common example of denormalization is allowing an occasional field to be blank for
some records. For instance, a database may contain a middle initial field, but not all

i
employees have or use a middle initial. Strict normalization rules would state that the

r
field should not be null—but it is common practice to keep this field in the same table
with the first and last names.

te
DISCOVERY ACTIVITY 7-6

a
Preventing Data Maintenance Problems

y
Scenario:

op
eM
You have two draft tables for the computer inventory database. One is called Employees and
has an EmployeeName field and a Department field. The other is called Computers and has the
other six fields you decided upon. Now consider what potential data maintenance problems

tC
might exist by imagining them filled with data. See Figure 7-7 and Figure 7-8.

No
c
Figure 7-7: The Employees table with sample data.
n
Do
e
se
r
fe
ea
Pl
Re

Figure 7-8: The Computers table with sample data.

Lesson 7: Planning a Database 135


LESSON 7
1. What should be done with the EmployeeName field to normalize the data?
a) It should list the last name first, with a comma and then the first name.
b) It should be broken up into two separate fields, one for the first name and one for
the last name.

al
c) It should include the last name data only.
d) Nothing, it is fully normalized as it is.

i
2. True or False? Since the Department field holds repeated values, a Departments table
should hold those values.

r
True

te
False

3. True or False? Since not all records have an entry in the Note field, strict adherence to
normalization guidelines would require the note field be moved to a separate table.
True

a
False

y
op
4.
eM
What can be done to normalize the data in the Manufacturer field?
a) The entries should be in all lowercase.
b) The entries should be in all uppercase.

tC
c) Since it has repeated entries, there should be a Manufacturers table to hold that
data.
d) Nothing, it is fully normalized already. No
5. If you chose to not normalize the data in the Manufacturer field in this way, that would
c
be an example of the data.

6. What needs to be done to normalize the Warranty field’s data?


n

a) It should be a text field.


Do

b) Because some check boxes are not checked, that data belongs in a separate table.
c) Nothing, it is fully normalized already.
e
se
r
fe
ea
Pl
Re

136 Microsoft® Office Access 2003 - Level 1


LESSON 7
PRACTICE ACTIVITY 7-7
Normalizing Additional Data

al
Activity Time:
10 minutes

i
Scenario:

r
A colleague has asked you to help them denormalize some tables in their databases.

te
1.

a
y
op
2.
The
eM
field does not contain the smallest meaningful values.

Based on the data shown, which additional fields would you need to add to normalize

tC
this data?
a) City
b) State
c) Zip Code
No
c
d) Country

Zip Code information implies the City and State. If a lookup function were available, then having
n

additional fields for City and State would, in this respect, amount to denormalizing this data.
Do
e

3.
se
r
fe
ea

What data normalization problems does this table have?


a) The LastName field appears before the FirstName field.
Pl
Re

b) There is a repeated group of Project fields.


c) There is a repeated group of Time fields.
d) The sets of Project and Time fields are not adjacent.

Lesson 7: Planning a Database 137


LESSON 7
4. Why would these be data maintenance problems?

al
5. True or False? This data could be normalized by separating it into two related tables:
one for the LastName and FirstName data, and one for the Project and Time data.
True
False

ri
6.

a te
y
op
7.
The eM
field contains unnecessarily repeated values that rely on a non-key field.

What data maintenance problem does this cause?

tC
8. True or False? You could normalize this data by moving the ProjectManager and Phone
fields into a second but related table.
True
No
c
False
n
Do
e
se
r
fe
ea
Pl
Re

138 Microsoft® Office Access 2003 - Level 1


LESSON 7
TOPIC G
Designate Primary and Foreign Keys

al
Now that you’ve modified the design of the tables so that you’re confident that the data can be
maintained accurately, it’s time to determine the primary and foreign keys for each table,
which in turn determines how the tables can be related to each other.

i
As you know, Access databases have such great querying power in part because tables can be
formally related to each other. Properly assigning primary and foreign keys is essential to cre-

r
ating useful relationships between your tables, and without them, you simply won’t be able to
use the full querying and reporting power of your database.

te
Primary Keys
Definition:

a
A primary key is a field or combination of fields that contains a value that uniquely

y
identifies a record. The primary key is used in establishing appropriate relationships
between tables. Primary key fields:

op



Have values that are never blank.
Have values that rarely (if ever) change.
eM
tC
Include as few fields as necessary.
• Never allow duplicates.
• Can be any datatype. No
AutoNumber is a common datatype choice for primary key fields because it guarantees uniqueness.
c
Access sorts the records by the values in the primary key.
n
Do

Example: EmployeeID as a Primary Key


e
se
r
fe
ea

Figure 7-9: An EmployeeID field is a good candidate to serve as a primary key


for an Employees table.
Pl
Re

Other common examples of primary key fields include: Student ID number, Order number, Item num-
ber, Part number, Serial number, ISBN number, and Date plus Time.

Lesson 7: Planning a Database 139


LESSON 7
Non-Example:
A LastName field is not a good primary key field because it can have duplicate values.
An Email field is also not a good primary key field because it could allow for blank
values and changes often.

rial
te
Figure 7-10: Not all fields would be good primary keys.

Foreign Keys

a
y
A foreign key field is a field or combination of fields that contains a value that relates
to a primary key field. Its datatype must match that of the primary key field. Duplicate

op
eM
values can appear in the foreign key field. The combination of primary and foreign key
fields is what gives Access its relational power.

DISCOVERY ACTIVITY 7-8


tC
Identifying Primary and Foreign Key Fields
No
c
Scenario:
Your database design now contains the following tables: Employees, Departments, Computers,
Manufacturers, Notes. See Figure 7-11. Now you need to designate which fields will be pri-
n

mary keys and, where necessary, foreign keys. In doing so you are preparing your tables to be
Do

properly related together.


e
se
r
fe

Figure 7-11: Tables in the ComputerInventory database.


ea

1. Which field in the Employees table would be best as a primary key?


Pl
Re

a) EmployeeLastName
b) EmployeeFirstName
c) DeptCode
d) A new field, EmployeeID

140 Microsoft® Office Access 2003 - Level 1


LESSON 7
2. In which table should the EmployeeID field appear as a foreign key field?
a) Departments
b) Computers
c) Manufacturers

al
d) Notes

3. The field should be the primary key field for the Departments table.

i
4. Which table should have DeptCode as a foreign key field?

r
a) Employees
b) Computers

te
c) Manufacturers
d) Notes

5. The field can serve as a primary key field for both the Computers and Notes

a
tables.

y
6. If you were to add a ManufacturerID field to serve as the primary field for the Manufac-

op
a) Employees
b) Departments
eM
turers table, what other table should have a ManufacturerID field as a foreign key?

tC
c) Computers
d) Notes
No
c

Lesson 7 Follow-up
n
Do

In this lesson, you learned all the steps required to plan a simple Access database. You fol-
lowed a process that ensures that your resulting database will take into account your existing
e

data, fulfill the needs of users, and be both robust and easy to maintain. You can feel confident
that the design that you now have can be implemented as an Access database appropriate to
your goals.
se
r

1. Why is it important to create a plan before building your database?


fe
ea

2. What fields might you include in the first database you need to build on your job? How
Pl
Re

would you group them into tables?

Lesson 7: Planning a Database 141


NOTES

rial
a te
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re

142 Microsoft® Office Access 2003 - Level 1


LESSON 8

al
LESSON 8 Lesson Time
1 hour(s)

ri
Building the Structure of a

te
Database

a
y
op
Lesson Objectives: eM
In this lesson, you will create a new database with related tables.

tC
You will:
• Create a new blank database.
• Create a new table using a wizard.
• Create new tables in table Design view.
No
c
• Create relationships between tables.
n
Do
e
se
r
fe
ea
Pl
Re

Lesson 8: Building the Structure of a Database 143


LESSON 8
Introduction
Once you’ve designed a database, you need to create the related tables that will store the data.
This lesson will introduce you to the basics of building tables and the relationships between
them that will enable robust queries and reports.

al
A database design is like an architect’s blueprint. Just as builders need to construct the house,
you need to build the structure of your database. Building a database from scratch will give
you the most flexibility. But to create a solid structure, you should use your design as a strict
guide when creating your tables and the relationships between them.

ri
TOPIC A

te
Create a New Database

a
Having planned a new database, you are now ready to create it. You have several options: cre-

y
ate it based on a template from Microsoft, create it based on the structure of a pre-existing
database, or create an empty database. In this lesson you will take the third approach.

op
eM
Knowing how to create a new database of your very own design frees you from having to find
an appropriate template or having to spend a lot of time modifying someone else’s design.

tC
How to Create a New Database
Procedure Reference: Create a New Database Based on a Database Template
No
To create a new database based on a database template:
c
Depending on the speed of your computer, it may take several minutes for Access to build a database
based on a template. You will be unable to use Access during that time.
n
Do

1. If necessary, start Access.


2. If necessary, choose File→New to display the New File task pane.
e

3. In the New File task pane, under the Templates heading, click On My Computer.
4. In the Templates dialog box, select the Databases tab.
se
r

5. Click the template you wish to use. Click OK.


fe

6. In the File New Database dialog box, navigate to the folder in which you wish to
ea

store the database file.


7. In the File Name text box, enter the name for the file. Click Create.
8. After reading the initial description of this template, click Next.
Pl
Re

9. For each table that the template provides, select any optional fields that you wish
to include and deselect any fields that you do not want. Click Next.
10. Select the style you want for forms in the database and click Next.
11. Select the style you want for printed reports and click Next.

144 Microsoft® Office Access 2003 - Level 1


LESSON 8
12. If you want the title of the database to be different from the file name, enter that
title. Click Next.
13. If you do not want the database to be opened after the wizard builds it, uncheck
Yes, Start The Database. If you want help on using a database, check Display
Help On Using A Database. Click Finish.

al
Templates
Access provides several templates on which you can base a new database. The tem-
plate provides a database designed to hold a certain type of data (such as Order Entry

i
or Resource Scheduling). A basic set of templates is installed on your computer when

r
you install Access and additional templates are available on the Microsoft Web site
through a link provided on the New File task pane.

te
ACTIVITY 8-1
Creating a New Database Based on a Template

a
y
Scenario:

op
eM
You’ve decided on Access as your relational database management system. You decide to try
creating the database using a template provided by Microsoft. There is no need to reinvent the
wheel, and if a template-based database is close enough to your database design (See Figure
8-1), it might save you a lot of time.

tC
No
n c
Do

Figure 8-1: Your current database design.


e
se
r
fe
ea
Pl
Re

Lesson 8: Building the Structure of a Database 145


LESSON 8
What You Do How You Do It

1. Create a new database based on the a. Launch Access.


Asset Tracking template.
b. Choose File→New to display the New File

al
You might have a shortcut to Access on task pane.
your desktop and can double-click that to
run Access.
c. In the New File task pane, under the Tem-
plates heading, click On My Computer.

ri
If On My Computer is not available, click More
to see the On My Computer link.

te
d. In the Templates dialog box, select the
Databases tab.

e. Select the Asset Tracking template.

a
y
op
eM
tC
No
c

f. Click OK.
n
Do

g. If necessary, in the Places bar, select My


Documents.
e

h. In the File Name text box, type


se

MyComputersTemp
r
fe

i. Click Create.
ea
Pl
Re

146 Microsoft® Office Access 2003 - Level 1


LESSON 8
2. The initial description of this template looks promising. Which of your planned data-
base tables seem to match to the information listed?
a) Employees
b) Departments

al
c) Manufacturers
d) Computers
e) Notes

ri
a te
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re

Lesson 8: Building the Structure of a Database 147


LESSON 8
3. Review the fields that will be a. Click Next.
included for each table and accept
the default selections.
b. With the Asset Information table selected
in the left pane, scroll through the right
pane to view the list of fields.

rial
a te
y
c. Select Department Information in the

op
eM left pane to see its three fields.

d. Do the same for the Information About

tC
Employees, Vendor Information, and any
other tables that interest you.

e. Click Next.
No
n c
Do
e
se
r
fe
ea
Pl
Re

148 Microsoft® Office Access 2003 - Level 1


LESSON 8
4. Preview the form styles, and then a. Select the Blends style to preview it.
select the Standard style and con-
tinue with the wizard.

rial
te
b. If desired, preview any other form styles
that interest you.

a
y
c. Select the Standard style.

op
5. Preview the various styles before
eM
d. Click Next.

a. If necessary, select Bold to preview the

tC
selecting the default Corporate bold report style.
style and continuing with the
wizard. No
n c
Do
e
se
r
fe

b. If desired, preview any other report


ea

styles that interest you.

c. Select the Corporate style.


Pl
Re

d. Click Next.

Lesson 8: Building the Structure of a Database 149


LESSON 8
6. Assign a title of Computer Inventory a. In the text box, type Computer Inventory
and continue with the wizard.

rial
te
b. Click Next.

a
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re

150 Microsoft® Office Access 2003 - Level 1


LESSON 8
7. The final screen asks if you want to a. Click Finish. A switchboard is displayed
open the database after the wizard with buttons for entering information and
builds it. Build the database. Review performing other actions.
its structure and then close it.

al
On slower computers, it may take Access
several minutes to build your database
from the template.

ri
te
b. Close the switchboard.

a
y
c. Restore Up the minimized database win-

op
eM dow from the bottom left of your
screen.

tC
No
c
d. After reviewing the Forms created for
you, click the Tables button and review
n

the tables created for you.


Do

e. Click the Queries button. No queries


were created for you.
e

f. Click the Reports button and review the


se
r

Reports created for you.


fe

g. Although it could be modified to meet


ea

your exact database design, you will


instead create an empty database and
build from scratch. Close the Computer
Inventory database window by clicking
Pl

the close button.


Re

Lesson 8: Building the Structure of a Database 151


LESSON 8
Procedure Reference: Create an Empty Database
To create a new blank database:
1. If necessary, start Access.
2. If necessary, display the New File task pane by clicking the New button.

al
3. In the New File task pane, under the New heading, click Blank Database.
4. If necessary, navigate to the location in which you wish to store the database file.

i
5. Assign a name to the database file.

r
6. Click Create.

te
ACTIVITY 8-2
Creating a New Blank Database

a
y
Scenario:
You’ve decided that you want a database that is precisely tailored to what you need to accom-

op
eM
plish, so you want to start it from scratch. You will create and save a new Access MDB file, so
you can then go on to create your own Access objects.

tC
What You Do How You Do It

1. Choose to create a Blank Database. a. If necessary, choose File→New to display


the New File task pane.
No
b. In the New File task pane, under the New
c
heading, click the Blank Database link.
n

2. Name the new database a. In the File Name text box, type
Do

MyComputerInventory.mdb and MyComputerInventory


save it in the My Documents folder.
e

b. If necessary, in the Save In drop-down list,


select My Documents.
se
r

c. Click Create.
fe
ea
Pl
Re

152 Microsoft® Office Access 2003 - Level 1


LESSON 8
d. Examine the database window. The
name of the new database is displayed in
the title bar. The title bar also indicates
that the database is in Access 2000 file
format.

rial
a te
y
op
eM
TOPIC B
Create a Table Using a Wizard
tC
No
c
A new blank database is just that—blank. You need to create all the appropriate tables to store
the data. There is a wizard available to help create tables, so you will try that out next.
n

Just because you aren’t using a template for your database, that doesn’t mean you can’t save
Do

time creating your tables. Wizards can simplify complex tasks for beginning users and can
save work for all users. It’s helpful to see what wizards are available for creating tables and
how they work so you’ll know when they might be useful to you.
e

How to Create a Table Using a Wizard


se
r

Procedure Reference: Create a New Table Using the Wizard


fe

To create a new table using the wizard:


ea

1. If necessary, in the database window, select Tables in the Objects bar.


2. Double-click Create Table By Using Wizard.
Pl
Re

3. Select the appropriate sample table.


4. From the sample table, add the sample fields you want to the new table.
5. If you wish, rename any fields by selecting the field and clicking Rename Field.
Enter the new name and click OK. Click Next.

Lesson 8: Building the Structure of a Database 153


LESSON 8
6. Assign a name to your table and select whether you want the wizard to set the
primary key or whether you wish to select it yourself. Click Next.
7. If you choose to set the primary key yourself:
a. Select the field that contains a unique value for each record.

al
b. Indicate the type of data you want the primary key field to contain.
c. Click Next.
8. If there are already other tables in your database:

i
a. Indicate whether the new table is related to any of them.

r
b. If the new table is related to an existing table, select that table, click Rela-
tionships, and select the type of relationship.

te
c. Click OK.
d. Click Next.
9. Select whether you want, after the table is created, to modify the design, enter
data directly in the table, or have the wizard create and display a form for you to

a
use to enter data. Click Finish.

y
Let Access Set the Primary Key

op
eM
If you choose to let the wizard set the primary key for you, one of two things will
happen. If you included an AutoNumber field (such as an ID Field) in your new table,
Access will designate that as the primary key. This means that Access will enter
unique sequential numbers in that field as you enter records. If there is not an

tC
AutoNumber field in your table, the wizard will add one with the same name as the
table followed by the abbreviation ID. You cannot change the values entered by Access
in an AutoNumber field. No
When are Numbers not Numbers?
c
Even though a field, such as an EmployeeID field, may contain numbers, it should not
necessarily be assigned a number data type. Examples of this are phone numbers, Zip
Codes, and Social Security numbers, which should be a text data type. You should use
n

the number data type only for fields that you will perform mathematical operations on.
Do
e
se
r
fe
ea
Pl
Re

154 Microsoft® Office Access 2003 - Level 1


LESSON 8
ACTIVITY 8-3
Create the Employees Table with a Wizard

al
Setup:
The MyComputerInventory database is open and the tables are displayed.

i
Scenario:
You’re creating your new database and want to start building the tables you need as quickly as

r
possible, so you’ve decided to try using a wizard. Your database diagram showing the tables
and their primary and foreign keys is in front of you. See Figure 8-2. You’ve decided to create

te
the table for information on employees first. Assume that the employees have IDs assigned by
the company.

a
y
op
eM
Figure 8-2: Diagram for the MyComputerInventory database.

tC
What You Do How You Do It

1. Start the wizard and review the a. Double-click Create Table By Using
No
Business and Personal sample tables Wizard.
c
that are available.
b. With Business selected, scroll the Sample
Tables list to see what tables are
n

available.
Do
e
se
r
fe
ea
Pl
Re

c. Select Personal.

d. Scroll the Sample Tables list.

Lesson 8: Building the Structure of a Database 155


LESSON 8
2. Using the Business sample tables, a. Select Business.
create an Employees table including
the EmployeeID, FirstName, and
LastName fields. b. In the list of Sample tables, select
Employees.

al
c. In the Sample Fields list, select
EmployeeID.

d. Click the right arrow button .

ri
e. In the Sample Fields list, select
FirstName and click the right arrow.

te
f. In the Sample Fields list, select LastName
and click the right arrow.

a
3. Based on the DepartmentName field, a. In the Sample Fields list, select
add a field named DeptCode. DepartmentName and click the right

y
arrow.

op
eM b. Click Rename Field
.

tC
c. In the Rename Field text box, type
DeptCode

d. Click OK.
No
c
e. Click Next.
n

4. Name the table and choose to set a. Name this table tblEmployees.
Do

the primary key yourself.


b. Select No, I’ll Set The Primary Key.
e

c. Click Next.
se
r

5. Specify that you want the data to a. Verify that the default field for unique
be numbers and/or letters that data entry will be EmployeeID.
fe

you’ll be entering.
ea

b. For the Primary Key datatype, select


Numbers And/Or Letters I Enter When I
Add New Records.
Pl
Re

c. Click Next.

6. Choose to enter data directly in the a. Verify that Enter Data Directly Into The
table and complete the wizard. Table is selected.

156 Microsoft® Office Access 2003 - Level 1


LESSON 8
b. Click Finish. The table is created and
shown in Worksheet view.

rial
c. Close the table.

te
TOPIC C

a
y
op
Create Tables in Design View eM
You’ve created a table with the Table Wizard. Now you’ll create additional tables using the

tC
more manual approach by working in Design View.
Wizards can be great time-saving devices. But for many tables there won’t be an appropriate
wizard. If you would spend more time altering the result of a wizard than creating a table from
scratch, then you should create your table in Design View.
No
c
How to Create Tables in Design View
n

Procedure Reference: Create a New Table in Design View


Do

To create a new table in Design view:


1. In the database window, in the Objects bar, select Tables.
e

2. Double-click Create Table In Design View.


se

3. For each field you wish to include in the table:


r

a. In the Field Name column, enter the name of the field.


fe

b. Click in the Data Type column for the field, display the drop-down list, and
ea

select the data type.


c. Make any changes you want to the Field Properties displayed in the lower
pane.
Pl
Re

4. Select the field(s) you want to set as the primary key and click the Primary Key
button.

You can also set the primary key by right-clicking the selected field and choosing Primary Key.

5. Click Save.

Lesson 8: Building the Structure of a Database 157


LESSON 8
6. Enter a name for the table. Click OK.

Field Size Property


The Field Size property is available for Text, Number, and AutoNumber fields. Your
database will perform more efficiently and will occupy less storage space if you set the

al
Field Size property to conform with the actual length of the data you will store in the
field. Look in Access Help for the topic on the FieldSize Property for details on the
various settings.

i
An AutoNumber Field as a Foreign Key
When you have an AutoNumber field as the primary key in one table and wish to use

r
that same field as a foreign key in another table, in that second table, you must set the
field’s data type to Number and the Field Size property to Long Integer.

te
ACTIVITY 8-4

a
Creating the Manufacturers Table in Design View

y
op
Setup: eM
The MyComputerInventory database is open and the tables are shown.

Scenario:

tC
You’re continuing to implement the design of your computer inventory database. See Figure
8-2. Since there aren’t appropriate sample tables available for all the tables you need, you’re
going to create the rest in Design view, starting with the Manufacturers table.
No
What You Do How You Do It
c
1. Open a table Design window and a. Double-click Create Table In Design
add an AutoNumber field named View.
n

ManufacturerID.
Do

b. In the first field in the Field Name col-


umn, type ManufacturerID
e

c. Click in the Data Type field for the


se

ManufacturerID record.
r

d. Click the down arrow and select


fe

AutoNumber.
ea

2. What is the default Field Size for the AutoNumber data type?
a) Byte
Pl
Re

b) Long Integer
c) Decimal
d) Currency

158 Microsoft® Office Access 2003 - Level 1


LESSON 8
3. Create a field named Manufacturer a. Click in the second field in the Field
that allows 30 characters of text. Name column.

b. Type Manufacturer

al
c. Press Tab. The Text data type is the
default.

d. In the Field Properties pane, select the

i
value in the Field Size property box.

r
e. Type 30

te
4. Set the ManufacturerID field as the a. Select the ManufacturerID record by
primary key. clicking the record selector at its far
left.

a
b. On the toolbar, click the Primary Key

y
button.

op
5. Save the table with the name
tblManufacturers and close the
Design window.
eM
a. Click Save.

b. In the Table Name text box, type

tC
tblManufacturers
If you notice in the database window that
you misspelled the name of the table,
you can change it. Right-click the table c. Click OK.
name and choose Rename. Enter the cor-
No
rect name and press Enter.
d. Click Close.
n c
Do
e
se
r
fe
ea
Pl
Re

Lesson 8: Building the Structure of a Database 159


LESSON 8
ACTIVITY 8-5
Create the Computers Table

al
Setup:
The MyComputerInventory database is open.

i
Scenario:
Now that you’ve successfully created your first table in Design view, you’re ready to create

r
the one to hold information on computers. The fields you need are listed in your database
diagram. See Figure 8-2.

te
What You Do How You Do It

1. In a new table design window, create a. Double-click Create Table In Design

a
an AssetTag text field that allows View.
four characters.

y
b. In the first Field Name field, type

op
eM AssetTag

c. Press Tab.

tC
d. Select the value in the Field Size prop-
erty box.

e. Type 4
No
c
2. Referring to your database diagram, you see that the next field, ManufacturerID is a
foreign key field. What data type and field size must it therefore have?
n

a) AutoNumber and Byte


Do

b) Number and Byte


c) AutoNumber and Long Integer
e

d) Number and Long Integer


se
r

3. Create a ManufacturerID field with a. In the next Field Name field, type
a data type of Number and a Field ManufacturerID
Size property of Long Integer.
fe
ea

b. Open the Data Type drop-down list and


select Number.

c. Click the Field Size property to verify


Pl
Re

that it is set to Long Integer.

160 Microsoft® Office Access 2003 - Level 1


LESSON 8
4. Create a DateTime field named a. In the next Field Name field, type
DateReceived that displays the DateReceived
ShortDate.
b. Open the Data Type drop-down list and
select Date/Time.

al
c. Click in the Format property box.

d. Open the Format drop-down list and

i
select Short Date.

r
5. Create a number field named a. In the next Field Name field, type

te
PurchasePrice. PurchasePrice

b. Open the Data Type drop-down list and


select Number.

a
6. Because PurchasePrice is a field with financial data, what datatype would likely be

y
better than number?
a) Text

op
b) Currency
c) Yes/No
eM
tC
d) Memo

7. Change the datatype to Currency. a. For the DataType of the PurchasePrice


field, select Currency.
No
c
b. Open the Decimal Places property drop-
down list and select 0.
n

8. Create a Warranty field as a Yes/No a. In the next Field Name field, type War-
Do

data type. ranty


e

b. Open the Data Type drop-down list and


select Yes/No.
se
r

9. Create an EmployeeID field as a a. In the next Field Name field, type


Text data type. EmployeeID
fe
ea

b. Open the Data Type drop-down list and


select Text.
Pl

c. Select the value in the Field Size prop-


Re

erty box. EmployeeID is a foreign key to


the Employees table and the primary key
of that table has a field size of 4. Type 4

Lesson 8: Building the Structure of a Database 161


LESSON 8
10. Set the primary key to AssetTag. a. Select the AssetTag field.

b. Click Primary Key.

al
11. Save the table as tblComputers and a. Click Save.
close the table Design window.
b. In the Table Name text box, type
tblComputers

i
c. Click OK.

r
d. Click Close.

te
PRACTICE ACTIVITY 8-6

a
y
op
eM
Completing the Tables for the Database
Activity Time:

tC
10 minutes

Scenario:
You need just two more tables to finish the implementation of your database design. You have
No
your database diagram, your notes about data types, and the previous activities as resources.
c

1. Create and save the tblDepartments table with these specifications:


n


Do

A DeptCode field with a data type of Text and a field size of 3.


• A Department field with a data type of Text and a field size of 50.

e

The DeptCode field as the primary key.

2. Create and save the tblNotes table with these specifications:


se
r

• An AssetTag field with a data type of Text and a field size of 4.


• A Note field with a data type of Memo.
fe

• The AssetTag field as the primary key.


ea
Pl
Re

162 Microsoft® Office Access 2003 - Level 1


LESSON 8
TOPIC D
Create Relationships between Tables

al
Once you’ve built the tables you need in your database, the last step in implementing your
design is to establish the appropriate relationships between the tables.
You can’t harness the full power of a relational database management system like Access with-

i
out establishing table relationships and using referential integrity. Together, these features help
to ensure the accuracy of the data, and enable the breadth of queries and reports that you will

r
likely want to use to retrieve, display, and print your data.

te
One-to-One Relationship
Definition:
A one-to-one relationship is a relationship between two tables where both the primary

a
key and the foreign key are unique. For each record in the first table there will be one

y
and only one record in the second table.

op
Example:
eM
tC
No
n c
Do
e
se
r
fe
ea

Figure 8-3: A one-to-one relationship between two employee data tables,


Pl
Re

using the EmployeeID field as the key.

Information about employees might be separated into two tables for security access reasons.

Lesson 8: Building the Structure of a Database 163


LESSON 8
One-to-Many Relationship
Definition:
A one-to-many relationship is a relationship between two tables where the primary key

al
is unique but the foreign key allows duplicate values. For each record in the primary-
key table there can be multiple records in the foreign-key table.

Depending on which of the two tables you’re looking at, you can also express this as a many-to-one
relationship.

ri
Example:

a te
y
op
eM
tC
No
c

Figure 8-4: A one-to-many relationship between a Customers table and an


n

Orders table, using the CustomerID field as the key.


Do

Many-to-Many Relationship
e

In examining the relationships between data in tables, you may find that you have a
many-to-many relationship between two tables. This is when many records in one table
can relate to many records in another table. For example, if you had a table for
se
r

employees and another for projects, you might find a many-to-many relationship if
each employee could work on many projects and each project could involve many
fe

employees. This relationship cannot be implemented directly in Access and would have
ea

to be resolved by the creation of an intersection table containing, for example, just


EmployeeID and ProjectNumber fields. This table would have a many-to-one relation-
ship with both of the other tables.
Pl
Re

Enforce Referential Integrity


Enforcing referential integrity for a relationship can avoid the loss or inadvertent updating of
data.

Guidelines:
You can set referential integrity between two tables if the following are true:

164 Microsoft® Office Access 2003 - Level 1


LESSON 8
• Both tables are in the same Access database.
• The matching field is a primary key in one table or has a unique index.
• The related fields have the same data type (the exception is that an AutoNumber
field can be related to a Number data type with a field size of Long Integer).

al
The Effects on Data Modification
When referential integrity is enforced (without enabling the cascading options), certain
rules apply to the data. This list gives you some examples.

i
You can’t enter a value in the foreign key field of one table if there is not a
matching value in the primary key of the related table.

r
• You can’t delete a record from the primary table (the table in which the primary
key is the related field) if a matching record exists in the related table.

te
• You can’t change the value in the primary key of the primary table if there are
related records in the related table.

Referential integrity is a rich subject. In this course you are only considering the basics of using it.

a
Additional concepts included orphaned records and cascading updates and deletes.

y
op
Example: eM
A CustomerID autonumber field in the Customers table is a unique primary key and
can be related to a number field in the Orders table in a one-to-many relationship. You
don’t want to allow the user to enter any order data for a customer that doesn’t have a

tC
record in the Customers table. Nor do you want the user to alter the CustomerID field
for a record in the customers table, because that would break the link with the related
orders data for that customer. Deleting a customer record that has matching order
records would also not be allowed. This is a good candidate for enforcing referential
integrity.
No
c
How to Create Relationships between Tables
n

Procedure Reference: Create a Relationship and Enforce Referential Integrity


Do

To create a relationship between two tables and enforce referential integrity between
them:
e

1. Choose Tools→Relationships to open the Relationships window.


se

2. In the Show Table dialog box, select the tables you want to work with and click
r

Add.
fe
ea

To select multiple tables in the Show Table dialog box, you can use Shift-click to select adjacent
tables and Ctrl-click to select non-adjacent tables.

3. Close the Show Table dialog box.


Pl
Re

4. Select the key field in the primary table that you want to relate to the second
table.
5. Drag the key to the related foreign key in the second table.
6. In the Edit Relationships dialog box, check Enforce Referential Integrity.
7. Click Create.

Lesson 8: Building the Structure of a Database 165


LESSON 8
8. Close the Relationships window, saving changes to its layout.

ACTIVITY 8-7

al
Creating One-to-Many and One-to-One Relationships
Setup:

i
The MyComputerInventory database is open and the Employees, Manufacturers, Computers,

r
Departments, and Notes tables have been created.

Scenario:

te
By considering your primary and foreign keys, and the type of data that will be stored in your
tables, you can determine what types of relationships there are between your tables. You want
to help ensure the accuracy of the data, so you’ve decided to enforce referential integrity in all
relationships. You do this by working in the Relationships window. See Figure 8-5.

a
y
op
eM
tC
Figure 8-5: The relationships in the MyComputerInventory database.
No
c
What You Do How You Do It

1. Display all five tables in the Rela- a. Choose Tools→Relationships.


n

tionships window.
Do

b. With tblComputers selected on the Tables


tab of the Show Table dialog box, press
e

Shift, and select tblNotes in the list of


tables.
se
r

c. Click Add.
fe

d. Click Close.
ea

2. Adjust the size of the tblComputers a. Place the mouse pointer over the bot-
table so you can view the entire list tom edge of the tblComputers table until
Pl

of fields. the mouse pointer becomes a vertical


Re

double-headed arrow.

b. Drag the bottom border down until you


can view all fields and the vertical scroll
bar is no longer displayed.

166 Microsoft® Office Access 2003 - Level 1


LESSON 8
3. The tables in the Relationships window are arranged in order by default.

4. Rearrange the tables for optimal a. Click and drag the tblManufacturer table
relationship mapping. under the tblNotes table.

al
b. Click and drag the tblComputers table to
the left of the tblNotes table.

5. What sort of relationship is there between the tblDepartments and tblEmployees tables

i
and why?

r
a) There is a one-to-one relationship because for every department record there will be
one employee record.

te
b) There is a one-to-many relationship because for each department record there could
be many employee records.
c) There is a one-to-many relationship because for each employee record there could
be many department records.

a
6. Create the relationship between a. In the Departments table, select the

y
the tblDepartments and DeptCode field.
tblEmployees tables.

op
eM
b. Drag the DeptCode field of the
tblDepartments table to the DeptCode
field in the tblEmployees table.

tC
In doing so you are dragging from the one-side
to the many-side of the relationship.
No
7.
n c
Do
e
se
r
fe
ea

In the Edit Relationships window, what kind of relationship is given as the Relationship
type?
Pl
Re

a) One-to-One
b) One-to-Many
c) Many-to-One
d) Many-to-Many

Lesson 8: Building the Structure of a Database 167


LESSON 8
8. Enforce referential integrity in this a. In the Edit Relationships dialog box, check
relationship. Enforce Referential Integrity.

b. Click Create.

al
9. What sort of relationship is there between the tblComputers and tblNotes tables

and why?
a) There is a one-to-one relationship because for each computer record there will be at

i
most one note record, and vice-versa.

r
b) There is a one-to-many relationship because for each computer record there could
be many note records.

te
c) There is a one-to-many relationship because for each note record there could be
many computer records.

10. Create the relationship between a. Drag the AssetTag field from the
the tblComputers and tblNotes tblComputers table to the AssetTag field

a
tables but do not enforce referen- of the tblNotes table.

y
tial integrity in the relationship.
b. Verify that the Relationship Type is One-

op
eM To-One. Click Create.

Given that the data was fully normalized so that


the Notes information is in a separate table,

tC
you would not want to enforce referential integ-
rity on this one-to-one relationship. Doing so
would require that every record in the
tblComputers table have a corresponding
record in the tblNotes table, which is not the
No
case and was the reason for normalizing this
c
data (there were blank fields). This is an
example where denormalizing the Notes data is
an option.
n
Do

11. Create the relationship between a. Drag the EmployeeID field from the
the tblEmployees and tblComputers tblEmployees table to the EmployeeID
e

tables and enforce referential field of the tblComputers table.


integrity in the relationship.
b. Verify that the Relationship Type is One-
se
r

To-Many and then check Enforce


Referential Integrity.
fe
ea

c. Click Create.
Pl
Re

168 Microsoft® Office Access 2003 - Level 1


LESSON 8
12. Create the relationship between a. Drag the ManufacturerID field from the
the tblManufacturers and tblManufacturers table to the
tblComputers tables and enforce ManufacturerID field of the
referential integrity in the tblComputers table.
relationship.

al
b. Verify that the Relationship Type is One-
To-Many and then check Enforce
Referential Integrity.

i
c. Click Create.

r
13. Preview and print the Relationships a. Choose File→Print Relationships to pre-
window object, and then save your view the printing of the Relationships

te
work. window.

b. Click Print.

a
If you do not have a printer available you will

y
not be able to actually print this page and may
get an error message.

op
eM
c. Close the Report window that was
opened and save the changes when
asked.

tC
Be sure to save the changes you have made to
the relationships or the same graphical repre-
sentation of the relationships will not be
No
displayed the next time you open the window.
c
d. Close the Relationships window.
n
Do

e. Close the MyComputerInventory


database.
e
se
r

Lesson 8 Follow-up
fe
ea

In this lesson, you implemented your database design plan. You saw that creating a blank data-
base is fairly easy, but adding custom tables can be a little trickier. When appropriate, using
the Table Wizard, or even a template for an entire database, can save you time and
Pl
Re

aggravation. You also learned that no database is complete without the right relationships
between your tables to help maintain the accuracy of your data.
1. In what circumstances would you prefer to create a database using a template over
creating one from scratch?

Lesson 8: Building the Structure of a Database 169


LESSON 8
2. Do you think the Table Wizard will offer most of the table-building functions you
require, or will you often build tables in Design view?

rial
a te
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re

170 Microsoft® Office Access 2003 - Level 1


LESSON 9

al
LESSON 9 Lesson Time
40 minutes

ri
Controlling Data Entry

a te
Lesson Objectives:

y
op
entry and maintain data integrity.
You will:
eM
In this lesson, you will control data entry by modifying the design of a table to streamline data

tC
Restrict data entry with field properties that set a default value, require data entry, and
validate data.
• Create an input mask to limit the type of information that can be entered.
• Add a lookup field to a table and modify a lookup list used in a lookup field.
No
n c
Do
e
se
r
fe
ea
Pl
Re

Lesson 9: Controlling Data Entry 171


LESSON 9
Introduction
You have a simple database and you want to control how data will be entered. There are
numerous enhancements you can make to tables to enable this. In this lesson you will consider
some that will help you to better control data entry.

al
Data consistency is one of the most important aspects of a good database. For example, to
enable consistent phone number formatting, you can pre-format how data will be entered in
that field. Or consider a required name field: you can ensure consistency and reduce errors by
requiring that each record have a name value.

ri
TOPIC A

te
Restrict Data Entry with Field

a
Properties

y
The first thing you’ll do to get started in controlling data entry is to work with properties of

op
eM
the fields in your tables. These properties can help make data entry more accurate.
Having the right kind of data in a field can often be critical. Consider the case where a calcu-
lation on a number field demands that no null (empty) fields be present. To avoid the

tC
possibility that a user forgets to enter a value, you can set field properties to require data entry
and provide a default value of 0. Or consider a case where you must have a value between 1
and 5. By using field properties you can restrict the data so that a value of 6, for instance,
would not be permitted. Simple field properties can help to restrict data entry and eliminate
errors in your tables and queries.
No
c
Field Properties
n

To enhance a table’s design and to facilitate data entry in the datasheet and its related forms,
Do

you can set field properties. Each field in your table has a set of field properties that you can
change and modify to affect how the field looks and works. When you set these properties,
you can increase the ease, speed, and accuracy of entering data. (See Table 9-1.)
e

Table 9-1: Essential Field Properties that Affect How a Field Appears and Behaves
se
r

Property Description
Format Determines the way data is displayed. For example, if you use the greater
fe

than (>) symbol, it forces all characters to uppercase so Access automati-


ea

cally capitalizes the data entered. Use the Format field property when you
need to display data in a consistent format.
Default Value A value that will be automatically entered for the field when you create a
new record. It only affects new records and does not alter the values of
Pl
Re

existing data. Establishing default values can save you a lot of typing,
especially when one value will be consistently entered in a field.
Caption The text that will be displayed in place of the FieldName as the column
heading in Datasheet view. It will also be used as the Label control in a
form where the field is dragged from the field list.

172 Microsoft® Office Access 2003 - Level 1


LESSON 9
Property Description
Required If set to Yes, a value is required for that field. If set to No, the value can
be left blank. Access displays an error message if you attempt to save a
record that has a null value in a required field.

al
Validation Rule Establishes a rule to set boundaries for data entry in a field. For example,
this property can be used with currency and number fields to check for
minimum or maximum allowed values, or it can be used with date fields
to ensure that the data isn’t entered before or after a specified date.

i
Validation Text A message that is displayed when the validation rule is violated. You can
customize the error message that’s displayed when a validation rule is vio-

r
lated or a required field is left blank.

te
How to Restrict Data Entry with Field Properties
Procedure Reference: Set Field Properties

a
y
To set field properties:

op
1. Display the table in Design view.
2.
field.
eM
In the upper pane, click the name of the field to display the properties for that

tC
3. In the lower pane, click the text box for the desired property and add or update its
value.

To obtain help specific to this property, press F1.


No
c
4. Save your changes to the table.

Modified Field Properties


n

Each time you change the properties in a table’s design, you must save the table before
Do

you can switch to Datasheet view and work with the records. If you are working with
a table that already contains records, then the new validation rules will be applied only
to new data entered after you set the rules. You will be asked whether you want
e

Access to check existing table data to see if it complies with the validation rules. After
Access checks the existing records, a message box is displayed letting you know
se

whether the records do or do not meet the new criteria. (There is no notification on an
r

individual record basis. You would have to use queries to find the data that does not
meet the validation rules.)
fe
ea

If you save a table using a different name after setting new validation rules, this would
create a new table with no records. The new table’s design contains the validation
rules, so each new record you enter must meet these validation rules.
Pl
Re

You can’t override a validation rule during data entry or editing. If you attempt to type or copy/paste
data, you must satisfy the validation rule for the corresponding field.

Lesson 9: Controlling Data Entry 173


LESSON 9
ACTIVITY 9-1
Setting a Default Value, Requiring Data Entry, and

al
Validating Data
Data Files:
• Control.mdb

ri
Scenario:
You have a personnel database with employee information such as name, address, start date,

te
pay rate, and so on. Because others will be entering data into tblPayroll, you feel compelled to
build in some constraints so data is entered as you would expect. You know that some people
will enter uppercase codes and others will use lowercase. Therefore, you want to have Access
automatically capitalize the letters in the Dept and ParkingLotCode fields. Also, most employ-
ees work 40 hours a week and none get paid more than $30 per hour.

a
y
What You Do How You Do It

op
1. eM
In the Control database, open
tblPayroll in Design view.
a. Open Control.mdb.

b. Maximize the Control database window.

tC
c. Open tblPayroll in Design view.

2. Format the ParkingLotCode and a. Display the properties for the Dept field.
No
Dept fields so that the values will
c
be displayed in uppercase.
b. In the Field Properties pane, in the For-
mat property text box, enter > to force
uppercase.
n
Do

c. In the Field Name column, click in the


ParkingLotCode cell.
e

d. In the Format field property, enter >


se
r

e. In the Caption property, enter Parking


Lot
fe
ea

3. Set the default for the Hours field a. Display the properties for the Hours
to 40. field.
Pl
Re

b. The Default Value field property is set to


0. Select the Default Value property and
change it to 40

c. Press Enter.

174 Microsoft® Office Access 2003 - Level 1


LESSON 9
4. Require that values for the PayRate a. Display the PayRate field properties.
field be less than $30.00.
b. Select the Validation Rule property and
change it to <30

al
5. Display a message when invalid data a. Press Tab to move the insertion point to
is entered and require that a value the Validation Text property box.
for this field be given.
b. In the Validation Text property box, type

i
Must enter a value under $30.

r
c. Press Tab to move to the Required prop-

te
erty box.

d. From the Required drop-down list, select


Yes.

a
6. Save this table as tblMyPayroll. a. Choose File→Save As to save the table

y
with a new name.

op
eMb. Save this table as tblMyPayroll

c. Switch to Datasheet view.

tC
7. A default value of is displayed in the Hours field.

8. In the EmployeeID field, enter en1- a. In the EmployeeID field, type en1-60
No
60.
c
b. Press Enter.
n

c. In the Hours field, press Enter.


Do

9. In the PayRate field, test the valida- a. In the PayRate field, type 32.50
e

tion properties and then enter


22.50.
b. Press Enter.
se
r
fe
ea
Pl
Re

c. Click OK.

Lesson 9: Controlling Data Entry 175


LESSON 9
d. Delete the value you typed, and then
with the field empty press Enter.

al
e. Click OK.

ri
f. Enter 22.50

te
g. Press Enter.

10. Complete the record by entering tw a. In the Dept field, enter tw


in the Dept field, bl in the
ParkingLotCode field, and a check

a
b. In the ParkingLotCode field, enter bl
mark in the Health field.

y
c. In the Health field, press Spacebar to

op
eM enter a check mark.

You can also click in the check box to check


(or uncheck) it.

tC
11. Save the record and close the table. a. The pencil icon is still displayed at the
left end of the record, indicating that the
No
record isn’t saved yet. Press Enter to
save the record and remove the pencil
c
icon.
n

b. Close the table.


Do
e
se
r
fe
ea
Pl
Re

176 Microsoft® Office Access 2003 - Level 1


LESSON 9
TOPIC B
Create an Input Mask

al
You have just used some of the properties of your fields to improve the accuracy of the data in
your tables. In this topic you will use another field property to limit the format that users can
enter data in.

i
Suppose you have a phone number field. Assume further that as you enter phone numbers, you
need to add parentheses around the area code and a hyphen between the digits. Sometimes you

r
remember the pattern and other times you forget. If you could force data input to match a spe-
cific pattern, this problem would be solved, thereby eliminating inconsistency in this field in

te
your table. An added bonus of sticking to a pattern is that you can save time because Access
automatically enters characters for you, such as slashes and hyphens, so you don’t have to
enter them yourself.

a
Input Masks

y
Definition:

op
eM
An Input Mask is a field property that establishes a pattern that dictates how users can
enter data into the field. An input mask contains literal characters (for example, spaces,
dashes, or parentheses) that separate blanks the user fills in. The blanks are represented

tC
by characters that control the type of data the user can type in.

Input Mask Sections


An input mask definition can contain up to three sections, separated by semicolons:
• The first section is the input mask itself.
No
c
• The second section determines whether the literal display characters are stored. If
you leave this section blank or enter a 1, only the characters the user enters are
stored; if you enter a 0, the display characters (along with the characters the user
n

enters) are stored. By not storing the literal display characters, you can reduce the
Do

size of your database.


• The third section represents the character that is displayed for blanks in the input
e

mask. By default, it is an underscore, but you can use any of a variety of


characters. To display a space (or empty string), use two quotation marks (“ ”).
se
r
fe
ea
Pl
Re

Lesson 9: Controlling Data Entry 177


LESSON 9
Example: Telephone Number Input Mask

rial
te
Figure 9-1: The input mask for a standard telephone number including area
code.

Example: Zip Code Input Mask

a
y
op
eM
tC
No
Figure 9-2: The input mask for a Zip Code with an optional four-digit
extension.
c
Input Mask Wizard
n

Most often, input masks are created using the Input Mask Wizard. This wizard pro-
Do

vides several common, predefined input masks, and takes you through the steps of
creating your own custom input masks. If you need to modify an input mask, see the
Access Help topic, “Valid Input Mask Characters,” for a table of the characters you
e

can use. Be sure to check your data first to be aware of any conflicts that might arise
from a modified input mask.
se
r

How to Create an Input Mask


fe
ea

Procedure Reference: Add an Input Mask Using the Wizard


To add an input mask using the wizard:
1. In the Table Design view window, click the field that the input mask will belong
Pl
Re

to.
2. In the Field Properties pane, click in the Input Mask property box.
3. Click the Build button at the end of the line to start the Input Mask Wizard.
4. Choose an input mask type. Click Next.
5. Choose the desired placeholder. Click Next.

178 Microsoft® Office Access 2003 - Level 1


LESSON 9
6. Choose whether the symbols will display to the user. Click Next.
7. If you want to modify an input mask, click Edit List. You can change the
placeholder character and choose to store constant characters like dashes and
slashes with the field value.

al
8. Click Finish when you are done with the wizard.

The Input Mask Wizard is available for Text and Date/Time fields. If you want to create an input
mask for a Number or Currency field, you must create it manually instead of using the wizard.

ri
Procedure Reference: Manually Add an Input Mask to a Field
To manually add an input mask to a field:

te
1. In the Table Design view window, click the field that the input mask will belong
to.
2. In the Field Properties pane, click in the Input Mask property box.

a
3. Enter the input mask desired for this field.

y
Placeholders are replaced as you enter data into the field. The default placeholder is the

op
underscore. eM
ACTIVITY 9-2
tC
Adding Pre-defined and Custom Input Masks No
Data Files:
c
• Control.mdb
n

Setup:
Do

The Control database window is open. The additional wizards were installed as part of the
class setup.
e

Scenario:
In order to improve data entry for the tblPersonal table, you decide to add input masks to the
se
r

Phone, ZipCode, and EmployeeID field properties to ensure that data entry is uniform.
fe

What You Do How You Do It


ea

1. Display the properties for the a. To review the phone and Zip code data,
Phone field in the tblPersonal table. open tblPersonal.
Pl
Re

b. Switch to Design view.

c. Display the field properties for the


Phone field.

Lesson 9: Controlling Data Entry 179


LESSON 9
2. Start the Input Mask Wizard to add a. Click in the Input Mask property box.
an input mask for all phone
numbers.
b. Click the Build button .

al
3. Use the wizard to create the input a. In the Input Mask list box, verify that
mask. Save the modified table Phone Number is selected. Click Next.
design.
b. To see the available placeholders, display
and scroll through the Placeholder char-

i
acter drop-down list. There are several

r
options available.

te
c. Select the underscore character so it’s
displayed in the Placeholder Character
box.

d. Click Next.

a
y
e. Verify that the default option, Without
The Symbols In The Mask, Like This, is

op
eM selected. Click Next.

tC
f. Click Finish. Press Enter. The input mask
No
is entered in the property box for the
c
Phone field.
n
Do
e

For more information about the symbols used in


Input Masks, press F1 to consult the Help specific
to this property.
se
r

g. Save the modified table design.


fe
ea
Pl
Re

180 Microsoft® Office Access 2003 - Level 1


LESSON 9
4. Add an input mask for the ZipCode a. Display the field properties for the
field that reflects the zip code + 4 ZipCode field.
convention.
b. Click in the Input Mask property box.

al
c. Click the Build button.

d. Select Zip Code.

i
e. Click Next.

r
f. Click Next to accept the defaults.

te
g. Verify that the default option, Without
The Symbols In The Mask, Like This, is
selected. Click Next.

a
y
h. Click Finish. The input mask is entered in
the property box for the ZipCode field.

op
eM
i. Save the modified table design.

tC
5. Create an input mask that reflects a. Display the field properties for the
the pattern for the EmpID field. EmpID field.

b. Start the Input Mask wizard.


No
c
c. You can customize or create an input
mask list right in the wizard. Click Edit
List.
n
Do

d. To create from scratch, rather than edit


an existing mask, click the New Record
button .
e

e. In the Description text box, type


se
r

Employee ID and press Tab.


fe

f. Type !LL0-00 and press Tab.


ea

g. Type _ (the underscore character), and


then press Tab.
Pl
Re

Lesson 9: Controlling Data Entry 181


LESSON 9
h. Type EN1-80 and press Tab.

rial
te
You need to enter a value in the Sample Data box
now; it’s later displayed in the list of input masks.

i. Click Close.

a
y
j. Select the Employee ID input mask from

op
eM the list.

k. Click Next twice to advance in the


wizard.

tC
l. This time, select the With The Symbols
In The Mask, Like This option. Click
Next.
No
n c
Do

m. Click Finish.
e

6. Save the modified table design. Pre- a. Save the modified table design.
pare to enter a new record.
se
r

b. Change to Datasheet view.


fe

c. Click the New Record button .


ea
Pl
Re

182 Microsoft® Office Access 2003 - Level 1


LESSON 9
7. Enter a new record in the table to a. Type en160 and press Tab.
test your input mask.
b. Type Thacher and press Tab.

al
c. Type Jeremy and press Tab.

d. Type 33 Strong Rd and press Tab.

i
e. Type Dresden and press Tab.

r
f. Type ny and press Tab.

te
g. Type 145278788 and press Tab.

h. Type 2155558288 and press Tab.

a
i. Type 08/20/2001 and press Enter.

y
op
eM
j. Close tblPersonal.

TOPIC C
tC
No
c
Create a Lookup Field
n

You’ve looked at field properties and input masks as a means for controlling data entry in your
Do

tables. Another way to control data entry is to limit the exact values that can be entered in a
field. In this topic, you’ll create a drop-down list of items to choose from when entering data
e

in a field.
When someone should choose only from a specific set of options, it’s much easier to have
them select from that set of options, rather than leaving it wide open to fill in what they
se
r

please, in the way they please. A set of choices is particularly useful if you repeatedly enter
the same data in a field and you want to limit typing and reduce errors. As an added bonus,
fe

entering data in a consistent manner enables you to derive solid summary information for the
ea

field, because you can more easily build queries using that field as a criteria.

Lookup List Fields


Pl
Re

Definition:
A lookup list is a list of values that you can choose from when entering data in a field.
These values can be from a custom listing of possible values or a table or query in the
database. A lookup list can display one or more columns of data, but designates one
column as the provider of the value to be stored in the field. Column headings can be
optionally displayed, and column widths can be adjusted as needed.

Lesson 9: Controlling Data Entry 183


LESSON 9
A lookup list can be created by using the Lookup Wizard or can be created manually by using various
field properties on the Lookup tab in Design View. The resulting list that the user will see can be either
a List Box or a Combo Box.

al
Example: Single-column Lookup List

ri
a te
y
op
eM
Figure 9-3: A lookup list with custom values for personal title abbreviations.

tC
Example: Multi-column Lookup List
No
n c
Do
e
se
r
fe
ea
Pl
Re

Figure 9-4: A lookup list that displays multiple columns to ease the selection
of a product’s CategoryID.

184 Microsoft® Office Access 2003 - Level 1


LESSON 9
Lookup List Relationships
Relationships will automatically be created when you create a lookup list field. To see
these relationships, you can choose the Show All option in the Relationships Window.

How to Create a Lookup Field

al
Procedure Reference: Create a Lookup Column Based on a Table
To create a lookup column based on a table (or query):

i
1. In table Design view, select the field in which you want to include a drop-down

r
list of values.
2. In the Data Type column, select Lookup Wizard.

te
3. Choose to base the list on the values in a table (or query). Click Next.
4. Choose the desired table (or query). Click Next.
5. Select fields to appear in the lookup list. Click Next.

a
6. Choose any desired sort criteria for the displayed columns in the lookup column.

y
Click Next.

op
7.
8.
eM
If desired, uncheck Hide Key Column.
If necessary, double-click column borders to resize them for the best fit. Click
Next.

tC
9. Choose a column whose value will be stored for this field. Click Next.
10. Type a label for this field. Click Finish.
11. Save your table.
No
c
ACTIVITY 9-3
n
Do

Adding a Lookup Field to a Table Using the Lookup


Wizard
e

Data Files:
se
r

• Control.mdb
fe

Setup:
ea

The Control database window is open. The additional wizards were installed as part of the
class setup.

Scenario:
Pl
Re

The Dept field in tblPayroll stores department codes for each department. To ensure a valid
department code in a new record and to simplify data entry, you will create a lookup list that
displays both the department codes and the names, with column headings. You will restrict
data entry to only the department codes in the tblDeptNames table. (See Figure 9-5 .)

Lesson 9: Controlling Data Entry 185


LESSON 9

al
Figure 9-5: A lookup list that displays department codes and names.

ri
What You Do How You Do It

1. In tblPayroll, start the Lookup Wiz- a. Open tblPayroll in Design view.

te
ard for the Dept field.
b. Display the DataType drop-down list for
the Dept field.

a
c. To start the wizard, select Lookup

y
Wizard.

op
eM
tC
No
c
2. Specify the source data for the a. Verify that the I Want The Lookup Col-
lookup column. Display both columns umn To Look Up The Values In A Table
n

from tblDeptNames in the lookup Or Query option is selected. Click Next.


Do

column.
e
se
r

b. Verify that tblDeptNames is selected


fe

from the list of tables and click Next.


ea

c. From the Available Fields list box, move


both fields to the Selected Fields list
box, by pressing the >> button, and then
Pl
Re

click Next.

186 Microsoft® Office Access 2003 - Level 1


LESSON 9
3. Sort and adjust the width of the a. Display the drop-down list for the first
fields in the Lookup Column. sort criteria.

al
b. Select DeptCode. Click Next.

ri
c. Uncheck Hide Key Column.

te
Although it is recommended that you hide the
key column, in this lookup list, you want to see
it and later use it to store the value entered in
the lookup column.

a
y
d. For best fit, double-click the DeptName
right column border.

op
eM
tC
No
c
This will only resize the column to fit the values that
are shown.
n

e. Click Next.
Do

4. Use DeptCode as the field that a. In the Available Fields list box, verify that
e

uniquely identifies the row in the DeptCode is selected. Click Next.


lookup column and finish the
wizard.
se

b. For the lookup column label, type


r

DeptCode
fe

c. Click Finish.
ea

d. Click Yes to save the table before Access


can create relationships.
Pl
Re

Lesson 9: Controlling Data Entry 187


LESSON 9
5. Test the behavior of the lookup list a. Switch to Datasheet view.
by assigning the first employee to a
new department.
b. In the first record, select the DeptCode
field. A drop-down arrow indicates the
presence of the list.

al
c. Click the drop-down arrow to display the
lookup list.

i
d. Select AC for the Accounting

r
department.

a te
y
op
6. eM
Display the properties established
by the wizard for the lookup list.
a. Switch to Design view.

b. If necessary, select the DeptCode field.

tC
c. In the Field Properties pane, select the
Lookup tab.
No
7. Include the column headings in the a. On the Lookup tab, change the Column
c
lookup list and display the lookup Heads field property to Yes.
list.
b. Save the modified table design.
n
Do

c. Switch to Datasheet view.


e

d. In the DeptCode field, display the Lookup


list for the first record to see the column
se

headings.
r
fe
ea
Pl
Re

e. Close the lookup list.

188 Microsoft® Office Access 2003 - Level 1


LESSON 9
8. Restrict entries in the field only to a. Switch to Design view and change the
items on the list. Limit To List field property to Yes.

b. Save the modified table design.

al
9. Test to see how this affects the a. Switch to Datasheet view.
lookup list interaction and then
close the table.
b. In the DeptCode field for the first record,
select the value, type PO, and press

i
Enter.

r
c. Only the department names listed are

te
acceptable. Click OK. Click Undo.

d. Close tblPayroll.

e. If asked, save your changes.

a
y
f. Close the Control database window.

op
eM
tC
Lesson 9 Follow-up
In this lesson, you controlled data entry by modifying the design of a table. By modifying
No
various field properties, and by using input masks and lookup fields, you have increased the
c
consistency of your data and reduced data entry errors.
1. Where do you expect to use Input Masks to control data entry in your databases?
n
Do

2. Where do you expect to use Lookup Fields to control data entry in your databases?
e
se
r
fe
ea
Pl
Re

Lesson 9: Controlling Data Entry 189


NOTES

rial
a te
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re

190 Microsoft® Office Access 2003 - Level 1


LESSON 10

al
LESSON 10 Lesson Time
1 hour(s)

ri
Finding and Joining Data

a te
Lesson Objectives:

y
op
and within a single table.
You will:
eM
In this lesson, you will find and retrieve desired data by using filters and joins between tables

tC
Apply a filter to view records that match criteria you specify.
• Create query joins to retrieve the desired data.
• Join two unrelated tables by including additional tables in a query.
• Relate data within a single table to itself.
No
n c
Do
e
se
r
fe
ea
Pl
Re

Lesson 10: Finding and Joining Data 191


LESSON 10
Introduction
You’ve worked with simple queries that returned a specific record or a subset of records from
a table. In this lesson, you will further this knowledge by using filters, building queries that
retrieve data from multiple tables, and relating data within a single table to retrieve the desired

al
records.
You are a project manager who needs to build a team of Java developers for a new
application. Using your personnel skills database you could quickly find the available employ-
ees who know Java from both your Seattle and Baltimore offices. Joining those results together

i
into one set of records would efficiently create the ideal project team.

r
te
TOPIC A
Find Data with Filters

a
y
There are many ways to find the data you need. In this topic you will learn the simplest
approach by using table filters. You’ll use several different methods for finding and displaying

op
the desired records. eM
Consider the following scenario: you are working in a table in worksheet view, and you want
to quickly see all the records that have the same value in the LastName field. Instead of leav-

tC
ing the table and creating a query to return these records, you can save time by simply
applying a filter to the table. Such a filter is like a magic wand for quickly getting to the data
you want.
No
Types of Filters
c
Filtering data can help you review and analyze information in your database. You can use one
of several techniques to filter data. (See Table 10-1.)
n
Do

Table 10-1: Filter Techniques


Filter Technique Results
e

Filter By Selection Lets you select a value in a datasheet or form and click a button to view any
matching records.
se

Filter Excluding Looks for values other than what you select.
r

Selection
Filter By Form Shows you a blank record where you can enter either the value you want to find
fe

or choose it from a drop-down list.


ea

Advanced Filter/ Lets you freely combine conditions and fields for a filter. You can also use this to
Sort sort a filtered view or set up multi-field sorts.
Pl
Re

Saving a Filter
Filter settings are saved with the table or form. Therefore, even if you do not modify
the data in a table, if you altered a filter setting, upon closing the table you will be
asked if you would like to save the table or not. When using an Advanced Filter, you
can quickly remove the saved filter settings: right-click in the top pane and choose
Clear Grid.

192 Microsoft® Office Access 2003 - Level 1


LESSON 10
How to Find Data with Filters
Procedure Reference: Use the Filter By Selection Technique
To use the Filter By Selection technique, perform the following steps:

al
1. Open a table or query in datasheet view.
2. Select one instance of the value that you want included in the view.
3. Click the Filter By Selection button.

ri
You can continue filtering until you get the results you want.

te
Procedure Reference: Use the Filter By Form Technique
To use the Filter By Form technique, perform the following steps:
1. Open a table in datasheet view.

a
2. Open the Filter By Form window.

y
3. Specify the criteria on the Look For and Or tabs.

op
4. Apply the filter.

Procedure Reference: Create an Advanced Filter or Sort


eM
tC
To create an advanced filter or sort, perform the following steps:
1. Open the Datasheet or Form view you want to filter.
2. Open the Advanced Filter/Sort dialog box. No
3. In the filter window, clear the grid.
c
4. Enter a field name in the grid. You can use any of the following techniques:
• On the list in the top of the window, double-click a field name.
n

• In the Field row, type a field name.


Do

• From the list in the top of the window, click and drag a field name.
• From the drop-down list for the Field row, choose a field name.
e

5. Enter a value in the Criteria row for the field.


• For an And filter, enter criteria for two fields.
se
r

• For an Or filter, enter an additional condition in the Or row for whatever


field it applies to.
fe
ea

6. If necessary, sort records.


7. Apply the filter.
Pl
Re

Using Criteria to Filter Records


Criteria are conditions that identify the records you want to find.

Criteria Finds Values Example


= with the exact match =11/29/1961

Lesson 10: Finding and Joining Data 193


LESSON 10
Criteria Finds Values Example
< less than <K
<= less than or equal to <=2500

al
> greater than >K
>= greater than or equal to >=2500
<> not equal to <>Michigan
Is Null that are empty

i
Between And within a range Between 5/1/2001 And 8/31/
2001

r
te
Removing a Filter
Click Remove Filter if you need to remove a filter before applying a new one. You can
check the bottom of a Datasheet view or Form view to see if you are looking at a filter
view.

a
y
ACTIVITY 10-1

op
Finding Data with Filters
eM
tC
Data Files:
• Join.mdb No
Scenario:
c
You have a couple of burning questions on your mind related to project management and sales
territories. You decide to use filters on your various database tables to get answers. First, in
tblBookProjects, you want to show the projects managed by Sarah Rubenstein (EN1-15). Next,
n

in tblCustomer, you want to show only those customers for salesperson Lauren MacKenzie
Do

(EN1-20). Finally, you’re considering redistricting the sales territories and want to see whether
or not adding the Canadian customers to Lauren’s sales territory would be too much.
e

What You Do How You Do It


se
r

1. In Join.mdb, apply a filter to a. Open Join.mdb.


tblBookProject to include only
fe

those projects managed by Sarah


b. Open tblBookProject in datasheet view.
ea

Rubenstein.

c. In the ProjectManager field, place the


insertion point on the first record that
Pl
Re

has a value of EN1-15.

d. Click the Filter By Selection button.

194 Microsoft® Office Access 2003 - Level 1


LESSON 10
2. How many records matched the filter?
a) 13
b) 14
c) 15

al
d) 20

3. Remove the filter and close the a. Click the Remove Filter button.
table.

i
b. Close the table, without saving the

r
changes.

te
4. Apply a filter to tblCustomer to a. Open tblCustomer.
include only those customers
assigned to salesperson Lauren
Mackenzie. b. To specify criteria for the datasheet, click
the Filter By Form button .

a
y
At the bottom of the window, notice the two
tabs, Look For and Or. The Look For tab is
selected.

op
eM
c. Place the insertion point in the Salesper-
son field and display the drop-down list.

tC
No
n c

d. Select en1-20.
Do

e. Click the Apply Filter button.


e

5. How many records matched this filter?


se
r

a) 3
b) 5
fe

c) 6
ea

d) 7

6. Apply a filter which includes those a. Click the Filter By Form button.
Pl
Re

customers assigned to Lauren


Mackenzie or those customers in
Canada. Then remove the filter b. Select the Or tab.
completely and close the table.

Lesson 10: Finding and Joining Data 195


LESSON 10
c. Display the Country drop-down list and
select Canada.

al
d. Click the Apply Filter button.

ri
The Remove Filter and Apply Filter buttons
function as one toggle button.

te
7. How many records match either salesperson en1-20 or have a country of Canada?
a) 6
b) 8

a
c) 10

y
d) 12

op
8.
eM
Remove the filter and close the
table.
a. Click the Remove Filter button to view
all 14 records again.

tC
b. Close the table, without saving the
changes.
No
c

ACTIVITY 10-2
n
Do

Finding Data with Advanced Filters


e

Data Files:
• Join.mdb
se
r

Setup:
fe

The Join.mdb database is open in Access.


ea

Scenario:
As President of the Book Source business, development costs are always an area of concern
Pl

for you. You decide to gather some historical data by combining criteria about costs and dates.
Re

You are working with tblBookProject and you want to find any projects whose development
costs were greater than $12,000 and whose product ship date was after January 1, 1999.

196 Microsoft® Office Access 2003 - Level 1


LESSON 10
What You Do How You Do It

1. In tblBookProject, use the Advanced a. Open tblBookProject.


Filter dialog box to set the criteria
for the development costs to
b. Choose Records→Filter→Advanced

al
greater than $12,000.
Filter/Sort.

c. Drag the DevelopmentCost field from


the tblBookProject field list to the first

i
Field cell in the filter grid.

r
d. In the Criteria cell for the
DevelopmentCost field, type >12000

te
2. Set the criteria for the ShipDate a. Drag the ShipDate field from the field
field to after Jan 1, 1999. Apply list to the next Field cell in the filter
your filter. grid.

a
y
b. In the Criteria cell for the ShipDate field,
type >1/1/1999

op
eM
c. Click the Apply Filter button.

tC
3. How many records match both criteria?
a) 2
b) 3
c) 4
No
d) 5
c
4. Remove all filters and close the a. Click the Remove filter button.
n

table.
Do

b. Close tblBookProject without saving the


changes.
e
se
r
fe
ea
Pl
Re

Lesson 10: Finding and Joining Data 197


LESSON 10
TOPIC B
Create Query Joins

al
You have worked with filters to eliminate from view the records that don’t match your criteria.
You can do something similar when two or more tables are related to each other to display the
desired data from each. In this topic, you’ll use query joins to accomplish this goal.

i
When you run a query to find records in related tables, by default, Access looks for records
that have matching values on both sides of the relationship. However, by knowing how to use

r
the different types of query joins, you can control the records that will be displayed as output.
This enables you to again find exactly the data you want—not more and not less.

te
Query Joins
A join is a temporary relationship you create between two tables in a query that do not already

a
have an established relationship or a common field with the same name and datatype. Tables

y
joined in a query are related only within that query and nowhere else. The type of join indi-
cates which records the query selects or performs an action on.

op
eM
Creating a query join will not establish a permanent relationship between the tables. Permanent relationships can
be created only in the Relationships window.

tC
Inner Join
Definition:
No
An inner join is a join that selects only those records from both tables that have
c
matching values. Records with values in the joined field that do not appear in both
tables will be excluded. One or more fields can serve as the join fields.
n

The inner join is alternately known as an equi-join.


Do
e

The inner join is the default join type in Access.


se
r
fe
ea
Pl
Re

198 Microsoft® Office Access 2003 - Level 1


LESSON 10
Example:

rial
a te
Figure 10-1: Conceptual diagram of an inner join between Projects data and

y
Employees data.

op
Analogy: eM
Consider a business that employs both managers and engineers—and some people who
are both. An inner join is like the union of this set: it selects the set of people who are
both managers and engineers and provides information about them in both roles.

tC
Outer Join No
Definition:
c
An outer join selects all the records from one table and only those records in the sec-
ond table that have matching values in the joined field. In a left outer join, the selected
records will include all records of the first table. In a right outer join, the selected
n

records will include all records of the second table. One or more fields can serve as
Do

the join fields.


e
se
r
fe
ea
Pl
Re

Lesson 10: Finding and Joining Data 199


LESSON 10
Example: Left Outer Join

rial
a te
Figure 10-2: Conceptual diagram of a left outer join between Projects data

y
and Employees data.

op
Analogy: eM
Consider again the business that employs both managers and engineers. A left outer
join selects the set of all managers, providing information about them, but in the case
of managers who are also engineers, it provides additional information about them.

tC
Example: Right Outer Join
No
n c
Do
e
se
r
fe
ea

Figure 10-3: Conceptual diagram of a right outer join between Projects data
and Employees data.
Pl
Re

Analogy:
Consider again the business that employs both managers and engineers. A right outer
join selects the set of all engineers, providing information about them, but in the case
of engineers and also managers, it provides additional information about them.

200 Microsoft® Office Access 2003 - Level 1


LESSON 10
How to Create Query Joins
Procedure Reference: Create a Join Line Between Tables in a Query Design
View

al
To create a join line between the tables in the query Design view:
1. Display the query in Design view.
2. Drag a field from one table to the matching field in the other table.

i
Procedure Reference: Change the Join Type

r
To change the join type of a query:

te
1. Display the query in Design View.
2. Click the Join Type button to display the Join Properties dialog box.
3. Click 2 or 3, depending on which table you want to show all the records for.
4. Click OK.

a
y
Cross-product Query

op
eM
Whenever you construct a query that involves two or more tables, you must tell
Access how to join the information in the tables. If you fail to do so, you will produce
a query results datasheet in which every record in table A is joined with every record
in table B. This is called a cross- or Cartesian product.

tC
Changing the Join Type
The Join Properties dialog box enables you to specify how two tables are to be joined
in a query. The three options describe which records you want the query to select.
No
Option 1 in the dialog box is the inner join. Options 2 and 3 represent outer joins.
c
Read the table names carefully when selecting these joins: if the join line was drawn
starting from the table on the left, the second option represents the left outer join and
the third option will represent a right outer join. (In a traditional database diagram, the
n

“one” or “primary” table is usually drawn to the left of the “many” or “secondary”
Do

table.) In this case, a left outer join includes all records from the table on the “left
side”, and the right outer join includes all records from the table on the “right side”.
e

Removing Joins in Queries


If you need to delete the join between tables in a query, right-click the join line
se

between them. From the shortcut menu, choose Delete (or, from the main menu,
r

choose Edit→Delete); or, in query Design view, select the join line and then press the
Delete key. Deleting a join line in a query affects only that query.
fe
ea

The broken join is effective only for the query in which you broke the join.
Pl
Re

Lesson 10: Finding and Joining Data 201


LESSON 10
ACTIVITY 10-3
Creating an Inner Join and an Outer Join

al
Data Files:
• Join.mdb

i
Setup:

r
The Join database window is maximized.

Scenario:

te
Suppose you’ve created a select query, qselBooks, that enables you to view what books have
been purchased from which customers. It uses the following tables: tblBookProject (29
records) and tblBookSales (100 records). However, the tables are not joined. What you want to
see is book information for books that have a sales record, and then for all books including

a
those that lack any sales records.

y
What You Do How You Do It

op
1.
eM
Run the existing query. a. Open qselBooks in design view and
observe its current structure.

tC
b. Run the query.

2. records are in the query results.


No
c
3. True or False? The reason this many records appear is because no join between the
tables has been established, so each record from tblBookProject is combined with each
record from tblBookSales.
True
n
Do

False
e
se
r
fe
ea
Pl
Re

202 Microsoft® Office Access 2003 - Level 1


LESSON 10
4. What fields should you use to join these tables?
a) Part# and OrderID
b) Part# and PartNumber
c) BookTitle and OrderID

al
d) BookTitle and PartNumber

ri
a te
y
op
eM
tC
No
5. Join the tables and then run the a. If necessary, change to Design view and
c
query again. drag Part# from the tblBookProject field
list to PartNumber in the tblBookSales
field list.
n
Do
e
se
r
fe
ea

You must drag in this direction to create the correct


join.
Pl
Re

b. Run the query.

Lesson 10: Finding and Joining Data 203


LESSON 10
6. Only books with sales are displayed. How many records for such books are in the
result?
a) 29
b) 90

al
c) 100
d) 2900

7. Change the join type to an outer a. Change to Design view and double-click

i
join so that the query will list all the the line that joins the two tables.
records from tblBookProject and only

r
the matching records from the joined
b. Select option 2. Click OK.
table, tblBookSales.

a te
y
op
eM
tC
c. Verify that the arrowhead points to the
table contributing only the matching
records. This is a left outer join.
No
n c
Do
e
se
r

d. Run the query.


fe
ea

8. All the records from tblBookProject are displayed. Only the matching records from
tblBookSales are displayed. How many results are displayed?
a) 29
Pl

b) 100
Re

c) 108
d) 2900

204 Microsoft® Office Access 2003 - Level 1


LESSON 10
9. Save and close the query. a. Save the query as qselMyOuterJoin

b. Close the query.

al
TOPIC C

ri
Join Unrelated Tables

te
You know how to retrieve data from multiple, related tables by using a query join. In this
topic, you will consider how to handle the case where two tables have the desired data, but are
only indirectly related to each other.

a
Consider the case where you have two tables with the data you need, but the tables are not

y
directly related to each other by a common field. To join such unrelated tables, you can often
include an additional table as a middle-man to create the link relationship. Doing so will

op
eM
enable you to retrieve exactly the data that you desire from multiple, unrelated tables.

How to Join Unrelated Tables

tC
Procedure Reference: Join Unrelated Tables by Adding a Table to a Query
Design
To join unrelated tables, you can add a table to the query design:
No
c
1. Open a query in Design View.
2. Click the Show Table button.
n

3. Select the table and click Add.


Do

4. If necessary, join the tables.


5. Complete your query design by adding the fields you want to display to the grid.
e

You can create more than one join between a pair of tables.
se
r
fe
ea
Pl
Re

Lesson 10: Finding and Joining Data 205


LESSON 10
ACTIVITY 10-4
Joining Two Unrelated Tables

al
Data Files:
• Join.mdb

i
Setup:

r
The Join database window is maximized.

Scenario:

te
You need a query that shows each book title listed with each customer that has ordered it. The
field Part# is in tblBookProject and the field CustomerName is in tblCustomer. However, the
tables tblBookProject and tblCustomer do not have any fields in common.

a
What You Do How You Do It

y
1. View the current design of a. In Design view, display the query

op
qselCustomerNames and add eM
tblBookSales to the query design
grid.
qselCustomerNames. The two tables do
not share a common field.

You must open the query in Design view; oth-

tC
Just as a bridge connects two places, the erwise, you will get an error message.
Book Sales table is like a bridge between
the tables whose data you want to use.
b. Click the Show Table button .
No
c
c. Select tblBookSales. Click Add. Click
Close.
n
Do
e
se
r
fe
ea

d. The tables are already related. Verify


Pl
Re

that the tables are automatically joined


together.

206 Microsoft® Office Access 2003 - Level 1


LESSON 10
2. Create the query by including a. From tblBookProject, drag BookTitle to
BookTitle and CustomerName in the the first Field cell.
design grid.
b. From tblCustomer, drag CustomerName
to the next Field cell.

al
3. Run qselCustomerNames. a. Run the query.

ri
a te
y
op
eMb. Verify that 100 records are displayed.
Save the updated query.

c. Close the query.

tC
4. True or False? Books that lack sales will not appear because this is an equi-join and not
a left-outer join.
True
No
False
n c
Do
e
se
r
fe
ea
Pl
Re

Lesson 10: Finding and Joining Data 207


LESSON 10
TOPIC D
Relate Data Within a Table

al
You have worked with a range of join types, from the default inner join to more complicated
outer joins. In some cases, however, the related data is all within a single table. In this topic,
you will use a special type of join that can be used to retrieve the desired data in this kind of
situation.

i
Consider the case where all the data you need is in a single table, but you need to be able to

r
relate columns in that table to each other to extract the desired records. For example, perhaps
an employee table has both an ID field for each record and also a field showing the ID of that

te
employee’s supervisor. To retrieve the desired data, you need to somehow relate the data to
itself. Fortunately, you can do this with a special kind of join designed for exactly this kind of
use.

a
Self Joins

y
Definition:

op
eM
A self join is a join that relates data in a table to itself. A table is joined to itself based
on a field or combination of fields that have duplicate data in different records. The
datatype of the inter-related columns must be the same.

tC
Example:
No
n c
Do
e
se
r
fe
ea

Figure 10-4: A self join that compares records within a table. The EmpID and
HireByID fields are the same datatype and contain the same data across differ-
Pl

ent records.
Re

208 Microsoft® Office Access 2003 - Level 1


LESSON 10
How to Relate Data Within a Table
Procedure Reference: Create a Self Join
To create a self-join:

al
1. Open a query in Design View.
2. Click the Show Table button.
3. Add the table to your query so that it appears twice.

i
4. Join the related fields.

r
5. Complete your query design by adding the fields you want to display to the grid.

te
Using an Alias
When you use the same table twice in a query, it is a good idea to change the name of
one of the tables. Assigning an alias to a table in the query does not rename the under-
lying table.

a
y
ACTIVITY 10-5

op
Creating a Self Join
eM
tC
Data Files:
• Join.mdb No
Setup:
c
The Join database window is maximized.

Scenario:
n

You need to design a query to display supervisor names for each employee. The tblSupervisors
Do

table contains information about employees and their supervisors. The supervisor is identified
according to his or her Employee ID number.
e
se
r
fe
ea
Pl
Re

Lesson 10: Finding and Joining Data 209


LESSON 10
What You Do How You Do It

1.

rial
te
In order to design a query to display supervisor names for each employee, which two
fields in tblSupervisors will need to be related?
a) Id and LastName
b) Id and SupervisorId

a
c) Dept and SupervisorId

y
d) LastName and SupervisorId

op
2.
eM
Add tblSupervisors to the query
design grid a second time.
a. In Design view, display qselSupervisors.

You must open the query in Design view; oth-

tC
erwise, you will get an error message.

b. Click the Show Table button.


No
c
c. Select tblSupervisors. Click Add.

d. Close the Show Table dialog box.


n
Do

You may want to make this second table list


wider in order to see its full title.
e

3. Assign an alias of Managers to the a. Right-click the tblSupervisors_1 field list


se
r

second table. to display the object menu. Choose


Properties.
fe
ea
Pl
Re

210 Microsoft® Office Access 2003 - Level 1


LESSON 10
b. In the Alias property box, type Managers
and press Enter.

rial
te
c. Close the Field List Properties dialog
box.

4. Create the self-join based on the a. Locate the SupervisorId field in the

a
SupervisorId field in the table and tblSupervisors field list.
the Id field in its copy.

y
b. Drag the SupervisorId field from the

op
eM tblSupervisors field list to the Id field of
the Managers table.

tC
No
n c
Do
e
se
r
fe
ea
Pl
Re

Lesson 10: Finding and Joining Data 211


LESSON 10
5. Add the FirstName and LastName a. From the tblSupervisors field list, add the
fields from the tblSupervisors field field FirstName to the first Field cell of
list and the LastName field from the the query design grid.
Managers field list.
b. From the tblSupervisors field list, add the

al
field LastName to the second Field cell
of the query design grid.

c. From the Managers field list, add

i
LastName to the third Field cell of the
query design grid.

r
a te
y
op
eM
tC
6. Change the caption property for the a. In the design grid, right-click the
LastName field in the Managers and LastName field from the Managers table.
tblSupervisors tables. Choose Properties.
No
b. Click in the Caption property box.
c
c. Type ManagerName
n
Do
e
se
r
fe
ea

d. Close the Field Properties dialog box.


Pl
Re

e. Set the caption property for the


LastName field from tblSupervisors to be
LastName.

212 Microsoft® Office Access 2003 - Level 1


LESSON 10
f. Run the query.

rial
a te
y
You might need to expand the column width to view

op
7. Save and close the query and the
eM the complete caption.

a. Save the query as qselMySelfJoin

tC
Join database.
b. Close the query.

c. Close the Join database.


No
n c
Do

Lesson 10 Follow-up
e

In this lesson, you focused on finding and displaying data using filters and queries. Being able
to filter data means that you can locate and work with the specific information that you’re
se

interested in at a particular time. By using query joins, you can obtain data from multiple
r

related tables or from related data in a single table. Doing so greatly expands the kind of data
reports you can create.
fe

1. You can use filters and query joins whenever you find yourself thinking, “I need to
ea

know,” or when you’re asking who, what, where, when, and how questions. What are
some of the questions you might ask in your day-to-day work that could be answered
by putting a filter to work or by joining tables for a query?
Pl
Re

2. Can you think of any scenarios with databases you will be using that would require
related data from multiple tables and, therefore, will likely benefit from a query join?

Lesson 10: Finding and Joining Data 213


NOTES

rial
a te
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re

214 Microsoft® Office Access 2003 - Level 1


LESSON 11

al
LESSON 11 Lesson Time
1 hour(s)

ri
Creating Flexible Queries

a te
Lesson Objectives:

y
op
eM
In this lesson, you will create flexible queries to display specified records; allow for user-
determined query criteria; and add, update, and delete data with queries.
You will:

tC
Set select query properties to show top and bottom values and show records that contain
unique values in selected fields.
• Create queries that accept criteria from the user on the fly.
• Create action queries that update, add, and delete multiple records in an underlying table.
No
n c
Do
e
se
r
fe
ea
Pl
Re

Lesson 11: Creating Flexible Queries 215


LESSON 11
Introduction
You’ve worked with simple queries, and you’ve retrieved related data from multiple tables
using query joins. Flexible queries can do even more than this, however, and in this lesson you
will see how to use queries to automatically return subsets of data, accept criteria from the

al
user at runtime, and modify the data in a table.
As a member of the Human Resources department, you have been asked to find the people in
your resume database that have networking or HTML skills. Instead of using two separate que-
ries, you can use the same flexible query twice by allowing for dynamic criteria. Once a

i
decision is made on who will be hired, an additional query could be used to automatically
update their records to reflect this change in status.

r
te
TOPIC A
Set Select Query Properties

a
y
At this point, you are familiar with the most common type of query, the select query. In this

op
eM
topic, you’ll use select query properties to display only the top or bottom values, select records
with unique values, and suppress records that contain duplicate information.
There are some types of select queries that you’ll find yourself creating again and again. For

tC
example, showing the top ten salespeople on your staff or the bottom five products in your
inventory. Or consider a case where you need to show the records that have a unique value for
a particular field, such as the books that have an author who hasn’t written any other titles. At
other times you’ll want to find records with non-unique values in a field, perhaps to help
No
remove duplicate entries. While select queries could be written manually to achieve all of these
results, you can save a lot of time and energy by using the built-in select query properties that
c
Access provides.
n

Select Query Properties


Do

Access provides properties you can set for a select query to restrict what records will be
shown.
e

Table 11-1: Select Query Properties


se
r

Property Description
Top Values A query property that enables the user to specify how many values to
fe

display in the datasheet. You can set its value as either a discrete num-
ea

ber of records to show (for example, 15) or as a percentage of the


records returned by the query (for example, 20%). To show top values
or bottom values, set values of either Ascending or Descending for the
Sort cell of the query design grid for that field.
Pl
Re

Unique Values A query property that when set to Yes will restrict the records returned
to those that have unique values in the fields in the query design grid.
Unique Records A query property that when set to Yes will restrict the records returned
to those that have unique values in all fields in the underlying tables or
queries. That is, the records in those tables are themselves unique.

216 Microsoft® Office Access 2003 - Level 1


LESSON 11
How to Set Select Query Properties
Procedure Reference: Show Top or Bottom Values
You can show top or bottom values in a query as follows:

al
1. Open a query in Design view.
2. Provide a value for the Top Values property box on the toolbar:
• Enter a number or a percent value. (The default value is All.)

i
• Select an option value.

r
Procedure Reference: Show Records that Contain Unique Values

te
To show records that contain unique values in selected fields:
1. Open a query in Design view.
2. Display the Query Properties dialog box.

a
3. Set the Unique Values property to Yes.

y
Procedure Reference: Show Unique Records Only

op
1.
2.
eM
To suppress records that contain duplicate information:
Open a query in Design view.
Display the Query Properties dialog box.

tC
3. Set the Unique Records property to Yes.

ACTIVITY 11-1
No
c
Showing Top Values
n
Do

Data Files:
• Flex.mdb
e

Setup:
se

Access is open and maximized.


r

Scenario:
fe

For an upcoming presentation you need a query that will display the top five book customers
ea

from your database, sorted by total sales.

What You Do How You Do It


Pl
Re

1. Set the qselBookSales query to dis- a. Open Flex.mdb.


play the customer name and the
total number of books sold to each
customer.

Lesson 11: Creating Flexible Queries 217


LESSON 11
b. Open qselBookSales in Design view.

rial
te
There are four field lists, so this query can display
information from four different tables.

c. From the tblBookSales field list, drag the

a
QuantitySold field to the first Field cell

y
in the design grid.

op
eM d. From the tblCustomer field list, drag the
CustomerName field to the second Field
cell in the design grid.

tC
No
n c

e. Click the Totals button to add the


Do

Total row to the design grid.


e

f. From the Total drop-down list in the


QuantitySold column, select Sum to add
these values in the datasheet.
se
r
fe
ea
Pl
Re

g. Run the query.

2. records are included in the query results.

218 Microsoft® Office Access 2003 - Level 1


LESSON 11
3. Display the records for only the top a. Switch to Design view and click the Top
five customers. Values drop-down arrow.

rial
b. Select 5.

te
Make sure you select 5, not 5%.

c. Run the query.

a
4. What order are the top five records displayed in?

y
a) By total sales, ascending

op
b) By total sales, descending
c) Alphabetical
d) No particular order
eM
tC
5. Sort the values by the sum of the a. Return to Design view.
quantity sold so that the top five in
quantity sold are displayed.
b. In the QuantitySold field column, choose
No
Descending as the sort value, and then
c
run the query.
n
Do
e
se
r

c. Save the query as qselMyTop5Values


fe
ea

d. Close the query.


Pl
Re

Lesson 11: Creating Flexible Queries 219


LESSON 11
ACTIVITY 11-2
Showing Records with Unique Values

al
Data Files:
• Flex.mdb

i
Setup:

r
The Flex database is open and the query objects are shown.

Scenario:

te
For your upcoming presentation, you also need a complete list of each book title ordered by
each customer. The number of times a title was ordered and the dates on which it was ordered
aren’t important; you only want to see one record for each customer and title combination.

a
What You Do How You Do It

y
1. Open a. Open qselCustomerNamesAndBooks.

op
eM
qselCustomerNamesAndBooks.
b. Examine the results and look for dupli-
cate combinations of customer and book
title.

tC
No
n c
Do
e

2. There are total records returned by this query.


se
r

3. There are records with a customer of Allendale Books and a book title of “Improving
Your Tennis Game.”
fe
ea

4. In the design of the query, remove a. Switch to Design view.


the TransactionDate field.
b. Place the insertion point in the
TransactionDate column.
Pl
Re

c. Choose Edit→Delete Columns.

220 Microsoft® Office Access 2003 - Level 1


LESSON 11
5. Set the query to display only unique a. Right-click the upper pane of the query
values. design.

b. Choose Properties.

al
c. Change the setting for the Unique Val-
ues property to Yes.

ri
a te
y
You can type “yes,” select Yes from the property’s
drop-down list, or select No and type “y.”

op
eMd. Close the Query Properties dialog box.

tC
e. Run the query.

6. There are now total records displayed by the query. No


7. There is now record with a customer of Allendale Books and a book title of “Improv-
c
ing Your Tennis Game.”

8. Save and close the query. a. Save the query as


n

qselMyCustomerNames
Do

b. Close the query.


e
se
r
fe
ea
Pl
Re

Lesson 11: Creating Flexible Queries 221


LESSON 11
TOPIC B
Create Parameter Queries

al
In the queries you’ve used so far, you’ve entered criteria in the query design grid to select a
group of records. In this topic, you will enable the user to input the criteria to be used by the
query.

i
You may find, in some cases, that it would be valuable if you could select a group of records
you choose on the fly, by supplying a criteria value for a field at runtime. For example, say

r
you regularly need to retrieve all records in a table for each U.S. state. You could create a
separate query for each of the fifty states, but a far better approach would be to create one

te
query that will ask the user for the state he is interested in. Doing so will save you a lot of
development time and let you create a leaner database.

Parameter Queries

a
y
Definition:
A parameter query is a flexible query that prompts the user for additional criteria. A

op
eM
message or command is placed in the criteria row beneath the applicable field, with
opening and closing brackets [ ] around it. When the query is run, this text appears as
a prompt, awaiting input from the query user. A parameter query can prompt for more

tC
than one criterion, with a separate dialog box displayed for each criterion.

Example: Single Parameter Query


No
n c
Do
e
se
r
fe
ea
Pl
Re

Figure 11-1: A parameter query that generates a prompt for the user to enter
a State criterion.

222 Microsoft® Office Access 2003 - Level 1


LESSON 11
Example: Multiple Parameter Query

rial
a te
y
op
eM
Figure 11-2: A parameter query that generates prompts for the user to enter

tC
City and State criteria.

The Like Operator and Wildcards No


You can use the Like operator with one or more wildcards to display query results from inex-
c
act criteria. The Like operator will search for records with a value in a field that follow the
pattern set by the wildcards used. (See Table 11-2.)
n

You can use wildcard characters in the Criteria cell for select queries or in response to parameter query prompts.
Do

Table 11-2: Common Wildcards


e

Character Description Example of Use


* Matches any number of characters Like “S*” would match Stone, Smith, and
se
r

but can only appear at the begin- Sullivan.


ning or the end of the string.
fe

? Matches any single alphabetic Like “B?nd” would match Band, Bind, and
ea

character and can appear in the Bend, amongst others.


middle of a string.
[] Matches any single character pro- Like “B[ai]nd” would match Band and Bind,
vided in the brackets. but not Bend.
Pl
Re

[! ] Matches any character not pro- Like “B[!a]nd” would match Bend and Bind,
vided in brackets. but not Band.
[-] Matches any single character from Like“B[a-d]nd” would match Band, Bbnd,
within the range provided in Bcnd, and Bdnd only.
brackets.

Lesson 11: Creating Flexible Queries 223


LESSON 11
Character Description Example of Use
# Matches any single numeric char- Like “9#7” would match 907, 917, 927, and
acter and can appear in the middle so on.
of a number.

al
Ampersand and Asterisk
You can use the ampersand (&) character along with the asterisk wildcard to link more

i
data to criteria specified by the user as part of a parameter query. For instance, to

r
prompt the user for an area code and to find all the telephone numbers listed for that
area code, you could use the following criterion: Like [Enter an Area Code]&*. The
ampersand links the area code from the user with the asterisk wildcard.

te
Between... And Operator
Another valid operator in a parameter query is the Between... And operator. To ask for
a range of values in a single cell, use the Between ... And operator with the bracketed

a
prompts (for example, Between [Start Date] and [End Date]).

y
How to Create Parameter Queries

op
eM
Procedure Reference: Create and Run a Parameter Query
To create and run a parameter query:

tC
1. Open a query in design view.
2. Click in the Criteria cell for the appropriate field(s), and type the desired expres-
sion within square brackets ([ ]).
No
c
When the query is run, Access displays this text to prompt the user for criteria. The text of the
prompt must be different from the field name, although it can include the field name.
n

3. Run the parameter query.


Do

4. When you are prompted to enter a parameter value, enter the value of the data
you want to view and click OK.
e

The Prompt Message


se

When you specify a prompt message, it should be brief but meaningful. Access can
r

display up to 50 or so characters in the prompt message. Do not type periods, commas,


exclamation points, or square brackets within the outer square brackets. The message
fe

cannot be the same as the field name.


ea

The Zoom Box


The Zoom dialog box enables you to type and view the entire expression. Use the
Pl
Re

Zoom dialog box when an expression is too long to be displayed completely in the
cell. Another way to display the Zoom dialog box is to right-click the cell and choose
Zoom from the shortcut menu.

224 Microsoft® Office Access 2003 - Level 1


LESSON 11
ACTIVITY 11-3
Creating a Single-parameter Query

al
Data Files:
• Flex.mdb

i
Setup:

r
The Flex database is open in Access and the query objects are displayed.

Scenario:

te
You often use the same query, qselCustomerOrder, but change it so that it is based on a spe-
cific customer name. This query uses the Flex database, which contains multiple tables to
display the fields CustomerName, BookTitle, and TransactionDate, and sorts the records by
customer name and transaction date. Rather than needing multiple queries, a better approach

a
would be to create a parameter query that prompts the user to specify which customer name to

y
use as a criterion.

op
What You Do

1. Run the existing qselCustomerOrder


query and open it in Design view.
eMHow You Do It

a. Open qselCustomerOrder to see its


results.

tC
b. Switch to design view.

2. a. In the Criteria cell for the CustomerName


Modify this query to have it prompt
No
for a customer name each time it field, type [Enter a Customer Name]
c
runs. Run the query using Book
World as the customer name.
n
Do
e
se
r

b. Run the query.


fe
ea
Pl
Re

Lesson 11: Creating Flexible Queries 225


LESSON 11
c. In the Enter Parameter Value dialog box,
type Book World

rial
d. Click OK.

a te
y
op
3.
eM
Run the query again; this time pro-
viding Jamison Books as the
a. Press Shift+F9 to run the query again.

tC
customer name.
b. In the Enter Parameter Value dialog box,
type Jamison Books

c. Click OK to view the results.


No
n c
Do
e
se
r

d. Save the query as qselMyCustomerOrder


fe
ea

e. Close the query.


Pl
Re

226 Microsoft® Office Access 2003 - Level 1


LESSON 11
ACTIVITY 11-4
Creating a Multiple Parameter Query

al
Data Files:
• Flex.mdb

i
Setup:

r
The Flex database is open with the query objects displayed.

Scenario:

te
While the parameter query you created is an improvement, you decide to add even more
flexibility. You want a query that will prompt for the first letter of the customer name and
prompt for the date of transaction (between two dates).

a
What You Do How You Do It

y
1. Set the query to prompt the user a. Open qselMyCustomerOrder in Design

op
for the first letter of the customer
name.
eM view.

b. Place the insertion point in the Criteria


cell of the CustomerName field.

tC
c. To display the Zoom dialog box, right-
click and choose Zoom.
No
c
d. Change the parameter criteria to read
Like [Enter the first letter of a Cus-
tomer Name]&*
n
Do
e
se
r
fe
ea

e. Click OK.
Pl
Re

Lesson 11: Creating Flexible Queries 227


LESSON 11
2. Set the query to prompt the user a. Click in the Criteria cell of the
for two transaction dates that the TransactionDate field.
resulting records must be between.
b. Display the Zoom dialog box.

al
c. Type Between [Enter a Start Date] and
[Enter an End Date]

d. Click OK.

ri
3. Run the query and display records a. Run the query.
for customers whose names begin

te
with the letter “b” who had trans-
actions dated between 4/1/2001 b. Type b and click OK.
and 6/30/2001.

a
y
op
eM
tC
Because the wildcard characters are added to the
parameter expression, you need to enter only the
first letter of the desired customer name.
No
c. To enter a start date, type 4/1/2001 and
click OK.
n c
Do
e
se
r

d. To enter an end date, type 6/30/2001


fe

and click OK.


ea
Pl
Re

228 Microsoft® Office Access 2003 - Level 1


LESSON 11
4. How many records satisfy the three criteria you set with parameters?
a) 10
b) 12
c) 15

al
d) 20

5. Save the query as a. Save the query as qselMyParameters


qselMyParameters and close the

i
query.
b. Close the query.

r
te
TOPIC C

a
y
Create Action Queries

op
eM
So far you’ve worked with select queries to create a view of data from one or more tables. But
queries can be used to change data, as well as to retrieve and display it. In this topic, you’ll
see how to use queries to update data, delete records, or add records from one table to another.

tC
Consider the case where a set of records in your products table needs to be altered to reflect a
10 percent increase in price. Rather than manually changing the price of each product record,
you can save a great deal of time by creating a query to automatically update the price values.
No
Or consider a case where you occasionally need to delete all of the records in a secondary
table that match a particular primary key. Again, rather than doing this manually, you can save
c
time by writing a query that locates the desired records and automatically deletes them.
n

Action Queries
Do

Definition:
e

An Action query is a query that modifies data in the underlying table or tables. It per-
forms a data operation, instead of selecting data. An action query can be an efficient
tool for making data modification in bulk.
se
r

Example: Update Query


fe

An Update query changes specified values in a table for all the records or for those
ea

records that match specified criteria.

It is generally a good idea to make a backup of your data before using update and delete action
Pl

queries.
Re

Lesson 11: Creating Flexible Queries 229


LESSON 11

rial
a te
y
op
Figure 11-3: An Update query that increases prices by five percent.

Example: Append Query


eM
An Append query copies data from specific fields or complete records from one table

tC
to another.

No
n c
Do
e
se
r
fe
ea
Pl

Figure 11-4: An Append query that copies matching records from


Re

tblProductsExternal to tblProducts.

You can use an append query even if some of the fields in the first table are not contained in the sec-
ond table, because Access appends values where the fields match and ignores the other fields.

230 Microsoft® Office Access 2003 - Level 1


LESSON 11
Example: Delete Query
A Delete query removes records from a table that match selected criteria.

rial
a te
y
op
eM
tC
Figure 11-5: A Delete query that deletes matching records in a table.

Make Table Query


A fourth kind of action query is quite different from the others. Instead of modifying
No
the data in an existing table, a Make Table query creates a new table from the results
c
of the query.

Action Query Icons


n

Each action query has a different icon to alert you that they will modify data. Simply
Do

opening an action query causes the query to be run, modifying the table data. Be care-
ful when working with action queries, always opening them in Design view to see
e

what they will do first!

How to Create Action Queries


se
r

Procedure Reference: Create an Action Query to Update Records


fe
ea

To create an action query that will update selected records:


1. Run a select query to determine that it will affect the desired records.
2. In Design view, click the drop-down arrow next to the Query Type button and
Pl
Re

select Update Query.


3. If necessary, modify the query so that the proper fields will be updated with the
desired new data.
4. Click the Run button to run the query.

Lesson 11: Creating Flexible Queries 231


LESSON 11
To run an action query, use the Run button rather than the View button. Use View to see a list of
all records that will be updated, but not their new values. Using Run will update the values.

5. When a dialog box appears indicating the number of records that will be affected,

al
click Yes.
6. If desired, save this query.

Add All Fields to the Query

i
To add all of the fields from a table to the query design grid, drag the asterisk from the
field list to the field row of the query design grid. This procedure ensures that if you

r
add or delete fields from a table, the query using that table still includes all of the
fields.

te
When you use the asterisk to add all the fields to the query design grid, and you want
to sort values or specify criteria, you must first add the individual fields to the field
row; and then you can define specifications for those fields. To prevent the fields from
appearing twice in the query results, uncheck the Show check box for each.

a
y
ACTIVITY 11-5

op
Updating Records with a Query
eM
tC
Data Files:
• Flex.mdb

Setup:
No
c
The Flex database is open and the query objects are displayed.

Scenario:
n

You’ve just gotten word that all projects beginning with 31 or 34 will have a price increase of
Do

five percent. You’ve decided to use an update query to change relevant records in
tblBookProject. You have an existing query, qselRetailPrice, that you can modify to accomplish
this goal.
e

What You Do How You Do It


se
r

1. As a precaution, create a copy of a. In the database window, display the table


fe

tblBookProject before the data is objects.


modified.
ea

b. Select the table tblBookProject.


Pl

c. Click the Copy button .


Re

d. Click the Paste button .

232 Microsoft® Office Access 2003 - Level 1


LESSON 11
e. In the Table Name text box, type
tblMyBackupBookProject

rial
te
f. Click OK. The copied table has been
added to the database.

g. Open your original table,

a
tblBookProject.

y
op
2.
from $25.95 to $45.95.
True
False
eM
True or False? For books with part numbers that begin with 31 or 34, the prices range

tC
3. View the design of the provided a. Close tblBookProject.
select query called qselRetailPrice.
Run the query to see its results.
b. In the database window, display the
No
query objects.
c
Action queries are very fast and their
results are permanent, so you’ll want to
test an action query first, as a select c. Display qselRetailPrice in Design view.
n

query, to see how your data will change


Do

before you actually make the change.


e
se
r
fe
ea

d. Verify that the criteria for PartNumber


is Like “31*” Or Like “34*” and that
Pl
Re

there is a calculated field named


NewBookPrice, which is defined to calcu-
late a five percent increase in the book
price. Run the query.

4. There are records that have a part number that begins with either 31 or 34.

Lesson 11: Creating Flexible Queries 233


LESSON 11
5. Running the select query does not a. Change to Design view and click the
change the prices in the table. Con- drop-down arrow next to the Query
vert this select query to an update Type button .
query that will change the data.

b. Select Update Query.

rial
te
c. Verify that the title of the query has
changed to Update Query and that an

a
Update To row was added to the grid.

y
d. In the BookPrice column, in the Update To

op
6.
eM
Run the update query, save the
cell, type [BookPrice]*1.05 and press
Enter.

a. Click the Run button .

tC
query, and view the results.

b. A dialog box indicates the number of


records that will be changed. Click Yes.
No
n c
Do
e

c. Save the query as qupdMyPriceIncrease


se
r

The object prefix “qupd” indicates that it is


now an update query.
fe
ea

d. Close the query.

e. Open tblBookProject.
Pl
Re

7. What is the new range of prices for books with part numbers beginning with 31 or 34?
a) $25.95 to $45.95
b) $27.25 to $48.25
c) $30 to $50

234 Microsoft® Office Access 2003 - Level 1


LESSON 11
8. What would happen to the values in the BookPrice field if you ran the query again?
a) Nothing, they would remain the same because they have already been increased by 5
percent.
b) The values in the BookPrice field in the underlying table would again be increased by
5 percent.

al
c) The previous prices would be reinstated: the 5 percent increase in price would be
revoked.
d) An error would result.

i
9. Verify the icon used to denote an a. Close tblBookProject.

r
update query.
b. In the Flex database window, verify that

te
the icon for
qupdMyPriceIncrease is different than
that used for select queries by display-
ing the query objects.

a
y
op
eM
Procedure Reference: Create an Action Query to Append Records
To create an action query that will append records:
1. If desired, run a select query to determine the records that will be appended.

tC
2. In Design view, click the drop-down arrow next to the Query Type button and
select Append Query.
3. In the Append dialog box, select the table you are appending records to. Click
OK.
No
c
4. If necessary, modify the query further so that the proper fields will be appended
with the desired new data.
n

5. Click the Run button to run the query.


Do

6. When a dialog box appears indicating the number of records that will be
appended, click Yes.
e

7. If desired, save this query.


se
r
fe
ea
Pl
Re

Lesson 11: Creating Flexible Queries 235


LESSON 11
ACTIVITY 11-6
Appending Records to a Table with a Query

al
Data Files:
• Flex.mdb

i
Setup:

r
The Flex database is open and the database window displays the query objects.

Scenario:

te
The tblNewProjects table contains information regarding new book projects. The table structure
is identical to tblBookProject. In both tables, the first two digits of the part number for each
book represents a category of books. For instance, category 41 is devoted to books on model
airplanes and category 43 is comprised of books about mountain biking. The category 41

a
projects are now complete, and you need to add those records from tblNewProjects to

y
tblBookProject.

op
What You Do

1. Review the contents of


tblNewProjects.
eM How You Do It

a. Open tblNewProjects.

tC
b. Verify that the table has seven records,
four with a part number beginning with
41 and three with a part number begin-
ning with 43. Close the table.
No
c
2. Create a select query that shows all a. With tblNewProjects selected in the data-
fields for all records from base window, display the New Object
tblNewProjects. drop-down list .
n
Do

b. Select Query.
e

c. Verify that Design View is selected. Click


OK.
se
r

d. From the tblNewProjects field list, drag


the asterisk to the first Field cell in the
fe

query design grid.


ea
Pl
Re

236 Microsoft® Office Access 2003 - Level 1


LESSON 11
3. Use criterion for the PartNumber a. In the second Field cell, display the drop-
field to find records with part num- down list and select PartNumber.
bers that begin with 41. Avoid
displaying the PartNumber field
b. In the Criteria cell for the PartNumber
twice in the query datasheet.
field, type 41* and press Enter.

al
The Like operator and quotation marks are
added automatically.

i
c. The PartNumber field is set to be dis-

r
played as part of the entire table (based
on the first Field cell). Above the criteria
for the PartNumber column, uncheck the

te
Show check box.

a
y
op
eM
d. Run the query.

tC
4. records are displayed by this query.

5. Change the select query to an


No
a. Change to Design view and display the
c
append query that will add this data Query Type drop-down list.
to tblBookProject.
b. Select Append Query.
n
Do

c. In the Append dialog box, from the Table


Name drop-down list, select
e

tblBookProject. Click OK.


se
r
fe
ea
Pl
Re

d. Verify that the query design window


title is now Append Query and that the
grid now includes an Append To row.

Lesson 11: Creating Flexible Queries 237


LESSON 11
e. In the Append To cell for the PartNumber
field, delete PartNumber, but do not
delete the Like “41*” criterion below it.

rial
The PartNumber field was included in the second

te
Field cell of the query design grid to supply a crite-
rion for the query. It was also included when the
asterisk was dragged to the first Field cell.

a
6. Run the append query, save it, and a. Click the Run button.
view the results.

y
b. The warning dialog box indicates the num-

op
eM
Access does not automatically refresh the
view of the table that has records added
to it.
ber of records that will be appended.
Click Yes.

tC
No
c
c. The object prefix “qapp” is used to indi-
cate an append query. Save the query as
n

qappMyAppend
Do

Append queries are often not used again; in


e

that case, once you have confirmed the results,


you can delete the query.
se
r

d. Open tblBookProject.
fe

7. The tblBookProject table had 26 records before the append query was run. How many
ea

records does it have now?


a) 26
b) 29
Pl
Re

c) 30
d) 33

238 Microsoft® Office Access 2003 - Level 1


LESSON 11
8. Verify that the contents of a. Close tblBookProject.
tblNewProjects are unchanged.
b. Open tblNewProjects.

al
c. Verify that running the append query
did not delete any records. Close
tblNewProjects.

ri
Procedure Reference: Create an Action Query to Delete Records
To create an action query that will delete records:

te
1. If desired, run a select query to determine the records that will be deleted.
2. In Design view, click the drop-down arrow next to the Query Type button and
select Delete Query.

a
3. If necessary, modify the query further so that the proper fields will be deleted

y
with the desired new data.

op
Click the Run button to run the query.
4.
5.
eM
When a dialog box appears indicating the number of records that will be deleted,
click Yes.

tC
6. If desired, save this query.

ACTIVITY 11-7 No
c
Deleting Records with a Query
n

Data Files:
Do

• Flex.mdb
e

Setup:
The query qappMyAppend is open in Design view.
se
r

Scenario:
Projects in category 41 are no longer considered new. They are complete and have been added
fe

to tblBookProject. You now want to remove these records from tblNewProjects.


ea
Pl
Re

Lesson 11: Creating Flexible Queries 239


LESSON 11
What You Do How You Do It

1. Change qappMyAppend to a delete a. Display the Query Type drop-down list.


query and preview the records that
will be deleted.
b. Select Delete Query.

al
The Delete Query choice is on the extended
menu.

i
c. In the design grid, verify that the Delete

r
row indicates that only records with a
PartNumber value that starts with 41

te
will be deleted from tblNewProjects.

a
y
op
eM d. To verify that only the four records where
part number begins with 41 will be

tC
deleted, click the View button.

2. Run the query and delete the four a. Change to Design view and click the Run
records. button.
No
n c
Do
e

The deletion is permanent; you cannot retrieve


deleted records by using the Undo feature.
se
r

b. Click Yes to delete the records.


fe
ea
Pl
Re

240 Microsoft® Office Access 2003 - Level 1


LESSON 11
3. Save the query and verify that the a. An object prefix of qdel is used to indi-
records were deleted. cate a delete query. Save the query as
qdelMyNewProjects

b. Close the query.

al
c. To verify that the deletion occurred and
that three records remain, open
tblNewProjects.

i
d. Close tblNewProjects.

r
te
e. Close the Flex database.

a
y
Lesson 11 Follow-up

op
eM
In this lesson, you used select query properties that let you quickly accomplish common tasks
such as showing the top values or showing unique values. You saw that typical select queries
are quite limited because they are static, but that by using a flexible parameter query you can
allow for the dynamic entry of one or multiple criteria. By using another type of advanced

tC
query, the action query, you were able to automatically add, update, and delete records in a
table. All of these query types have expanded your ability to work with data in flexible and
powerful ways.
1.
No
Considering your current or planned Access projects, can you foresee needing to cre-
ate parameter queries? In what contexts and why?
c
2. Considering your current or planned Access projects, can you foresee needing to cre-
n

ate action queries that add, update, or delete data? In what contexts and why?
Do
e
se
r
fe
ea
Pl
Re

Lesson 11: Creating Flexible Queries 241


NOTES

rial
a te
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re

242 Microsoft® Office Access 2003 - Level 1


LESSON 12

al
LESSON 12 Lesson Time
40 minutes

ri
Improving Your Forms

a te
Lesson Objectives:

y
op
forms.
You will:
eM
In this lesson, you will enhance the appearance, data entry, and data access capabilities of your

tC
Add text and graphic elements including lines, rectangles, and pictures to a form.
• Restrict data entry in forms by adding Combo Box and Option Group controls.
• Add a command button to a form.
• Add a subform to a form.
No
n c
Do
e
se
r
fe
ea
Pl
Re

Lesson 12: Improving Your Forms 243


LESSON 12
Introduction
If you’re lucky, you might never need to customize a form. The forms you create with
AutoForm or the Form Wizard might work perfectly for you, but chances are you’ll end up in
the Form Design view window to improve your forms at some point. This lesson will provide

al
an opportunity to try your hand at many form design tasks.
Database users will work more efficiently if given attractive and functional data-entry forms.
You can improve your forms by adding headings, graphics, boxes, and controls. You can also
enable related data from multiple tables to be edited in a single form window, allowing users

i
to more efficiently add and update records.

r
te
TOPIC A
Enhance the Appearance of a Form

a
y
You’ve created your own forms, but if you used the AutoForm feature of a Form Wizard, your
forms will more than likely look a little bland. You may have tinkered with them a bit in Form

op
appearance.
eM
Design view already, but in this topic, you will add text and graphics to really improve their

Although unnecessary distraction should be avoided, an entirely plain form might not be the

tC
most effective tool to provide users of your database. By adding lines, boxes, additional text,
and graphics to your forms, you can improve their appearance and make it easier for users to
enter and manipulate information. See Figure 12-1.
No
n c
Do
e
se
r
fe
ea
Pl
Re

Figure 12-1: A form with a heading, graphic, and shaded rectangle grouping box.

244 Microsoft® Office Access 2003 - Level 1


LESSON 12
Form Design View
The Form Design view window (see Figure 12-2) is the design environment for making
changes to a form’s design. It provides numerous tools to help you improve the design of your
forms and increase the efficiency of data entry.

al
There are additional toolbars and features of Form Design view not discussed in this course. These are the most
commonly used.

ri
Tool Description
Form Design toolbar Provides buttons for common tasks like View, Save, and Print. It also

te
has special buttons to open Design tools like the Toolbox and Field
list.
Formatting toolbar Has buttons for typical formatting jobs, like changing font sizes and
colors.
Toolbox Has buttons for placing labels, fields, combo boxes, command but-

a
tons, and other special-purpose objects in a form. This is where you

y
typically go to find controls to add to your form.

op
Field list A handy way to reference fields in the Design view window. Shows

Properties dialog box


you are working on.
eM
fields from the table or query that is the source of data for the form

Each object in a Form Design view window has its own properties

tC
dialog box with tabs that list the properties you can change for the
object.
Control Wizards toggle button Often when you click a button in the Toolbox to place an object on
the form design, you get some help from one of the Access wizards.
No
n c
Do
e
se
r
fe
ea
Pl
Re

Lesson 12: Improving Your Forms 245


LESSON 12

rial
a te
y
op
eM
Figure 12-2: The Form Design view window.

tC
Formatting Palettes
A formatting palette can be used to enhance forms and reports with color or other
effects from a predetermined set of options. The Formatting toolbar includes several
buttons that offer palettes. See Table 12-1.
No
c
Table 12-1: Buttons on the Formatting Toolbar that Display a Palette
Button Name Description
n
Do

Fill/Back Color Changes the background color of a control or


section.
e

Font/Fore Color Changes the color of text in a control.

Line/Border Color Changes the color of a control’s border.


se
r

Line/Border Width Changes the thickness of a control’s border.


fe
ea

Special Effect Controls whether a control or section appears


flat, raised, sunken, etched, shadowed, or
chiseled.
Pl
Re

There are a couple of things to keep in mind when working with any of these buttons:
• The palette closes after you make a selection.
• For the color-related tools, the colored box on the button displays the most recent
color you selected from the palette. You don’t need to use the drop-down palette
to select the same color.

246 Microsoft® Office Access 2003 - Level 1


LESSON 12
• To avoid clicking the Palette toolbar button each time you need to display a given
palette, you can drag that palette away from the button to keep it displayed while
you design the form or report.

Unbound Controls

al
An unbound control is not bound or connected to a field or an expression. They can
display informative text (such as in a label), a rectangle, a line, a command button, or
a picture such as a company logo, which might be stored in a bitmap file, separate
from any tables.

i
Section Selector

r
There might be times when you need to select an entire section of a form or report—
for example, the Header, Footer, or Detail sections. To select a specific section of the

te
form or report, use the section selector—a box in the left of the section bar in Form or
Report Design view. After you select a section, you can display the properties dialog
box for that section.

a
You can also display the properties for that section automatically by double-clicking its section selector
box.

y
op
Grouped Controls eM
Grouped controls are two or more controls that can be treated as one unit while
designing a form or report. You can select the group instead of selecting each indi-
vidual control as you’re arranging controls or assigning properties. You can group text

tC
boxes and other controls on a form or report by using the Group command on the For-
mat menu. When you carry out that command, a black box appears around all of the
selected objects. This is now considered a group for the purposes of moving them
around the layout window and applying properties such as text font color.
No
c
To select multiple adjacent controls, place the mouse pointer on the vertical or horizontal ruler and
when the mouse pointer changes shape to a horizontal or vertical arrow, click the mouse button. This
method selects all the controls that have been placed in the same horizontal or vertical position.
n
Do

How to Enhance the Appearance of a Form


e

Procedure Reference: Work with Lines, Boxes, and Labels


se

To work with lines, boxes, and labels, as you design forms with a variety of features:
r

1. From the toolbox, select the tool you would like to work with.
fe

2. Click in the Design view window where you want the object (line, box, and so
ea

on) to start.
3. Depending on the object, drag to the end or the other opposite corner and release
the mouse button.
Pl
Re

4. If desired, apply special effects to the control.

Procedure Reference: Add an Image


To add an image to a form in Design view:
1. From the toolbox, choose the Image tool.

Lesson 12: Improving Your Forms 247


LESSON 12
2. Click in the form where you want the image displayed.
3. Browse to the desired file’s location, select it, and click OK.
4. Double-click the image to display its properties.

al
5. Alter any properties as needed and then close the properties dialog box.
6. If necessary, resize and relocate the image on the form.

ACTIVITY 12-1

ri
Adding Text and Graphic Elements

te
Data Files:
• Improve.mdb

a
Setup:

y
Access is open.

op
Scenario: eM
You’ve started a form, frmSalesAndProfit, that could be used for order entry at the Book
Source. You’ve identified some basic improvements you could make to polish up the form.

tC
You will:
• Group together four controls so that they are easier to work with.
• Surround several of the remaining controls with a rectangle to enhance the visual
design of a form.
No
• Add a label, Book Source Sales, and an image to the top of the form.
c
What You Do How You Do It
n
Do

1. In the Improve database, open a. Open the Improve database. Maximize


frmSalesAndProfit in Design view. the database.
This form is based on a multiple-
e

table query.
b. Open frmSalesAndProfit, and then
switch to Design view.
se
r
fe
ea
Pl
Re

248 Microsoft® Office Access 2003 - Level 1


LESSON 12
2. Create a group of the first set of a. Hold down the Shift key and select the
three controls. Change the font of OrderID, CustomerID, and
the entire group of controls. Then TransactionDate label controls.
ungroup the controls.

rial
b. Choose Format→Group.

te
c. Deselect the group by clicking in any
open gray space. There is no indication
that this set of controls is considered a
group; it has no visible boundary.

a
d. Click the OrderID label control to select

y
the group.

op
eM
tC
Any of the controls could be clicked to select the
No
group.
c
e. You can still work with each control
individually. Click the OrderID label con-
n

trol again. Press Delete. The group still


Do

exists without this deleted control.


e

f. Click Undo .
se
r

g. Place the mouse pointer on the group


boundary. When the mouse pointer
changes to a hand, drag to the right. This
fe

moves the group of controls as a single


ea

unit.

h. Click Undo.
Pl
Re

i. With the group still selected, select a red


font color .

If the Formatting toolbar is not displayed,


choose View→Toolbars→Formatting (Form/
Report).

Lesson 12: Improving Your Forms 249


LESSON 12
j. Choose Format→Ungroup. When you
ungroup controls, the group rectangle is
deleted.

3. Draw a rectangle around the a. Make sure you can see the QuantitySold,

al
QuantitySold, Retail Cost, and Retail Cost, and Wholesale Cost controls.
Wholesale Cost labels and text If necessary, resize the form window.
boxes.
b. From the Toolbox, choose the Rectangle

i
tool .

r
c. Click above and to the left of the
QuantitySold label. Drag the mouse

te
pointer to surround the three controls
that display calculated data and release.

a
y
op
4.
eM
Format the rectangle with color and a. On the Formatting toolbar, next to the

tC
a shadowed effect. Special Effect button, click the drop-
down arrow to display the special effects
options for the rectangle control.
No
n c
Do

b. Select Special Effect: Shadowed. The


e

rectangle control changes its appearance


and remains selected.
se
r

c. On the Formatting toolbar, next to the


Line/Border Color button , click the
fe

drop-down arrow.
ea

d. From the palette, select a red color.


Pl

You may choose a different color if you wish.


Re

5. Make room to add a label and pic- a. The Form Header is currently hidden. To
ture control to the Form Header view it, choose View→Form Header/
section. Footer.

250 Microsoft® Office Access 2003 - Level 1


LESSON 12
b. Double-click the Form Header section
selector to display the properties for the
Form Header section.

rial
c. If necessary, select the Format tab.

te
Instead of changing the value in the properties
dialog box, you could drag the Detail section
bar down to the 2” mark on the vertical ruler.

a
d. Change the Height setting to 2”

y
e. Close the properties dialog box.

op
6. In the upper-left corner of the Form
Header section, create a label that
reads Book Source Sales.
eM
a. Choose the Label tool .

tC
b. Click the mouse pointer in the upper-
left corner of the Form Header section.
No
n c
Do
e

c. Type Book Source Sales and press Enter.

d. From the Font Size drop-down list, select


se
r

20.
fe

e. Choose Format→Size→To Fit.


ea

7. Insert the Book file image and size a. Choose the Image tool .
it so that it is smaller.
Pl
Re

Lesson 12: Improving Your Forms 251


LESSON 12
b. In the Form Header section, click near
the 3” horizontal mark at the top of the
section.

rial
c. The contents of the My Documents folder

te
are displayed. From the list of files,
select Books.

d. Click OK.

a
y
You can change the object’s position by drag-
ging it or by using Ctrl+arrow keys.

op
eM e. Double-click the image to display its
properties.

tC
f. If necessary, select the Format tab.

g. Set the Size Mode property to Stretch.


No
c
h. Close the properties dialog box.

i. Place the mouse pointer on the lower-


n

right corner of the image until it turns


Do

into a double-ended arrow and drag up


and to the left to make the graphic
e

smaller.

j. Drag the top border of the Detail section


se
r

up under the graphic.


fe
ea
Pl
Re

252 Microsoft® Office Access 2003 - Level 1


LESSON 12
8. Hide the Form Footer section. a. Double-click the Form Footer section
selector to display the properties for the
Form Footer section.

b. Change the Visible property to No.

al
c. Close the properties dialog box.

9. Save the modified form as a. Save the form as frmMySalesAndProfit

i
frmMySalesAndProfit.

r
b. Switch to Form view.

a te
y
op
eM
tC
No
c

TOPIC B
n
Do

Restrict Data Entry in Forms


e

You’ve seen how to improve the appearance of your forms by adding text and graphic
se
r

elements. But even more important than appearance is how well your forms can produce accu-
rate data in your tables. In this topic, you will use special kinds of controls to restrict data
fe

entry.
ea

In some cases, users of a form need the freedom to enter any value they desire in a text box
(for example, a name field). However, in other instances you can drastically reduce data-entry
errors by restricting the possible values that can be entered by using a set of buttons or other
Pl
Re

such control. Doing so can also greatly increase the efficiency of users of the form, since they
are being presented with a simple choice of preset options and do not need to remember the
set of valid values they can enter.

Lesson 12: Improving Your Forms 253


LESSON 12
Control Wizards
When adding certain types of controls to a form, you can use a wizard to create the control.
Collectively, this group of wizards is referred to as Control Wizards. To toggle Control Wizards
on and off, click the Control Wizards button in the Toolbox.

al
You can use the Control Wizards to create any of these controls: a list box, combo box, option group, command
button, chart, subreport, and subform.

i
Combo Box Control

r
Definition:

te
A Combo Box control is a form control that provides a combination of a text box to
which a drop-down list of choices is attached. You can type in a value or choose from
the list. The list is displayed only when you click the drop-down arrow. Combo boxes
can display more than one column of values, but only one column will provide the
value to be stored for that field. A combo box is typically accompanied by a label

a
control.

y
op
Example:
eM
tC
No
n c
Do
e
se
r
fe
ea

Figure 12-3: A combo box that can be used to assign a product category for
each product record.

List Box Control


Pl
Re

Definition:
A List Box control is a form control that displays a list of values to choose from. It is
similar to a combo box, but it does not allow direct typing of values and it can display
multiple rows. A list box is typically accompanied by a label control.

254 Microsoft® Office Access 2003 - Level 1


LESSON 12
Example:

rial
a te
y
op
eM
Figure 12-4: A list box that can be used to assign a product category for each
product record.

tC
Option Group Control No
Definition:
c
An option box group is a type of form control that consists of a group frame contain-
ing option buttons, check boxes, or toggle buttons. You can select only one element in
the option group; therefore, you should use an option group when only one choice is
n

possible within the group. To simplify data entry, one option can be set as the default.
Do

A label for the option group is typically provided.


e

Although you can place check boxes in the group, it is usually better to use option buttons or toggle
buttons. Windows users have come to expect that, with square boxes, they can choose more than one
option, and that with option buttons they can choose only one.
se
r
fe
ea
Pl
Re

Lesson 12: Improving Your Forms 255


LESSON 12
Example:

rial
a te
Figure 12-5: An option group can be used to restrict the possible values for

y
the Reason field in a table for employee time off.

op
eM
How to Restrict Data Entry in Forms
Procedure Reference: Add a Combo Box or List Box Control

tC
To add a Combo Box or List Box control based on a table or query to a form in
Design view:
1. If necessary, activate the Control Wizards button.
No
2. In the toolbox, click the Combo Box (or List Box) button.
c
3. Click in the form to place the control in the desired location.
4. Select the I Want The Combo Box To Look Up The Values In A Table Or Query
n

option. Click Next.


Do

5. Choose the table or query that will provide the values. Click Next.
e

6. Choose the field(s) to display in the control. Click Next.


7. Set any desired sort criteria for the items in the control. Click Next.
se
r

8. If desired, uncheck Hide Key Column.


9. If necessary, double-click column borders for best fit. Click Next.
fe
ea

10. Choose a field to uniquely identify the row in the control and to provide the value
that will be stored in the table. Click Next.
11. Choose whether or not to store the values in the field and specify a field, and then
Pl

click Next.
Re

12. Accept the suggested label name or enter a name for the Combo Box and then
click Finish.

256 Microsoft® Office Access 2003 - Level 1


LESSON 12
ACTIVITY 12-2
Adding a Combo Box Control

al
Data Files:
• Improve.mdb

i
Setup:

r
The frmMySalesAndProfit form is open in Form view.

Scenario:

te
You continue to work with frmMySalesAndProfit and decide to add some choices to simplify
data entry. To begin, you’ll add a Combo Box that displays the part numbers and book titles
for each record, and records the part number field.

a
What You Do How You Do It

y
1. Delete the existing PartNumber a. Switch to Design view.

op
text box and label controls. eM
b. Delete the PartNumber text box and
label controls.

tC
No
c
2. Start the Combo Box Wizard. a. In the Toolbox, verify that the Control
Wizards button is selected. It
appears a different color when selected.
n
Do

b. Choose the Combo Box tool .


e

c. On the form, click below the


TransactionDate controls to start the
se

Combo Box Wizard.


r
fe
ea
Pl
Re

Lesson 12: Improving Your Forms 257


LESSON 12
3. Using the wizard, select two fields in a. Verify that the I Want The Combo Box
tblBookProject that will be dis- To Look Up The Values In A Table Or
played as columns in the combo Query option is selected. Click Next.
box: PartNumber and BookTitle.

rial
a te
b. In the lower part of the dialog box, verify

y
that the selected View option is Tables.

op
eM c. In the upper part of the dialog box, from
the list of tables select tblBookProject.
Click Next.

tC
d. With PartNumber selected in the Available
Fields list box, click the right arrow but-
ton
No .

e. Move the BookTitle field from the Avail-


c
able Fields list box to the Selected
Fields list box. Click Next.
n
Do
e
se
r
fe
ea
Pl
Re

258 Microsoft® Office Access 2003 - Level 1


LESSON 12
4. Sort the items in the Combo Box by a. In the first drop-down menu, choose
part number. PartNumber.

b. Verify that the corresponding button is


set to Ascending. Click Next.

rial
a te
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re

Lesson 12: Improving Your Forms 259


LESSON 12
5. Ensure that both columns will dis- a. Uncheck Hide Key Column.
play in the combo box and adjust
the column widths.
Although the wizard recommends that you hide
the key column, for this example, you want to
display it in the combo box with the book title.

al
b. To make the best fit for the column,
double-click the right edge of the
BookTitle column.

ri
a te
y
op
eM
tC
c. Double-click the right edge of the
PartNumber column. Click Next.

d. In the Available Fields list box, verify that


No
PartNumber is selected. Click Next.
c
This field uniquely identifies the row in the
combo box, and it contains the value you want
n

to store or use in the database.


Do

6. Specify that Access should store the a. Select Store That Value In This Field.
e

combo box value in the PartNumber


field and complete the wizard.
b. From the drop-down list, select
se

PartNumber.
r
fe
ea
Pl
Re

c. Click Next.

260 Microsoft® Office Access 2003 - Level 1


LESSON 12
d. Accept the suggested label and Click
Finish.

rial
7. Display and scroll through the val- a. Change to Form view.
ues listed in the new combo box.

te
b. Click the combo box drop-down arrow.

a
y
op
eM
tC
c. Close the combo box list.

d. Save the modified form.


No
n c
Do
e
se
r
fe
ea
Pl
Re

Lesson 12: Improving Your Forms 261


LESSON 12
8. To see the difference, temporarily a. In Design view, right-click the Combo Box
convert the combo box to a list control.
box.
b. Choose Change To→List Box.

al
c. In Form view, scroll through the list box.

ri
te
d. Change to Design view and click Undo.

a
To use this List Box control effectively, addi-

y
tional design changes would be needed so that
it does not overlap the Text Box controls below

op
eM it.

e. Close frmMySalesAndProfit.

tC
If you are asked to save changes again, click
No.
No
c
Procedure Reference: Create an Option Group
n

To add an option group to a form in Design view:


Do

1. If necessary, activate the Control Wizards button.


e

2. In the Toolbox, click the Option Group button.


3. Click in the form where you want the option group created.
se
r

4. Enter the labels for the options you want to show on the form and click Next.
fe

A label is the text that describes the purpose of each option.


ea

5. From the drop-down list, select a default value for the field and click Next.
Pl

A default choice is not required for option buttons, but Windows users have come to expect that
Re

with this type of control, a default option will already be selected.

6. Accept the default values that will be used for each option or change them to suit
your needs and click Next.
7. Specify whether the value is saved for later use or stored in a selected field and
click Next.

262 Microsoft® Office Access 2003 - Level 1


LESSON 12
8. Choose a control type and select a style and click Next.

Option Buttons is the default control type. Etched is the default style.

9. Enter a caption to be displayed above the option group and click Finish.

al
ACTIVITY 12-3

i
Adding an Option Box Group to a Form

r
te
Data Files:
• Improve.mdb

Setup:
You must have installed the Additional Wizard set when setting up this course. Otherwise, you

a
will be prompted at this point for a CD.

y
Scenario:

op
eM
In addition to an Order Entry form, you also have a New Customer Information form. On this
form, you’ll also include the payment method. You decide to add an option group as an inter-
face for adding the payment method number.

tC
What You Do How You Do It

1. Add an option group to a. Open frmNewCustomer in Design view.


frmNewCustomer by starting the
No
c
wizard.
b. If necessary, enlarge the Design view
window so that all the fields can be
seen.
n
Do

c. Verify that the Control Wizards tool is


selected.
e

d. In the Toolbox, choose the Option Group


tool .
se
r
fe
ea
Pl
Re

Lesson 12: Improving Your Forms 263


LESSON 12
e. Below the Phone and Fax labels, click the
form to start the Option Group Wizard.

rial
te
2. Create the four options that will be a. In the first Label Names text box, enter
displayed as choices: Cash, C.O.D., Cash
Company Charge, and Credit Card

a
as the default choice. To move to the next label, press Tab.

y
b. In the next three text boxes, enter C.O.

op
eM D., Company Charge, and Credit Card

tC
No
n c
Do

c. Click Next.
e

d. Verify that the Yes, The Default Choice


se

Is option is selected. Display the drop-


r

down list of labels, and select Credit


Card. Click Next.
fe
ea
Pl
Re

e. To accept the default values, click Next.

3. Store the value in the Payment a. Select the option Store The Value In This
field, use the Sunken style with Field.
option buttons, and add a label.

264 Microsoft® Office Access 2003 - Level 1


LESSON 12
b. From the drop-down list, select Payment.
Click Next.

al
c. Select Sunken as the style. Click Next.

i
You can select each of the styles and control
types and view the examples.

r
te
d. Type Payment Method

e. Click the Finish button. The option group


is created on the form design.

a
y
op
eM
tC
f. Save the form as frmMyNewCustomer
No
c
4. Page through the records to see the a. Change to Form view.
effect of the option group.
b. Page through the records. Different
n

option buttons are selected for each


Do

record, depending on which payment


method the customer has chosen.
e

c. Click the New Record button.


se
r

d. Verify that the default value for the


option group is Credit Card.
fe
ea
Pl
Re

Lesson 12: Improving Your Forms 265


LESSON 12
TOPIC C
Add Command Buttons

al
At this point, your forms look good and produce accurate data. Now you’ll learn how to add a
command button to your form to make repetitive functions easier to use.
Once you start working with your forms, you might discover that there are things you or oth-

i
ers who use your form commonly do—like print a form, close a form, or add a record. By
adding a command button to a form, you can automate tasks such as these, which could reduce

r
the time spent on such repetitive tasks. Such buttons also add a touch of professionalism to
your Access database, by giving them the appearance of a more robust application.

te
Command Buttons
Definition:

a
A Command button is a control that carries out a pre-defined function. The appearance

y
of command buttons can vary by size and by whether their label is text or an image.
Command buttons can be used to perform any number of common tasks, including

op
eM
form operations such as closing the form or printing the form, record operations such
as deleting a record, and many more.

tC
Example:

No
n c
Do
e
se
r
fe
ea

Figure 12-6: Three common command buttons: Close Form, Print Form, and
Delete Record.
Pl

How to Add Command Buttons


Re

Procedure Reference: Create Command Buttons Using the Wizard


To use the Command Button Wizard to create command buttons:
1. In Design view, open the form you want to add buttons to.

266 Microsoft® Office Access 2003 - Level 1


LESSON 12
2. If necessary, make room for the buttons on the form.
3. If necessary, open the Toolbox and activate the Control Wizards button.
4. In the toolbox, choose the Command Button tool.

al
5. In the Form Design view window, click where you want the command button to
appear.
6. Click one of the categories.
7. Select an action. Click Next.

i
8. The remaining steps of the wizard depend on the type of action you chose. Click

r
Next.
9. Enter a name for the button and click Finish.

te
ACTIVITY 12-4

a
Adding a Command Button to a Form

y
op
Data Files:
• Improve.mdb
eM
tC
Setup:
The frmMyNewCustomer form is open in Form view.

Scenario:
No
Once an order is taken, the form can be closed. This is a fairly common routine: open the
c
form to record a transaction, and then close the form. You’ve decided that it would be nice to
have a button to do that, so you will add a command button to close the form.
n
Do
e
se
r
fe
ea
Pl
Re

Lesson 12: Improving Your Forms 267


LESSON 12
What You Do How You Do It

1. Add a command button to the bot- a. Change to Design view and choose the
tom of the form that will close the Command Button tool from the
form. Toolbox.

al
b. To start the Command Button Wizard,
click the mouse button in the lower-left
corner of the form.

ri
te
c. The Command Button Wizard displays.

a
From the Categories list box, select Form

y
Operations.

op
eM d. From the Actions list box, select Close
Form. Click Next.

tC
No
n c
Do
e

e. Select Text. Click Next.


se
r

f. Type Close Form and click Finish.


fe

2. a. Save the form.


ea

Test the Close Form button.

b. To close the form, switch to Form view


and click the Close Form command but-
Pl
Re

ton .

If you are asked to save the form again, click


Yes.

268 Microsoft® Office Access 2003 - Level 1


LESSON 12
TOPIC D
Create a Subform

al
You’ve improved the appearance and usability of your forms, but there is more you can do. In
this topic, you will enable a form to include data from a second table.
Consider a case where you have two tables with data in a one-to-many relationship. It might

i
make sense to allow users to add or update data in both tables at once. By creating a subform
you enable users of a form to add or update records in the primary table while at the same

r
time modify any related data in the secondary table. This saves them from needing to work in
two separate forms at once and reduces the chances for data-entry errors.

te
Subforms
Definition:

a
A subform is a form that is displayed as an object within another form called a main

y
form. When a one-to-many relationship exists between tables or queries, you can use
the main form to represent the “one” side of the relationship and a subform to repre-

op
eM
sent the “many” side. The subform is often displayed in Datasheet view so that
multiple records can be shown for each related record in the main form. You can
modify the data for both the fields in the main form and the rows in the subform.

tC
Although the subform is displayed as part of another form, it is a separate form, and its design is inde-
pendent of the main form.
No
Example:
n c
Do
e
se
r
fe
ea
Pl
Re

Figure 12-7: A main form with Orders data that contains a subform with
related Order Details data.

Lesson 12: Improving Your Forms 269


LESSON 12
How to Create a Subform
Procedure Reference: Create a Subform Using the Wizard
The Subform/Subreport Wizard can guide you through the steps of creating a subform

al
when a main form exists. To create a subform by using the Subform/Subreport Wizard:
1. From the Toolbox, choose the Subform/Subreport tool.
2. Click in the desired location on the form on which you would like to place the
subform.

i
3. Select your data source for the subform.

r
te
You can insert a new subform based on a table or query, or you can insert an existing form as a
subform.

4. Select the object that will create the subform. Click Next.
• If you select the tables and queries option, display the table or query that

a
contains the fields you would like to use and add them to the Selected Fields

y
list box.

op

eM
You can select fields from more than one table or query.

If you select the forms option, select the form that you want from the list
box.

tC
5. Select one of the links that Access suggests, or create one of your own. Click
Next.
6. Name your form and click Finish.
No
c
Other ways to add a subform to a form: drag a form from the database window to the Design
view window; or drag a table from the database window.
n
Do

Using a Form that has a Subform


In Form view, you can switch between a main form and a subform by using the Tab
key or the mouse. When you use a form that has a subform to enter new records,
e

Access saves the current record in the main form. This ensures that the records in
the “many” table will also have a record in the “one” table to relate to. Each record is
se

also saved automatically as you add it to the subform.


r
fe
ea
Pl
Re

270 Microsoft® Office Access 2003 - Level 1


LESSON 12
ACTIVITY 12-5
Adding a Subform Control to an Access Form

al
Data Files:
• Improve.mdb

i
Setup:

r
The Improve database is open in Access.

Scenario:

te
You have a simple form, frmCustomersMain, that displays basic information about each
customer. When entering or editing data with this form, it would be helpful if you also read,
enter, or update information about the related records from tblBookSales. You will accomplish
this by adding a subform to the main form.

a
y
What You Do How You Do It

op
1. Start the Subform/Subreport Wizard
to add a subform to
frmCustomersMain.
eMa. Open frmCustomersMain.

tC
No
n c

b. Switch to Design view and verify that


Do

the Control Wizards button is selected.


e

c. Choose the Subform/Subreport tool


.
se
r

d. Click in the form below the existing con-


trols to launch the wizard.
fe
ea
Pl
Re

Lesson 12: Improving Your Forms 271


LESSON 12
2. Complete the wizard such that the a. The Subform Wizard is displayed. Verify
data source is tblBookSales and all that Use Existing Tables And Queries is
the fields except the CustomerID selected. Click Next.
field are included.
b. To add fields from tblBookSales, display

al
the Tables/Queries drop-down list and
select Table: tblBookSales.

c. Add all the fields to the Selected Fields

i
list box except CustomerID.

r
a te
y
d. Click Next.

op
eM e. To accept the wizard’s suggestion regard-
ing the linking of the forms, click Next.

tC
f. In the Subform text box, type
fsubMyBookSales
No
g. Click Finish.
n c
Do
e
se
r
fe
ea

You may need to resize the form window to see the


entire Subform control as shown.
Pl
Re

3. With the Subform control selected, a. If necessary, using the Object drop-down
change the Width property to 4”. menu on the Formatting
Save your work. toolbar, select fsubMyBookSales.

272 Microsoft® Office Access 2003 - Level 1


LESSON 12
b. On the Form Design toolbar, click the
Properties button .

rial
a te
c. In the Width property box, enter 4”

y
op
eM
d. Close the properties dialog box.

e. Save the main form as


frmMyCustomersMain

tC
No
n c
Do
e
se
r
fe
ea
Pl
Re

Lesson 12: Improving Your Forms 273


LESSON 12
4. View the form that now includes a a. Switch to Form view.
subform in Form view.
b. To alter the width of the first column,
double-click the field border between
OrderID and TransactionDate.

al
c. To extend the widths of the other three
columns, do the same on the field bor-
ders between TransactionDate and

i
PartNumber, PartNumber and
QuantitySold, and at the right edge of

r
QuantitySold.

a te
y
op
eM
tC
5. True or False? Although the CustomerID field is not found in the subform, because the
tblCustomer and tblBookSales are related, the data in the CustomerID field in the main
form will be used for the CustomerID data in the related table as well.
No
True
c
False

6. a. Close the frmCustomersMain form.


n

Close the form and the database


Do

window.
b. Close the Improve database window.
e
se
r

Lesson 12 Follow-up
fe
ea

In this lesson, you learned techniques to make forms work more efficiently and intuitively for
the user. By grouping form controls and making other aesthetic improvements, users will feel
more comfortable while entering data. By using command buttons and subforms, you can
Pl
Re

make users more efficient, and these gains can be very large—as in many databases the bulk of
time spent by users is in forms.
1. What do you expect will be the most challenging aspects of improving your forms?

274 Microsoft® Office Access 2003 - Level 1


LESSON 12
2. Do you expect to make more aesthetic improvements to your forms or more improve-
ments to enhance data entry efficiency? Or both?

rial
a te
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re

Lesson 12: Improving Your Forms 275


NOTES

rial
a te
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re

276 Microsoft® Office Access 2003 - Level 1


LESSON 13

al
LESSON 13 Lesson Time
1 hour(s)

ri
Customizing Your Reports

a te
Lesson Objectives:

y
op
eM
In this lesson, you will customize reports to better organize the displayed information and pro-
duce specific print layouts such as mailing labels.
You will:

tC
Sort and group report records.
• Set report control properties that enhance the display of data.
• Control whitespace between records and manual page breaks.
• Include data that is printed at the beginning or end of each group of data on your report.
No

c
Add a subreport to a report footer.
• Create a mailing label report.
n
Do
e
se
r
fe
ea
Pl
Re

Lesson 13: Customizing Your Reports 277


LESSON 13
Introduction
The reports you create with AutoReport or the Report Wizard might work perfectly for you,
but chances are you’ll end up in the Report Design view window to improve your reports at
some point. This lesson will provide an opportunity to try your hand at many report design

al
tasks.
You have been assigned to produce invoices from a product orders database. Using basic
report features, you could create one report for the customer’s information and a second report
for the products they have just ordered. But, by customizing a report, you can create a single,

i
far more effective invoice.

r
te
TOPIC A
Organize Report Information

a
y
You have created some basic reports using the Report Wizard. You may have noticed that
while the desired information was all included, it was not optimally organized and it lacked

op
eM
any summary information. In this topic, you take the first step in customizing your reports by
sorting and grouping report records to show summary information.
By determining the order in which the data is displayed in the report and by grouping relevant

tC
data together in the report, you can present information in a more logical and concise format.
For example, you may want to group employees by department, and then list them in alpha-
betical order by last name. Or, you could use record grouping to view or print data by
department or by sales territory. Such simple changes can be very valuable for the reader of
your report.
No
c
Report Design Enhancements
n

Regardless of the method you chose to initially create a report, you can always modify the
Do

report design to improve it. There are many report design features that you can use to accom-
plish this. (See Table 13-1.)
e

Table 13-1: Report Design Enhancements


Enhancement Description
se
r

Text display Change the alignment of text within a control to provide greater balance.
Whitespace Reduce or increase the amount of whitespace between records in the
fe

Detail section.
ea

Graphic elements Add lines, rectangles, borders, or dashes to your report.


Pictures Add pictures and logos to your report for visual appeal.
Page breaks Control whether to keep the data in a group together on a page or force a
Pl
Re

page break before or after a section.


Custom pages Create a custom page, such as one with a subreport.

278 Microsoft® Office Access 2003 - Level 1


LESSON 13
Report Design View
The Report Design view window (see Figure 13-1) is the design environment for making
changes to a report’s design. It provides numerous tools to help you improve the design of
reports generated by the Report Wizard or those previously created manually.

al
Many of the tools available to help you with your design work in Report Design view are the same as those avail-
able in Form Design view.

ri
Tool Description
Report Design toolbar Provides buttons for common tasks like View,

te
Save, and Print. It also includes the useful Sorting
and Grouping button.
Formatting toolbar Has buttons for typical formatting jobs, like chang-
ing font sizes and colors.
Toolbox Has buttons for placing labels, fields, images, and

a
other special-purpose objects in a report. This is

y
where you typically go to find controls to add to
your report.

op
Field List

Properties dialog box


eM
Shows fields from the table or query that is the
source of data for the report you are working on.
Each object in a Report Design view window has

tC
its own properties dialog box with tabs that list the
properties you can change for the object.
Control Wizards toggle button Often when you click a button in the Toolbox to
place an object on the report design, you get some
No
help from one of the Access wizards.
n c
Do
e
se
r
fe
ea
Pl
Re

Lesson 13: Customizing Your Reports 279


LESSON 13

rial
a te
y
op
eM
Figure 13-1: The Report Design view window.

tC
How to Organize Report Information
Procedure Reference: Add Report Grouping using the Wizard
No
To build grouping and sorting features into a report based on a query by using the
c
Report Wizard:
1. Open a query in Design view.
n

2. From the New Object button’s drop-down list, select Report.


Do

3. In the New Report dialog box, select Report Wizard and click OK.
e

4. Select the desired fields and click Next.


5. Choose the desired field to group records by and click Next.
se
r

6. If desired, choose additional grouping levels. Click Next.


7. If desired, choose a field to sort records by and choose a sort order (Ascending or
fe

Descending).
ea

8. If desired, specify any calculated fields by clicking Summary Options and making
a selection. Click OK, and then click Next.
9. Choose a layout for your report and click Next.
Pl
Re

10. Choose a style for your report and click Next.


11. Name your report and click Finish.

280 Microsoft® Office Access 2003 - Level 1


LESSON 13
Procedure Reference: Add a Report Grouping Section Manually
If, after using the Report Wizard, you decide to add record grouping and sorting, you
can still do so. To manually add a Report Grouping section to a report:
1. Open a report.

al
2. Display the report in Design view.
3. Open the Sorting And Grouping dialog box.
4. To specify a sort, click in the first blank line under the Field/Expression section to

i
show its drop-down arrow, and then select the field you want from the list of
fields. Under the Sort Order heading, specify Ascending or Descending.

r
5. In the bottom half of the dialog box, select the group properties you would like,

te
such as a header or a footer.
6. As desired, move the sort field higher in the field list.
7. Close the Sorting And Grouping dialog box.

a
ACTIVITY 13-1

y
op
Sorting and Grouping Report Records
eM
tC
Data Files:
• Report.mdb

Setup:
No
Access is open.
c
Scenario:
You need to create a report with customer order information grouped by book titles. The report
n

will be based on a query, qselSalesAndProfit, that draws data from four tables and displays all
Do

kinds of information about the book’s transactions. Under each book title will be customer
name, quantity sold, transaction date, and order ID. These detail records will be sorted by cus-
e

tomer name. Under each title, you also want to show how many of that book you’ve sold.

What You Do How You Do It


se
r

1. Start the Report Wizard to create a a. Open Report.mdb.


fe

report based on qselSalesAndProfit.


ea

Include the BookTitle,


b. Open qselSalesAndProfit in Design view.
CustomerName, QuantitySold,
TransactionDate, and OrderID
fields. c. From the New Object button’s drop-down
Pl
Re

list, select Report.

d. In the New Report dialog box, select


Report Wizard. Click OK.

Lesson 13: Customizing Your Reports 281


LESSON 13
e. From the Available Fields list box, move
the BookTitle, CustomerName,
QuantitySold, TransactionDate, and
OrderID fields to the Selected Fields list
box. Click Next.

rial
a te
y
op
2. eM
Group the data by book title. Sort
the detail records by customer
name in ascending order.
a. To view your data by book title, verify By
TblBookProject is selected. Click Next.

tC
No
n c
Do
e

b. You don’t want other grouping levels.


se
r

Click Next.
fe
ea
Pl
Re

282 Microsoft® Office Access 2003 - Level 1


LESSON 13
c. From the first sort drop-down list, select
CustomerName. The default sort order is
Ascending.

al
3. Specify the sum of the quantity sold a. To summarize detail records, click Sum-
as the only summary value to be mary Options .

i
calculated.

r
b. For the QuantitySold field, check Sum.

a te
y
op
eM
tC
No
c. Click OK, and then click Next.
n c
Do
e
se
r
fe
ea
Pl
Re

Lesson 13: Customizing Your Reports 283


LESSON 13
4. Set the layout and style of your a. In the Layout option group, select Align
report to be Align Left and Formal Left 1. Click Next.
and complete the wizard.
b. From the report style list box, select
You can preview the layout and style in Formal. Click Next.

al
the left section of the dialog box.

c. In the report title text box, type My Book


Sales and click Finish.

ri
a te
y
op
eM
tC
As you scroll through the report, you might see fea-
tures you would like to change.

5.
No
What are some things you could improve about the data layout?
c

6. What are some things you could improve about the pagination? For example, is there a
n

lot or a little white space? Where do pages break?


Do
e
se

7. What are some things you could improve about the summary data in each group and
r

the end of the report?


fe
ea
Pl

8. Close the Print Preview of the a. To display Design view, click Close
Re

report and close qselSalesAndProfit. .

b. Close qselSalesAndProfit.

284 Microsoft® Office Access 2003 - Level 1


LESSON 13
TOPIC B
Set Report Control Properties

al
You’ve created a report that includes groups, which is a big step in the organization of the
report. But that effort will be all for naught if the data doesn’t display very well in the report.
In this topic, you will use control properties to enhance the data layout.

i
Of course you want your reports to look good, and generally the Report Wizard does an
adequate job of creating the initial report based on your specifications. But to look truly out-

r
standing, in most cases, you’ll need to bring a little finesse to the situation by altering some
key control properties. In the end, the effort will be worthwhile—a report that really stands out

te
for both its organization and its layout design.

Display Properties

a
Report control properties allow you to customize the look and capabilities of controls in your

y
reports.

op
Control Property
Caption
Description
eM
Provides an alternate label to be used in place of the default name for
the control.

tC
Width Sets an object’s width to specific dimensions.
Height Sets an object’s height to specific dimensions.
Can Grow Controls the appearance of controls that are printed or previewed. When
No
set to Yes, the control automatically resizes vertically so that all the data
c
it contains is shown.
Can Shrink Similar to Can Grow. When set to Yes, the control automatically resizes
vertically so that all the data it contains is shown but no additional space
n

is displayed.
Do

Text Align Specifies the alignment of text in the control. Settings are General, Left,
Center, Right, or Distribute.
e
se
r

The Width and Height properties are useful if you want to create objects that are exactly the same size or have
the same height or width.
fe
ea

Hide Duplicates Property


If you use the Report Wizard to design a report and you select a field for grouping,
Access automatically puts that field in a Group Header, where it is printed only once
for each group. The Hide Duplicates property provides an alternative method for sup-
Pl
Re

pressing repeating values without choosing groups. To use the Hide Duplicates
property, sort the records on a field (either by basing the report on a query or in the
report design itself), so that the repeating values in the field appear together. In the
report Design view, select the appropriate control. Set the Hide Duplicates property for
the control to Yes.

Lesson 13: Customizing Your Reports 285


LESSON 13
How to Set Report Control Properties
Procedure Reference: Modify the Properties of a Control
To enhance the appearance of the report by modifying the properties of its controls:

al
1. Select the control in report Design view.
2. Change the properties displayed in the properties dialog box as desired.

i
ACTIVITY 13-2

r
te
Setting Report Control Properties
Data Files:
• Report.mdb

a
y
Setup:
The My Book Sales report is open in Design view.

op
Scenario:
eM
You have decided to make some improvements to the My Book Sales report. Your first focus

tC
is the data layout. For example, some book titles and customer names are truncated. In addi-
tion, some customer names are repeated. A better way would be to list each customer name
once along with its corresponding transaction dates. The end result will be a concise, efficient
report that does not display repeating data. No
n c
Do
e
se
r
fe
ea
Pl
Re

286 Microsoft® Office Access 2003 - Level 1


LESSON 13
What You Do How You Do It

1. For both the report title bar and for a. Choose View→Properties to display the
the report title, change the caption report’s properties.
to Book Sales.

al
b. Change the report’s Caption property to
Book Sales

ri
te
You won’t see this change take effect unless the
report is in Print Preview.

c. In the Report Header section, select the

a
label control.

y
d. Change the label’s Caption property to

op
eM Book Sales

You can keep the property window open and


simply select each of the controls whose prop-

tC
erties you wish to modify, as the property
window will dynamically display the current
control’s properties.
No
2. Change the width of the BookTitle a. In the BookTitle Header section, provide
c
text box to fit each title on a single enough space for each title to be dis-
line. Modify the CustomerName text played on a single line by selecting the
box control so long names wrap to a BookTitle text box and changing its
n

second line. Width property to 3.75”


Do

b. In the Detail section, select the text box


e

CustomerName. On the Format property


page, change the Can Grow property to
Yes.
se
r

3. Change the alignment of the a. Select the QuantitySold text box.


fe

QuantitySold data in the Detail sec-


tion to center the values.
ea

b. Scroll down the list of properties on the


Format tab and change the control’s
Text Align property to Center.
Pl
Re

Lesson 13: Customizing Your Reports 287


LESSON 13
4. Center the values of the a. For the TransactionDate text box in the
TransactionDate and Sum Of Detail section, change the Text Align
QuantitySold text boxes. property to Center.

b. For the SumOfQuantitySold text box in the

al
BookTitle footer, change the Text Align
property to Center.

5. Change the caption of the Sum label a. For the Sum label in the BookTitle Footer

i
to Total Sold and set its width to section, change the Caption property to
0.56”. Change the caption of the Total Sold

r
Grand Total label to Books Grand
Total, set its width to 1.35”, and Set its Width property to 0.56”

te
center it.
Access might change this to 0.5597”.

b. For the Grand Total label in the Report

a
Footer section, change the Caption prop-
erty to Books Grand Total

y
Set its Width property to 1.35”

op
eM c. For the QuantitySold Grand Total Sum text
box in the Report footer, change the Text

tC
Align property to Center.

d. Preview the report by clicking Print Pre-


view .
No
n c
Do
e
se
r
fe
ea
Pl
Re

288 Microsoft® Office Access 2003 - Level 1


LESSON 13
6. Hide repeating data in the a. Change to Design view. In the Detail sec-
CustomerName text box control. tion, select the CustomerName text box
Save your work as rptMyOrders. control.

al
b. On the Format page of the properties dia-

i
log box, change the Hide Duplicates
property to Yes.

r
a te
y
op
eM
c. Close the properties dialog box.

d. Preview the report. No repeated data is


displayed in the CustomerName column in

tC
the report.

No
n c
Do
e
se
r
fe
ea

e. Change to Design view. Save the report


Pl

as rptMyOrders
Re

Lesson 13: Customizing Your Reports 289


LESSON 13
TOPIC C
Control Report Pagination

al
So far in this lesson, you’ve organized the desired information through grouping and sorting,
and you’ve dealt with data layout issues. The next step is to hone in on the report pagination—
where the pages break and how much white space is displayed on each page.

i
A report loses much of its appeal when the data seems to extend from one page to the next
with little or no concern as to when the page breaks. Although it might not seem like a big

r
deal, having data spill over in no organized fashion can cause your audience to become dis-
tracted and lose interest, and it may prevent them from arriving at the conclusions you are

te
trying to make. However, setting your pagination squarely and properly does not take much
additional effort and can be the clincher for a great-looking report.

Keep Together Property

a
y
The Keep Together property can be used to control page breaks for control groups such as the
group header, detail section, and group footer. This property can prevent widowed records

op
eM
from being displayed alone at the top of a new page.

The Keep Together property can also be directly applied to a particular section. In this case its possible values
are simply Yes and No.

tC
Keep Together Property Settings
No
Setting Description
c
No Allows the group to print without keeping the
Group Header, Detail, and Group Footer sec-
tions on the same page.
n
Do

Whole Group Forces the Group Header, Detail, and Group


Footer sections to print on the same page.
Groups that are too large to fit on a single
e

page will be split across pages.


With First Detail Allows the Group Header to print on a page
se

only if the first Detail record can also be


r

printed on that page.


fe
ea

Force New Page Property


The Force New Page property can be used to force each new section to print on a new page of
Pl
Re

the report. This property can guarantee that critical information is shown on a fresh page.

290 Microsoft® Office Access 2003 - Level 1


LESSON 13
Force New Page Property Settings

Setting Description
None Allows the section to print on the current

al
page.
Before Section Forces the section to start printing at the top
of a new page.
After Section Forces the following section to start printing at

i
the top of a new page.

r
Before & After Forces the current and following sections to
start printing at the top of a new page.

te
How to Control Report Pagination

a
Procedure Reference: Control Pagination of a Report

y
To control report pagination:

op
1.
2.
eM
If necessary, open the report in Design view.
If desired, adjust line spacing in one of two ways:
• Drag the section header to the desired location on the vertical ruler.

tC
• Select the section and then change the Height property.

When the mouse pointer is in position to move a report band up or down, it changes to a cross
with a double-headed vertical arrow.
No
c
The settings are confined to the section in which they are made. For example, if you increase the
size of the Report Heading section, it won’t affect the spacing in the Detail section of the report.
n
Do

3. Open the Sorting And Grouping dialog box.


4. Set the Keep Together and/or Force New Page properties for the group.
e

5. Close the Sorting And Grouping dialog box.


se
r

Troubleshooting a Report
When you print your report, you might get unwanted blank pages for one of several
fe

reasons.
ea

• If you get a blank page only at the end of the report, it could be that you have an
empty Report Footer section with a Height property set to something other than
zero. Check the Report Footer’s Height property and make sure it’s set to zero.
Pl


Re

If you’re getting blank pages on every other page of your report, make sure that
the total width of the report plus the widths of the left and right margins don’t
exceed the paper size specified in the Page Setup dialog box. If they do, then you
can either reduce the width of the report, reduce the margins, or change the page
orientation.

Lesson 13: Customizing Your Reports 291


LESSON 13
ACTIVITY 13-3
Reducing the Amount of White Space Between Records

al
and Controlling Manual Page Breaks
Data Files:
• Report.mdb

ri
Setup:
The rptMyOrders report is open in Design view.

te
Scenario:
You’ve decided to optimize your Book Sales report to make it easier to read. Currently, there
is too much white space and the page breaks often split the groups on the report. In fact,
groups sometimes start at the bottom of the page, which is less than ideal. You will correct

a
these layout flaws.

y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re

292 Microsoft® Office Access 2003 - Level 1


LESSON 13
What You Do How You Do It

1. The records in the report are rather a. To select all of the controls in the Detail
spaced out. Reduce the unnecessary section, click in the vertical ruler to the
white space under the controls in left of the controls in the Detail section.

al
the Detail section by decreasing its
size.

i
b. To position the controls higher in the

r
Detail section, press the up arrow key
once.

te
c. Place the mouse pointer on the top bor-
der of the BookTitle Footer band. Drag
the band up a small distance to nearly
touch the bottoms of the four text box

a
controls in the Detail section.

y
op
eM
tC
No
c
Instead of dragging the band, you could change the
Height property of the Detail section to 0.225”.
n
Do

2. To prevent groups from splitting on a. Click the Sorting And Grouping button
the report, open the Sorting And .
e

Grouping dialog box and set the


Keep Together property to Whole
Group. b. With BookTitle selected, under the Group
Properties heading, display the Keep
se
r

Together drop-down list.


fe
ea
Pl
Re

Lesson 13: Customizing Your Reports 293


LESSON 13
c. To keep category groups together on the
same page, select Whole Group.

rial
te
d. Verify that the Group Header and Group
Footer properties for the BookTitle field
are each set to Yes. Each section will dis-
play in the report. Close the Sorting And

a
Grouping dialog box.

y
3. Preview the report and save your a. Select Print Preview to preview your

op
work. eM report.

b. Customer names are closer together, so

tC
there’s less white space. No groups are
split across pages. Close print preview to
return to Design view. Save the report.
No
c

TOPIC D
n
Do

Summarize Information
e

As you saw earlier, you can use the Report Wizard to show summary information in a report.
se
r

Now you’ll go through the steps of setting up summary fields by hand, and you’ll add other
fields to the Group Footer as well.
fe

Sometimes your reports call for even more detail and organization than you’ve created thus far.
ea

For these more complex reports, manually using groups and summary information fields is the
ticket. While this can take some extra effort, the results are definitely worthwhile, as it permits
you to provide exactly the information desired in your report.
Pl
Re

How to Summarize Information


Procedure Reference: Define a Summary Field
To define a summary field, perform the following steps:
1. If necessary, open the report in Design view.

294 Microsoft® Office Access 2003 - Level 1


LESSON 13
2. Make room in the report for the new control.
3. Choose the Text Box tool.
4. From the Toolbox, click the report design where you want to create a Text Box
control.

al
5. In the properties dialog box for the new control, in the Control Source property,
enter an expression for the summary you want to perform.

Adding Fields to Sections in a Report

i
Depending on the information you display in your report and how it’s grouped, you

r
might still need to add fields to a report section. You can do this by dragging fields
from the field list to the appropriate section of your report.

te
Moving Report Controls
To move a control you’ve placed on the design, select it and drag or select it and use
the Ctrl key in combination with the arrow keys for precise placement.

a
ACTIVITY 13-4

y
op
Including Group Data and Defining a Summary Field
eM
tC
Data Files:
• Report.mdb

Setup:
No
The rptMyOrders report is open in Design view.
c
Scenario:
You would like to provide the readers of your Book Sales report with more information about
n

each book title. In particular, you will show inventory and restock orders for each book title.
Do

Additionally, you would like to add those numbers to show the available count of the title.
e

What You Do How You Do It

1. Make room on the report for two a. Display the properties dialog box for the
se
r

new controls. BookTitle Footer.


fe
ea
Pl
Re

Lesson 13: Customizing Your Reports 295


LESSON 13
b. Change the Height property to 1”

rial
te
c. Close the property dialog box.

a
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re

296 Microsoft® Office Access 2003 - Level 1


LESSON 13
2. Add the InStock and OnOrder fields a. If necessary, choose View→Field List to
to the BookTitle Footer and align display the field list window.
them as necessary.
b. From the bottom of the field list, select
InStock and OnOrder.

rial
te
c. Drag the selected fields to the 1” hori-
zontal position in the BookTitle Footer,

a
below the Total Sold label and text box

y
controls.

op
eM
tC
You can fine-tune the placement of selected controls
No
by using Ctrl-arrow keys.
c
d. With the InStock and OnOrder label con-
n

trols selected, shift-click the Total Sold


Do

label to select it as well.


e

e. To align all three labels, choose Format→


Align→Left.
se
r

f. Close the field list.


fe

3. Create a Text Box control to show a. From the toolbox, choose the Text Box
ea

the total inventory and sum of the tool .


InStock and OnOrder values. Align
as necessary.
b. Click in the Booktitle Footer to the right
Pl

of the InStock and OnOrder controls at


Re

about the 3.5” horizontal mark.

c. In the properties dialog box for the new


control, click the Data page.

Lesson 13: Customizing Your Reports 297


LESSON 13
d. On the Data page, in the Control Source
property box, enter
=([InStock]+[OnOrder])

rial
a te
y
Your property dialog box may have a title other than
Text Box: Text33.

op
eM e. Select the new label control.

tC
f. On the Format page of the properties dia-
log box, edit the caption to read Total
Inventory
No
g. Set the Width property to 0.9”
c
h. Close the properties dialog box.
n
Do

i. With the Total Inventory label and text


box controls selected, Shift-click the
OnOrder text box to select it as well.
e

j. To align these controls, choose Format→


se

Align→Bottom.
r
fe
ea
Pl
Re

298 Microsoft® Office Access 2003 - Level 1


LESSON 13
4. Separate the new controls from the a. Choose the Line tool .
next group with a dashed line (2pt
width) that is five inches long.
b. Hold down the Shift key and draw a line
below the controls in the BookTitle
Footer section that extends from the 0”

al
mark to the 5” mark on the horizontal
ruler.

c. Display the properties for the line.

ri
d. Change the line’s Border Style property
to Dashes.

te
e. Change the line’s Border Width property
to 2 pt.

f. Close the properties dialog box.

a
y
op
eM
tC
g. Save the updated report.

5. Preview your report. a. Click Print Preview.


No
n c
Do
e
se
r
fe
ea

b. Close the report preview.


Pl
Re

Lesson 13: Customizing Your Reports 299


LESSON 13
TOPIC E
Add a Subreport to an Existing Report

al
You’ve already done a number of things to improve the look and value of your reports. In this
topic, you will add a subreport to a report. Doing so goes beyond the mere display aspects of
your report and actually increases the amount of data that can be effectively included.

i
At times, you might want to provide additional or summary information on the data that you
display in your reports. Rather than creating two separate reports, you can combine them by

r
using a subreport. Doing so will save you time and result in a single, effective report with all
the data you need to convey.

te
Subreports
Definition:

a
A subreport is a report inserted into another report called the main report. This is often

y
done in the main report’s Report Footer section. A main report can be bound and
based on a table, query, or SQL statement, with the subreport linked to the main report

op
eM
using a link field. A main report can also be unbound and act as a folder for unrelated
subreports that you want to combine.

tC
The use of a link field to link a subreport to a main report is similar to the link field used to link a
subform to a main form.

Example: Subreport in a Bound Main Report


No
n c
Do
e
se
r
fe
ea
Pl
Re

Figure 13-2: A subreport to display product names in a bound main report dis-
playing orders.

300 Microsoft® Office Access 2003 - Level 1


LESSON 13
How to Add a Subreport to an Existing Report
Procedure Reference: Create a Subreport
To create a subreport:

al
1. If necessary, open the main report in Report Design view.
2. If necessary, make room for the subreport.
3. Click the Subform/Subreport tool.

i
4. Click in the report where you want to place the subreport.

r
5. In the SubReport Wizard, select the record source for the subreport. Click Next.

te
6. Choose which fields will link the main report to the subreport, or choose None.
Click Next.
7. Name the control and click Finish.

a
Another way to add a subreport to a report is to vertically tile the database window and the

y
Report Design view window. Drag the subreport from the database window to the appropriate
location in the main report that is displayed in the Report Design view window.

op
ACTIVITY 13-5
eM
tC
Adding an Existing Subreport to an Existing Report
Data Files:
No
c
• Report.mdb

Setup:
n

The rptMyOrders report is open in Design view.


Do

Scenario:
e

Suppose someone who uses your Book Sales report also wishes to see an ID reference number
for each customer. Fortunately, you already have a separate report that includes each custom-
er’s name and ID reference. You will therefore add the second report,
se
r

rsubCustomerNameAndID, as a subreport to the main report. By placing the subreport in the


Report Footer section, it will be printed once at the end of the report.
fe
ea
Pl
Re

Lesson 13: Customizing Your Reports 301


LESSON 13
What You Do How You Do It

1. Make room for a subreport and then a. To make room for the subreport, enlarge
add rsubCustomerNameAndID to the the Report Footer section by setting its
Report Footer section. Height property to 2.5”

rial
a te
y
op
eM You could also accomplish this by dragging the bot-
tom border of the Report Footer section.

tC
b. In the Toolbox, click the Subform/
Subreport tool .
No
c. To start the wizard, click in the Report
Footer area directly below the Books
c
Grand Total label.
n
Do
e
se
r

d. Specify the data for the subreport. Select


fe

Use An Existing Report Or Form to


ea

specify the data for the subreport.

e. Select rsubCustomerNameAndID. Click


Pl

Next.
Re

f. From the list, select None. Click Next.

302 Microsoft® Office Access 2003 - Level 1


LESSON 13
g. To leave the name intact, click Finish.

al
h. Save the modified report design.

ri
a te
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re

Lesson 13: Customizing Your Reports 303


LESSON 13
2. Preview your report to verify the a. Preview the report.
subreport and see what design issues
remain.
b. To view two pages at a time, click the
Two Pages button .

al
c. Scroll through the first several pages.

ri
a te
y
op
eM d. Verify that when you added this
subreport to the report, the report’s
width became greater than the printable
width, so the number of pages doubled

tC
and every other page is blank.

e. To see the grand total of books sold in the


subreport in the report footer, view the
No
second-to-last page.
n c
Do
e
se
r
fe
ea
Pl
Re

304 Microsoft® Office Access 2003 - Level 1


LESSON 13
f. Close Print Preview.

3. Eliminate the blank pages. Save a. Choose File→Page Setup.


your work.

al
b. On the Page tab, change the orientation
to Landscape. Click OK.

c. Preview the report.

i
d. Verify that the blank pages in the report

r
have been eliminated. Close the
preview.

te
e. Choose File→Page Setup.

f. On the Page tab, change the orientation


to Portrait.

a
y
g. On the Margins tab, change the Right

op
eM Margin setting to 0.5

tC
No
n c
Do
e
se
r
fe
ea

h. Click OK.

i. Save the modified report design.


Pl
Re

Lesson 13: Customizing Your Reports 305


LESSON 13
4. Preview the report. a. Preview and page through the report in
the two-page layout.

rial
te
b. Verify that the blank pages in the report
have been eliminated. Close the pre-

a
view and the report.

y
If the blank pages remain, make sure that the

op
eM report design grid is not more than seven
inches wide.

tC
No
TOPIC F
c

Create Mailing Labels


n
Do

The sort of reports you have been working with are great for common data printing
requirements. But there are times when an entirely different kind of printout is required, such
e

as when mailing labels are needed. Fortunately, Access provides a wizard specifically for this
need, and in this topic, you will use it to create a mailing labels report.
se
r

Typically, in a large enough company or organization, labels are created for mailing
purposes—for addressing envelopes and packages. However, you can just as easily create prod-
fe

uct labels, tape labels, name tags, or any other type of label you want. Rather than having to
ea

create a report from scratch, or use the standard Report Wizard, you will find that the Access
Label Wizard will save you a lot of time and create exactly the kind of result you need to print
labels.
Pl
Re

306 Microsoft® Office Access 2003 - Level 1


LESSON 13
How to Create Mailing Labels
Procedure Reference: Create a Report that Prints Mailing Labels
To create a report that prints mailing labels by using the Mailing Label Report Wiz-

al
ard:
1. In the database window, display the report objects and click New.
2. Double-click Label Wizard to open the first wizard step.

i
3. Choose a table or query for the labels and then click OK.

r
4. Choose the type of mailing label you’re using. Click Next.
5. Choose the text style for the labels. Click Next.

te
6. Arrange fields in the Prototype Label box to create a label layout. (Double-click a
field to move it to the Prototype Label box. Press Spacebar, add punctuation, and
press Enter as necessary to create the layout.) Click Next.

a
7. Select a field to sort your labels by. Click Next.

y
8. Name the mailing label report. Click Finish.

op
eM
If you want to change the sort order after the labels are designed, click the Sorting And Grouping
button on the toolbar to display the Sorting And Grouping dialog box, in which you can specify a
new sort order.

tC
Changing the Record Source and the Control Source
If a report design suits records from another table or query, you can display those
records by changing the record source for the report. For instance, you might have one
No
table that holds employee names and addresses and another that holds customer names
c
and addresses. An efficient and versatile way to produce mailing labels for both sets of
people would be to change the record source in the report’s properties dialog box; that
way, the report can print data from different tables. When you change the record
source, you might also need to change control sources on the report. You can change
n

control sources in each control’s properties dialog box.


Do
e
se
r
fe
ea
Pl
Re

Lesson 13: Customizing Your Reports 307


LESSON 13
ACTIVITY 13-6
Creating Mailing Labels

al
Data Files:
• Report.mdb

i
Setup:

r
The Report database window is open.

Scenario:

te
As head of Book Source, you have the need to correspond with all of your customers, whether
it be for a promotional offer, a quarterly catalog, or a revised price information sheet. From the
central office, you want to create a mailing label for every one of your customers. You will use
the Label Wizard to create a report design that prints Avery C2160 labels for records in

a
tblCustomer.

y
What You Do How You Do It

op
1.
eM
Begin to create mailing labels using
the wizard. Specify that the data
should come from tblCustomer.
a. If necessary, display the report database
objects.

tC
b. Click New . The New Report dia-
log box appears.
No
c. Select Label Wizard.
c
d. Click the drop-down list.
n

e. Select tblCustomer.
Do
e
se
r
fe
ea
Pl
Re

f. Click OK.

308 Microsoft® Office Access 2003 - Level 1


LESSON 13
2. Select a label size, unit of measure, a. Under the label size section, verify that
label type, and manufacturer by the first option is selected.
accepting the defaults.

rial
te
b. Accept the other options for Unit Of
Measure, Label Type, and Manufacturer

a
by clicking Next to continue.

y
c. To accept how the text on your label

op
eM appears, click Next.

tC
No
n c
Do

3. a. Double-click CustomerName. Press


e

Add the CustomerName, Address,


City, Region, and PostalCode fields Enter.
to the label.
se
r

b. Double-click Address. Press Enter.


fe

c. Double-click City. Type a comma. Press


ea

Spacebar. Double-click Region. Press


Enter.
Pl
Re

Lesson 13: Customizing Your Reports 309


LESSON 13
d. Double-click PostalCode. Press Enter.

rial
e. Click Next.

te
4. Sort the labels by customer name a. Double-click CustomerName. Click Next.
and name the report rptMyLabels.
b. Type rptMyLabels

c. Click Finish.

a
y
op
eM
tC
No
n c

5. Close the report and the database. a. Close the report preview.
Do

b. Close the report window.


e

c. Close the Report database.


se
r
fe
ea
Pl
Re

310 Microsoft® Office Access 2003 - Level 1


LESSON 13
Lesson 13 Follow-up
In this lesson, you modified reports to make them more visually effective and rich with
information. You were able to reduce white space, modify page breaks, and generally improve
the look of a report. But you also improved the report’s effectiveness at conveying information

al
by including calculated fields and a subreport, as well as creating a mailing labels report from
address information in your database. You should now be able to open most of the reports you
come across, including any created by the Report Wizard, and change them to suit your needs.
1. What do you think will be the most challenging requirements for improving the look of

i
your reports?

r
te
2. What do you think will be the most challenging requirements for increasing the infor-
mation that is conveyed by your reports?

a
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re

Lesson 13: Customizing Your Reports 311


NOTES

rial
a te
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re

312 Microsoft® Office Access 2003 - Level 1


LESSON 14

al
LESSON 14 Lesson Time
30 minutes

ri
Expanding the Reach of

te
Your Data

a
y
op
Lesson Objectives: eM
In this lesson, you will use Access data in other applications, including Microsoft Word and
Excel.

tC
You will:
• Publish data from Access as a Word document.
• Analyze data from Access in an Excel spreadsheet.
No

c
Export data from individual database objects to a text file.
• Merge data from Access with an existing Word document.
n
Do
e
se
r
fe
ea
Pl
Re

Lesson 14: Expanding the Reach of Your Data 313


LESSON 14
Introduction
The Access application is a great tool and it may be all you need to use to work with your
data. But you haven’t yet explored ways to take your data beyond Access. In this lesson, you’ll
export data to a text file and look at some of the methods for using your data in other pro-

al
grams with Office Links.
As a member of the Human Resources department, you have been asked to send a letter to
each employee in your company that explains new safety procedures. You have the employee
data in your Access database, but you need to use it in a Microsoft Word template. You can

i
expand the reach of your data by using Office Link technology to auto-populate the desired
letters, potentially saving you hours of tedious manual typing.

r
te
TOPIC A
Publish Access Data as a Word

a
y
Document

op
eM
There are numerous ways you can use Access data outside of the Access program itself. The
first you will consider is how to use a table worksheet or a report in Microsoft Word.

tC
Access reports and datasheets often include just the kind of information you need in a detailed
Word-based report, white paper, or memo. Sure, you could print your documents from Access
and staple them alongside your Word document, but you can create a better looking report and
save collating time by actually publishing the Access data directly into Word.
No
c
Office Links
The Office Links tool enables you to share Access data with Word and Excel. There are three
n

Office Links options, each of which works with different types of Access objects and has a
Do

different result. (See Table 14-1.)

Table 14-1: Office Links Options and Results


e

Office Link Works With Results


Publish It With Microsoft Office Forms, Reports, Tables, Queries Creates an RTF file of the
se
r

Word Access object and opens it in


Word.
fe

Analyze It With Microsoft Office Forms, Reports, Tables, Queries Saves Access data as an Excel
ea

Excel file and opens it in Excel.


Merge It With Microsoft Office Queries, Tables Creates an Access data source
Word for mail merge documents and
Pl

launches the Mail Merge Wizard


Re

in Word.

314 Microsoft® Office Access 2003 - Level 1


LESSON 14
How to Publish Access Data as a Word Document
Procedure Reference: Publish an Access Document with Word
To publish an Access document with Word:

al
1. In the database window, select the datasheet, form, report, or query that you wish
to publish.
2. Choose Tools→Office Links→Publish It With Microsoft Office Word. Word will
open, displaying the Access object as an RTF file.

i
3. Save the Word document.

r
te
ACTIVITY 14-1
Publishing Access Data as a Word Document

a
y
Data Files:
• Expand.mdb

op
Setup:
Access is open.
eM
tC
Scenario:
Your manager was pleased with the Book Sales report you created. However, she has asked to
receive it in Word format so that she can incorporate it in a larger document, highlight certain
No
areas, and make other formatting changes. You decide to use Office Links to publish the
c
Access report to Word.

What You Do How You Do It


n
Do

1. Publish rptMyOrders with Word. a. Open Expand.mdb.


e

b. In the database window, display the


report objects.
se
r

c. If necessary, select rptMyOrders.


fe
ea
Pl
Re

Lesson 14: Expanding the Reach of Your Data 315


LESSON 14
d. Choose Tools→Office Links→Publish It
With Microsoft Office Word.

rial
a te
y
op
2.
eM
Save the Word document as
rptBookSales.rtf and close the
document in Word.
a. In Microsoft Word, choose File→Save As
and name the file rptBookSales.rtf

tC
b. Click Save.

c. Close Word.
No
n c
Do

TOPIC B
e

Analyze Access Data in Excel


se
r

You have seen how Access data can be used in Word. Now you’re ready to see what you can
fe

do with Access data in Excel.


ea

Excel provides data analysis options that just aren’t available in Access. Plus, Excel has a
much wider variety of charting options. Moving data from your Access database to an Excel
worksheet allows you to take advantage of these features, extending your ability to analyze,
manipulate, and display your data.
Pl
Re

Excel Office Links


Since they aren’t available or easily accessible in Access, you can take advantage of Excel’s
financial analysis tools and charting options by using the Analyze It With Microsoft Office
Excel office links option. In doing so, your data is saved as an Excel XLS file.

316 Microsoft® Office Access 2003 - Level 1


LESSON 14
Any formatting that you have done in Access, such as font style and color, will be transferred to Excel.

Dragging and Dropping Tables and Queries to Excel


Another way to export data from Access to Excel is by dragging and dropping an

al
Access object, such as a table or query, from the database to Microsoft Excel. This is a
fast way to export data for further analysis using Excel’s toolset.

How to Analyze Access Data in Excel

ri
Procedure Reference: Analyze Access Data in Excel
To analyze Access data in Excel:

te
1. In the database window, select the datasheet, query, form, or report that you wish
to publish.
2. Choose Tools→Office Links→Analyze It With Microsoft Office Excel. Excel will

a
open, displaying the Access data in an Excel worksheet.

y
3. Save the Excel file.

op
ACTIVITY 14-2
eM
tC
Creating an Excel Chart with Access Data
Data Files:
No
• Expand.mdb
c
Setup:
The Expand database is open in Access.
n
Do

Scenario:
Your manager has asked for sales data for each book part number. She needs only the total
e

sales quantities for each item. However, she wants the data in an Excel spreadsheet, not in
Access table format. You decide to use Office Links to analyze the qselQuantitySold query in
Excel. She would also like to see the totals in a 3-D exploded pie chart—an option not easily
se
r

accessible in Access.
fe

What You Do How You Do It


ea

1. Analyze the qtotCategories query in a. In the database window, display the


Excel. query objects.
Pl
Re

b. If necessary, select qselQuantitySold.

Lesson 14: Expanding the Reach of Your Data 317


LESSON 14
c. Choose Tools→Office Links→Analyze It
With Microsoft Office Excel. Excel opens
and the query is displayed.

rial
a te
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re

318 Microsoft® Office Access 2003 - Level 1


LESSON 14
2. Create a 3-D exploded pie chart a. In Excel, click the Chart Wizard button
with the data. .

b. In the first screen of the wizard, in the


Standard Types page, under the Chart

al
Type heading, select Pie.

c. For the chart sub-type, select the middle


type on the bottom row, Exploded Pie

i
Chart With A 3-D Visual Effect. Click
Next.

r
a te
y
op
eM
tC
No
c
d. To accept the default worksheet data
selection, click Next.
n
Do

e. The next screen of the wizard asks you to


add a chart title. The wizard uses “Total
e

Quantity” from the column heading for


the sales totals. To accept the default,
click Next.
se
r

f. The final screen in the wizard asks where


fe

you wish to place the chart. Verify that


ea

As Object In qselQuantitySold is
selected, and then click Finish.
Pl
Re

Lesson 14: Expanding the Reach of Your Data 319


LESSON 14
3. Improve the placement of the chart a. Click the chart graphic and drag it to the
and save your work as top of your worksheet, starting at the D
rptQuantitySold. column.

rial
a te
y
op
eM b. Hover your mouse over the resize
handle in the middle and bottom of the
chart graphic. When it turns into a double
vertical arrow, resize the chart object so

tC
that all of the labels in the box on the
right are shown.
No
n c
Do
e
se
r
fe
ea

c. Choose File→Save As and name the file


Pl
Re

rptQuantitySold

d. Click Save.

e. Close Excel.

320 Microsoft® Office Access 2003 - Level 1


LESSON 14

TOPIC C

al
Export Data to a Text File

i
Besides Word and Excel, you can also use your Access data in other applications or in another

r
Access database. In this topic, you will export your data to a text file so that it can be used
elsewhere.

te
Access is a great program for managing lists of data; however, it doesn’t do everything. For
example, you may want to export data from Access into a specific accounting application to
take advantage of its advanced mathematic capabilities. By exporting data from Access to a
text file, you are then in a position to import that data into other databases or programs. This is
a flexible approach to expanding the reach of your data, allowing Access data to be used in a

a
wide range of applications.

y
Exporting

op
eM
Exporting is a means of outputting data and database objects to another database, spreadsheet,
or file format, so another application can use the data. A copy of the data is created in an

tC
external source file, so the original data is still stored in your database.

As you consider exporting data to other sources, keep in mind that other database systems have limitations on
the types of files they will accept. Some database systems will accept files in Excel format; others might only
accept text file formats. All of the Access objects allow you to export their data into a variety of formats (Excel,
No
text files, html, and so on), but the output of those formats will vary from one object to another. For example,
c
exporting a table or query to a text file is likely to result in a file that can be utilized in another database system.
Exporting a form or report to a text file is unlikely to have the same result.
n
Do
e
se
r
fe
ea
Pl
Re

Lesson 14: Expanding the Reach of Your Data 321


LESSON 14

rial
a te
y
op
eM
Figure 14-1: A copy of data from a table, query, form, or report can be made in vari-

tC
ous file formats.

How to Export Data to a Text File No


Procedure Reference: Export Data to a Text File
c
To export data from an Access table to an external text file:
1. Open the database window and select the object you want to export.
n
Do

2. Choose File→Export.
3. Change the folder, if needed, and enter a name for the new file.
e

4. Change Save As Type to the type of file you want to export to.
5. Click Export.
se
r

6. Choose an export format. Click Next.


fe

7. If you chose Delimited, then choose a character delimiter. Click Next.


ea

8. Choose a destination for the output file. Click Finish.


9. Click OK when the export is complete.
Pl
Re

To export to an Access database, enter a name for the exported object in the Export dialog box.
Select Definition Only if you want to export an empty table. Click OK.

322 Microsoft® Office Access 2003 - Level 1


LESSON 14
ACTIVITY 14-3
Exporting Database Records to Notepad

al
Data Files:
• Expand.mdb

i
Setup:

r
The Expand database window is open.

Scenario:

te
The data in tblCustomer has value to another department in your company. They currently use
an alternate proprietary database application and have requested that you send the data from
tblCustomer to them as a delimited text file. To accomplish this, you will export the data from
Access to a semicolon delimited text file.

a
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re

Lesson 14: Expanding the Reach of Your Data 323


LESSON 14
What You Do How You Do It

1. Export tblCustomer to a text file, a. In the database window, display the table
and save it as CustomerData.txt. objects.

al
b. If necessary, select tblCustomer.

c. Choose File→Export.

i
d. Type a file name of CustomerData

r
e. Open the Save As Type drop-down list

te
box and choose Text Files.

f. To start the Export Text Wizard, click


Export.

a
g. For the export format, verify that Delim-

y
ited is selected. Click Next.

op
eM
tC
No
n c
Do
e

h. Select Semicolon as the delimiter.


se
r
fe
ea

i. Click Next.
Pl
Re

j. Verify that the document will be saved


in My Documents. Click Finish.

k. The export is complete. Click OK.

324 Microsoft® Office Access 2003 - Level 1


LESSON 14
2. Open the CustomerData.txt file in Notepad to verify that the export was successful.

rial
te
3. True or False? The headings for each column of data were not exported with the

a
values.

y
True
False

op
4.
eM
True or False? When a value was empty (null) a space is placed between the two semi-
colons that delimit this field from the previous and next fields.

tC
True
False

5. In order for this exported data to be optimally used by another application, which
character must not appear in the data?
No
c
a) Comma
b) Semicolon
c) Space
n
Do

d) Ampersand
e

6. Close Notepad. a. Close Notepad.


se
r
fe
ea
Pl
Re

Lesson 14: Expanding the Reach of Your Data 325


LESSON 14
TOPIC D
Merge Access Data with a Word

al
Document
Thus far you have seen how to work with Access data in other applications. In each case, you

i
worked with the data as it is found in Access, but that isn’t always ideal. In this topic, you
will selectively work with Access data in exactly the way needed to create a personalized letter

r
in Word.
Suppose you have a database of employee information stored in Access. The data includes

te
employee names and addresses, among many other pieces of information. If the Human
Resources department wanted to mail a personalized letter out to each employee, they could
print out a report showing employee names and addresses and then rekey that information into
the Word document with the text of the letter. This would be tedious and time-consuming, but
it would get the job done. However, thanks to Office Links, there’s a much easier way of

a
merging Access data with Microsoft Word—one that eliminates the unnecessary retyping of the

y
information.

op
eM
How to Merge Access Data with a Word
Document

tC
Procedure Reference: Merge an Access Table or Query with an Existing Word
Document
To merge an Access table or query with an existing Word document:
No
1. In the database window, select the table or query.
c
For smoother merging, check field names in the Access table or query to be certain that they
aren’t longer than 20 characters and that they do not contain spaces or special characters.
n
Do

2. Choose Tools→Office Links→Merge It With Microsoft Office Word.


e

3. Choose to link your data to an existing Word document, and then select the
document. Click OK.
4. Locate your Word document and click Open.
se
r

5. Click Next: Write Your Letter.


fe

6. Add merge fields to your document, as desired.


ea

7. Click Next: Preview Your Letters and review the resulting merged letters.
8. Click Next: Complete The Merge.
Pl
Re

326 Microsoft® Office Access 2003 - Level 1


LESSON 14
ACTIVITY 14-4
Merging Access Data with a Word Document

al
Data Files:
• Expand.mdb
• CustomerLetter.doc

ri
Setup:
Access is open and the table objects are displayed.

te
Scenario:
A colleague needs to send a special announcement to all of your customers. He has provided a
Word file (CustomerLetter.doc) containing the letter. He knows that the customer names and
addresses are stored in your database, so he has asked if there is a way you could help auto-

a
mate the process. You will use the Office Links feature to merge this data with the letter,

y
saving your colleague a great deal of time.

op
What You Do

1. Start the Office Link Wizard to


eMHow You Do It

a. If necessary, from the list of tables,

tC
merge tblCustomer with select tblCustomer.
CustomerLetter.doc.
b. Choose Tools→Office Links→Merge It
With Microsoft Office Word.
No
c
c. Verify that Link Your Data To An Existing
Microsoft Word Document is selected,
and then click OK.
n
Do
e
se
r
fe
ea
Pl
Re

Lesson 14: Expanding the Reach of Your Data 327


LESSON 14
d. To launch the Mail Merge Wizard in Word,
select the CustomerLetter file, and then
click Open.

rial
a te
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re

328 Microsoft® Office Access 2003 - Level 1


LESSON 14
2. In the Write Your Letter step of the a. In the Mail Merge pane, in the Select
wizard, add mail merge fields for Recipients section, verify that Use An
the customer’s name, address, city, Existing List is selected and that
region, country, and postal code. tblCustomer is selected as that list. Click
Next: Write Your Letter.

rial
b. To open the Insert Merge Field dialog box,

te
position your insertion point in the
blank area to the left of the screen,
underneath the date, and click the
Insert Merge Fields button on the
toolbar.

a
y
op
eM
tC
No
n c
Do
e

Do not click the similar looking More Items button


se
r

in the Mail Merge pane.


fe

c. To add the CustomerName field to the


ea

letter, select CustomerName and then


click Insert.
Pl

d. Close the Insert Merge Field window.


Re

e. Press Enter. Click the Insert Merge


Fields button again.

f. To add the Address field to the letter,


select Address and click Insert.

Lesson 14: Expanding the Reach of Your Data 329


LESSON 14
g. Close the Insert Merge Field window.

h. Add merge fields for the City, Region,


Country, and Postal Code fields. Sepa-
rate the City and Region fields with a

al
comma and a space.

i. Add a merge field for the CustomerName


field after the greeting and before the

i
comma in the letter.

r
a te
y
op
3.
eM
Use the Mail Merge task pane to
preview your letters. Look at let-
a. In the Mail Merge task pane, click Next:
Preview Your Letters. The letter to your

tC
ters for both U.S. and Canadian first customer is displayed. Verify that
customers. the merge fields have been replaced
with customer information from the first
record in the table.
Be sure to use the Mail Merge task pane
No
to preview your letter. Do not use Print
c
Preview.
n
Do
e
se
r
fe
ea
Pl
Re

330 Microsoft® Office Access 2003 - Level 1


LESSON 14
b. To find a Canadian customer, in the Mail
Merge task pane, click the Find A Recipi-
ent link . The Find
Entry dialog box displays.

rial
te
c. In the Find text box, type Canada and
click Find Next.

a
y
op
eM
tC
No
c
d. Verify that the first Canadian customer
is shown. Click Cancel.
n
Do
e
se
r
fe
ea
Pl
Re

Lesson 14: Expanding the Reach of Your Data 331


LESSON 14
4. Complete the merge. Explore your a. In the Mail Merge task pane, click Next:
printing options. Save your letters. Complete the Merge.
Exit Word.
b. Click the Print link . The Merge
To Printer dialog box displays, giving you

al
the option to print all of the letters, the
current record only, or a range of letters.
Click Cancel.

ri
a te
y
c. Save your document as

op
eM MyCustomerLetter. Close Word.

d. Close Access.

tC
No
Lesson 14 Follow-up
c
Creating reports and queries in Access harnesses the power of your data, but suppose you
would like to take that data beyond Access? Whether you would like to add data to a Word
n

document, draw on data as a mail merge source, or use Excel to analyze your data, Office
Do

Links make it possible. You can expand the reach of your data further by exporting it in vari-
ous formats for use in other applications.
e

1. When might you use the Analyze It With Microsoft Office Excel Office Links option?
se
r

2. How might you take advantage of the Merge It With Microsoft Office Word Office Links
fe

option in your work?


ea
Pl
Re

332 Microsoft® Office Access 2003 - Level 1


Follow-up FOLLOW-UP
In this course, you explored the concept of the relational database and accomplished various
tasks using the basic features and components of Access 2003. In addition, you worked with
tables to store, modify, and report on data; you created new queries, forms, and reports; and

al
you modified existing queries, forms, and reports. You have also begun to prepare for the more
advanced Access courses and have completed the first step toward obtaining your Microsoft
Office Specialist certification.

i
What’s Next?

r
The Microsoft® Offıce Access 2003 - Level 1 course introduced you to the basics of the Access
application and prepared you to go to the New Horizons course, Microsoft® Offıce Access 2003 -

te
Level 2.

a
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re

333
NOTES

rial
a te
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re

334 Microsoft® Office Access 2003 - Level 1


APPENDIX A

al
APPENDIX A

ri
Microsoft Office Specialist

te
Program

a
y
Selected New Horizons courseware addresses Microsoft Office Specialist skills. The following

op
eM
tables indicate where Access 2003 skills are covered. For example, 1-3 indicates the lesson and
activity number applicable to that skill.

tC
Core Skill Sets and Skills Access 2003: Access 2003: Access 2003: Access 2003:
Being Measured Level 1 Level 2 Level 3 Level 4
Create Access Databases No
Creating databases using 2-1
Database Wizard
c
Creating blank databases 2-2
Create and Modify Tables
n

Creating tables using Table 2-3


Do

Wizard
Modifying table properties or 2-4, 2-5, 2-6,
e

structure 3-1
Define and Modify Field Types
se

Creating Lookup fields 3-3


r

Changing field types 2-5


fe

Modify Field Properties


ea

Changing field properties to 3-2


display input masks
Modifying field properties for 3-1
tables in Design view
Pl
Re

Create and Modify One-to-Many Relationships


Creating and modifying one- 2-7
to-many relationships
Enforce Referential Integrity

Appendix A: Microsoft Office Specialist Program 335


APPENDIX A
Core Skill Sets and Skills Access 2003: Access 2003: Access 2003: Access 2003:
Being Measured Level 1 Level 2 Level 3 Level 4
Enforcing referential integrity 2-7
in a one-to-many relationship

al
Create and Modify Queries
Creating and modifying Select 4-3
queries using the Simple
Query Wizard

i
Creating and modifying 2-1, 2-3

r
Crosstab, unmatched, and
duplicates queries

te
Create Forms
Creating forms using the 5-3
Form Wizard
Creating AutoForms 5-2

a
Add and Modify Form Controls and Properties

y
Modifying form properties 5-5, 5-6, 5-7,
5-8

op
Modifying specific form con-
trols (e.g., text boxes, labels,
bound controls)
Create Reports
eM
5-5, 5-6, 6-5 6-1

tC
Creating reports 6-1, 6-2 7-1, 7-6
Add and Modify Report Control Properties
Adding calculated controls to 6-4 7-4
a report selection
No
c
Create a Data Access Page
Creating data access pages 1-1
using the Page Wizard
n

Enter, Edit, and Delete Records


Do

Entering records into a 2-2


datasheet
e

Find and Move Among Records


Using navigation controls to 2-1, 2-5
se
r

move among records


Import Data to Access
fe

Importing structured data into 3-4


ea

tables
Create and Modify Calculated Fields and Aggregate Functions
Adding calculated fields to 4-5
Pl
Re

queries in Design view


Using aggregate functions in 4-6
queries (e.g., AVG, COUNT)
Modify Form Layout
Aligning and spacing controls 5-6, 5-7

336 Microsoft® Office Access 2003 - Level 1


APPENDIX A
Core Skill Sets and Skills Access 2003: Access 2003: Access 2003: Access 2003:
Being Measured Level 1 Level 2 Level 3 Level 4
Showing and hiding headers 6-1
and footers

al
Modify Report Layout and Page Setup
Changing margins and page 7-5
orientation
Aligning, resizing, and spac- 7-3

i
ing controls

r
Format Datasheets
Formatting a table or query 1-4

te
for display
Sort Records
Sorting records in tables, que- 2-3 5-1, 7-1
ries, forms, and reports

a
Filter Records

y
Filtering datasheets by form 4-1
Filtering datasheets by selec- 2-4 4-1

op
tion
Identify Object Dependencies
Identifying object dependen-
eM 7-5

tC
cies
View Objects and Object Data in Other Views
Previewing for print 2-7 No
Using Datasheet, PivotChart, 1-4 2-5 1-1, 1-3, 2-5
Web Page, and Layout view
c
Print Database Objects and Data
Printing database objects and 2-7 1-4
n

data
Do

Export Data From Access


Exporting data from Access 8-3
e

(e.g., Excel)
Back Up a Database
se

Backing up a database 7-2


r

Compact and Repair Databases


fe

Using Compact and Repair 7-3


ea
Pl
Re

Appendix A: Microsoft Office Specialist Program 337


NOTES

rial
a te
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re

338 Microsoft® Office Access 2003 - Level 1


APPENDIX B

al
APPENDIX B

ri
Microsoft Office Specialist

te
Program

a
y
Selected New Horizons courseware addresses Microsoft Office Specialist skills. The following

op
eM
tables indicate where Access 2003 skills are covered. For example, 1-3 indicates the lesson and
activity number applicable to that skill.

tC
Core Skill Sets and Skills Access 2003: Access 2003: Access 2003: Access 2003:
Being Measured Level 1 Level 2 Level 3 Level 4
Create Access Databases No
Creating databases using 2-1
Database Wizard
c
Creating blank databases 2-2
Create and Modify Tables
n

Creating tables using Table 2-3


Do

Wizard
Modifying table properties or 2-4, 2-5, 2-6,
e

structure 3-1
Define and Modify Field Types
se

Creating Lookup fields 3-3


r

Changing field types 2-5


fe

Modify Field Properties


ea

Changing field properties to 3-2


display input masks
Modify field properties for 3-1
tables in Table Design view
Pl
Re

Create and Modify One-to-many Relationships


Creating and modifying one- 2-7
to-many relationships
Enforce Referential Integrity

Appendix B: Microsoft Office Specialist Program 339


APPENDIX B
Core Skill Sets and Skills Access 2003: Access 2003: Access 2003: Access 2003:
Being Measured Level 1 Level 2 Level 3 Level 4
Enforcing referential integrity 2-7
in a one-to-many relationship

al
Create and Modify Queries
Creating and modifying Select 4-3
queries using the Simple
Query Wizard

i
Creating and modifying 2-1, 2-3

r
Crosstab, unmatched and
duplicates queries

te
Create Forms
Creating forms using the 5-3
Form Wizrd
Creating auto forms 5-2

a
Add and Modify Form Controls and Properties

y
Modifying form properties 5-5, 5-6, 5-7,
5-8

op
Modifying specific form con-
trols (e.g., text boxes, labels,
bound controls)
Create Reports
eM
5-5, 5-6, 6-5 6-1

tC
Creating reports 6-1, 6-2 7-1, 7-6
Add and Modify Report Control Properties
Adding calculated controls to 6-4 7-4
a report selection
No
c
Create a Data Access Page
Creating data access pages 1-1
using the Page Wizard
n

Enter, Edit, and Delete Records


Do

Entering records into a 2-2


datasheet
e

Find and Move Among Records


Using navigation controls to 2-1, 2-5
se
r

move among records


Import Data to Access
fe

Importing structured data into 3-4


ea

tables
Create and Modify Calculated Fields and Aggregate Functions
Adding calculated fields to 4-5
Pl
Re

queries in Query Design View


Using aggregate functions in 4-6
queries (e.g., AVG, COUNT)
Modify Form Layout
Aligning and spacing controls 5-6, 5-7

340 Microsoft® Office Access 2003 - Level 1


APPENDIX B
Core Skill Sets and Skills Access 2003: Access 2003: Access 2003: Access 2003:
Being Measured Level 1 Level 2 Level 3 Level 4
Showing and hiding headers 6-1
and footers

al
Modify Report Layout and Page Setup
Changing margins and page 7-5
orientation
Aligning, resizing, and spac- 7-3

i
ing controls

r
Format Datasheets
Formatting a table or query 1-4

te
for display
Sort Records
Sorting records in tables, que- 2-3 5-1, 7-1
ries, forms, and reports

a
Filter Records

y
Filtering datasheets by form 4-1
Filtering datasheets by selec- 2-4 4-1

op
tion
Identify Object Dependencies
Identify object dependencies
eM 7-5

tC
View Objects and Object Data in Other Views
Previewing for print 2-7
Using datasheet, PivotChart, 1-4 2-5 1-1, 1-3, 2-5
Web page and layout view
No
c
Print Database Objects and Data
Printing database objects and 2-7 1-4
data
n

Export Data From Access


Do

Exporting data from Access 8-3


(e.g., Excel)
e

Back Up a Database
Backing up a database 7-2
se
r

Compact and Repair Databases


Using Compact and Repair 7-3
fe
ea
Pl
Re

Appendix B: Microsoft Office Specialist Program 341


NOTES

rial
a te
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re

342 Microsoft® Office Access 2003 - Level 1


LESSON
LABS

al
LESSON LABS

ri
te
Due to classroom setup constraints, some labs cannot be keyed in sequence immediately fol-
lowing their associated lesson. Your instructor will tell you whether your labs can be practiced
immediately following the lesson or whether they require separate setup from the main lesson
content. Lesson-level lab setup information is listed in the front of this manual in the course

a
setup section.

y
LESSON 1 LAB 1

op
eM
tC
Examining the Microsoft Northwind.mdb Database
Activity Time:
10 minutes
No
c
Data Files:
• Northwind.mdb
n
Do

Scenario:
The consultant that installed your Access application and developed the company’s databases
e

has suggested to your manager that you practice using the program before actually working
with the company’s real data. He suggested opening and touring the Microsoft Northwind.mdb
database, which comes as part of the application.
se
r
fe

1. If necessary, launch Access.


ea

2. Search for and locate the Northwind.mdb database.

Open the Northwind database and display the Database window. Close the task
Pl

3.
Re

pane. At the Welcome screen, click OK. Close the Main Switchboard.

4. Open the Customers table and examine the table in Datasheet view.

5. Examine the table in Design view.

Lesson Labs 343


LESSON
6. Close the table, and then close the database.
LABS

al
LESSON 2 LAB 1
Working with Data in Tables

ri
Activity Time:

te
10 minutes

Data Files:
• UseForms.mdb

a
Scenario:

y
Imagine that you work as a data entry person for the GSC Corporation and you have just

op
eM
received a new customer’s information. Before the customer can place an order they need to
be added to the company’s database. To add the customer, you need to open the UseForms.
mdb database and input the necessary data.

tC
1. In the UseForms.mdb database, use the frmGSCCustomers form to add the fol-
lowing new customer data to the Customers table:
• CustomerID: 22000
No
• CustomerName: Maple River Cleaners
c
• Address: 2 Sharp Stone Way
• City: Hamlin
n

• Region: MN
Do

• Country: US
• Postal Code: 56789
e

• Phone: 567 898 8800


• Fax: 567 898 8801
se
r

2. Close the form.


fe

3. In the tblCustomers table, verify that the new customer’s data was added
ea

correctly.

4. Close the table and the database; do not save your changes.
Pl
Re

344 Microsoft® Office Access 2003 - Level 1


LESSON
LESSON 3 LAB 1 LABS
Examining the Northwind.mdb Database Relationships

al
Window
Activity Time:

i
10 minutes

r
Data Files:

te
Northwind.mdb

Scenario:
To reinforce your understanding of table links and relationships, the consultant also suggested
that you examine the Northwind.mdb database’s Relationship window and open several tables

a
and subdatasheets to familiarize yourself with their use in a larger database environment.

y
op
1.

2. Display the Relationships window.


eM
Search for and locate the Northwind.mdb database.

tC
3. Right-click in the header of the Orders table and choose Table Design to display
the table in Design view.

4. Display the table in Datasheet view.


No
c
5. Open several of the Customer record’s subdatasheets to examine the orders
they have placed.
n
Do

6. Close the subdatasheets, close the table, close the Relationships window, and
then close the Database window.
e
se
r
fe
ea
Pl
Re

Lesson Labs 345


LESSON
LABS LESSON 4 LAB 1
Creating and Modifying the Design of Select Queries

al
Activity Time:
15 minutes

i
Data Files:

r
• BookBiz.mdb

te
Scenario:
Imagine that you run a book bindery business. Your database includes tables that store infor-
mation about each book, each order placed, and each customer. In this activity, you will create
several queries to answer business-related questions, such as the following:

a
• Which books have sold?

y
• Which book orders have been for 250 or more books?

op
How many sales transactions were recorded by the sales rep whose ID is EN1-22?


eM
Which transactions did sales rep EN1-22 have on August 16, 2001?
How much did each individual book order cost?

tC
The Solution BookBiz file is a completed file of this activity. You can compare your results to this file.

No
1. Open the BookBiz database.
c
2. Imagine that you would like to see a listing of which books have sold. Use the
Query Wizard to display data from both the BookOrders and Books tables. From
n

the BookOrders table, add the SalesId, Date, and Quantity fields. From the Books
Do

table, add the BookNumber and BookPrice fields.


e

3. Indicate that you want to see the Detail records.

Give your query the title of MyBookSales


se

4.
r
fe
ea
Pl
Re

346 Microsoft® Office Access 2003 - Level 1


LESSON
5. Run the query.
LABS
6. Next, suppose you want to view only a portion of the records. First, you want to
view all of the orders that were for a quantity of 250 or greater. Use criteria to
select just the records you want. Record the number of records that satisfy

al
this criteria: _____________.

You want to view all the records for the sales rep whose ID number is EN1-22.
Enter the appropriate criteria. Record the number of records that satisfy this
criteria: _____________.

i
Next, you want to know how many of the sales records for sales rep EN1-22

r
occurred on 8/16/2001. Enter the appropriate criteria. Record the number of
records that satisfy this criteria: _____________.

te
Save your revised query as MySelectBookSales and close it.

7. Next, you’ll create a query that answers the question, “How much did each indi-
vidual book order cost?” Create a query in Design view that includes the

a
BookOrders table and the Customers table. Add the CustomerName, Quantity,

y
and BookNumber fields to the design grid. Sort the query records by

op
CustomerName. Run the query and view the results.

8.
eM
Return to the query’s Design view and add the Books table to the query. From
the Books table, add the Title field to the design grid.

tC
9. Create a field that calculates the total price each customer owes for each book
order. (Multiply the Quantity field from the BookOrders table by the BookPrice
field from the Books table.) Change the default calculated field name to
OrderCost
No
c
10. Run the query and, before closing it, save it as MyBookCosts
n

11. Close the BookBiz database.


Do
e
se
r
fe
ea
Pl
Re

Lesson Labs 347


LESSON
LABS LESSON 5 LAB 1
Creating and Modifying Forms

al
Activity Time:
15 minutes

i
Data Files:

r
• BreadBiz.mdb

te
Scenario:
Imagine that you run a company that supplies bread mixes to gourmet and specialty shops.
You want to create a data entry form that will make it easier to add new customers and refer
to customer orders. You’ll need to include customer information, as well as order details. Use

a
the Form Wizard to quickly create a basic form and then modify the form you created.

y
The Solution BreadBiz file is a completed file of this activity. You can compare your results to this file.

op
1. Open the BreadBiz database.
eM
tC
2. In the BreadBiz database, use the Form Wizard to create a form based on the
Customers and OrderDetails tables. From the Customers table, add all the fields
to the selected field list. From the OrderDetails table, add all the fields to the
selected fields list.
No
c
3. Specify that you want to view the information in the form by Customers.
n

4. Use the Datasheet layout. Choose a form style you like. Save the form as
Do

MyCustomers and save the subform as MyOrderDetails Subform


e

5. Customize the appearance of the form by selecting, sizing, aligning, and mov-
ing controls.
se
r

6. Save the modified form design and view the form.


fe

7. Close the form and close the BreadBiz database.


ea
Pl
Re

348 Microsoft® Office Access 2003 - Level 1


LESSON
LESSON 6 LAB 1 LABS
Creating and Modifying Reports

al
Activity Time:
20 minutes

i
Data Files:

r
• PersonnelBiz.mdb

te
Scenario:
The PersonnelBiz database contains basic data about employees, compensation, departments,
and parking lots. You want to compile some of this data into various reports. You will use the
Report Wizard to create a phone list report based on a query. You will also work in Design

a
view to make some modifications to a report that focuses on the employee payroll.

y
The Solution PersonnelBiz file is a completed file of this activity. You can compare your results to this file.

op
1. Open the PersonnelBiz database.
eM
tC
2. In the upcoming days, the company parking lots are being repaved and you’ll need
to notify employees by calling them as necessary. Use the Report Wizard to cre-
ate a printed phone list report based on the ParkingLot query.
No
• Add the following fields: FirstName, LastName, ParkingLot, and Phone.
c
• View your data by Employees.
• Group the report based on the ParkingLot.
• Sort by the FirstName field in ascending order.
n
Do

• Select the Tabular layout and Corporate style for the report.
• Name the report MyPhoneList
e

• Preview the report.

Close the report.


se
r

3. Suppose you already created another report and want to complete it by enhancing
its appearance. In EmployeePay report’s Design view, apply the Soft Gray
fe

AutoFormat to change the look of the report.


ea

4. You want to add a field that calculates the annual salary. Under the Annual Salary
label control, create a field that multiplies Weekly Hours, Hourly Pay Rate, and
Pl
Re

52. Delete the default label for the control and align the text box control as
necessary. Change the format of the new calculated control so that it prints
the values in Currency format with zero decimal places.

5. Change the format of the text control in the Page Footer section that contains
the Date function from Short Date to Long Date.

Lesson Labs 349


LESSON
6. Save the revised report as MyEmployeePay
LABS

al
LESSON 7 LAB 1
Planning a Simple Human Resources Database

ri
Activity Time:

te
10 minutes

Scenario:
You are responsible for designing your company’s Human Resources database to track employ-
ees and their related information, including personal data, department, pay rate and benefits,

a
and parking lot assignment. Following the database design process, you need to create an

y
appropriate design plan that includes a statement of purpose, a list of appropriate tables, and
the fields in each table with primary and foreign key assignments.

op
eM
The SolutionDatabaseDesign.doc file in the LessonLabSolutions folder is a completed file of this activity. You can
compare your results after each step to this file.

tC
1. Based on the assignment you have been given, write an appropriate statement of
purpose for this database.
No
c
2. After looking at the available sources of data and discussing this project with the
various users and stakeholders, you’ve decided you need to include the following
fields: Name, Address, City, State, Zip, WorkPhone, DateHired, Hours, PayRate,
n

Health, ParkName, ParkFee, and DeptName. Using this field list, organize the
Do

fields into logical tables.


e

3. Using the normalization guidelines, normalize your list of tables by moving,


splitting, or adding fields as necessary. Include any additional fields that will
be needed to uniquely identify each record in each table and to relate the
se
r

tables together.
fe

4. Designate fields to be used as primary and foreign keys for each table.
ea
Pl
Re

350 Microsoft® Office Access 2003 - Level 1


LESSON
LESSON 8 LAB 1 LABS
Creating a Database and Adding Tables

al
Activity Time:
15 minutes

i
Scenario:

r
You have a database design for a simple Human Resources database that stores information
about employees, their pay and benefits, parking lots, and departments. Using this design plan

te
you now need to create the database and its related tables.

a
y
op
eM
tC
The SolutionMyHR.mdb file in the LessonLabSolutions folder is a completed file of this activity. You can compare
your results to this file.
No
c
1. Create and save a new blank Access MDB file named MyHR.
n
Do

2. Using the design plan, use the Table Wizard to create a table named
tblEmployees. Use the Employees sample table in the Business section. After
the wizard is finished, open the table in Design view and set the field size of
e

the DeptCode field to 4.


se

3. Use Design view to create a table named tblPayAndBenefits with the following
r

specifications:
• An EmployeeID field with a data type of Number (Long Integer).
fe


ea

An Hours field with a data type of Number (Byte).


• A PayRate field with a data type of Currency.
• A Health field with a data type of Text and a field size of 100.
Pl

• A ParkCode field with a data type of Number (Long Integer).


Re

Lesson Labs 351


LESSON
4. Use Design view to create a table named tblParking with the following specifi-
LABS cations:
• A ParkCode field with a data type of AutoNumber.
• A ParkName field with a data type of Text and a field size of 50.
• A ParkFee field with a data type of Currency.

al
5. Use Design view to create a table named tblDepartments with the following
specifications:
• A DeptCode field with a data type of Text and a field size of 4.

i
• A DeptName field with a data type of Text and a field size of 30.

r
6. Establish the appropriate relationships between the tables. Enforce referential

te
integrity between them.

a
LESSON 9 LAB 1

y
op
eM
Streamlining Data Entry and Maintaining Data Integrity

tC
Activity Time:
15 minutes

Data Files:
No

c
PersonnelOffice.mdb

Scenario:
n

You have been asked to improve the PersonnelOffice database. You decided to start by modify-
Do

ing the design of the tblPayAndBenefits table to streamline data entry and maintain data
integrity. First, you’ll assign field properties to several fields in the table. Then, using the Input
Mask Wizard, you’ll add a new field to this table to store social security numbers. To further
e

facilitate data entry, you’ll also change the ParkingLotCode field to a Lookup list by using the
Lookup Wizard.
se
r

The SolutionPersonnelOffice.mdb file, located in the LessonLabsSolutions folder, is a completed file of this
activity. You can compare your results to the tblPayAndBenefits table in this file.
fe
ea

1. In the PersonnelOffice database, open tblPayAndBenefits and view the fields


and records.
Pl
Re

2. Change the design of the table so that data entry is required in these three
fields: EmpID, Dept, and Hours.

352 Microsoft® Office Access 2003 - Level 1


LESSON
3. Change the design of the table so that an entry in the Hours field is valid only
if it is over 15. If a value of 15 or less is entered, display a text message that
reads: Number of hours worked must be greater than 15.
LABS
4. Change the design of the table so that the PayRate field has a default value of

al
11.

5. In this same table, add a new Text field for SocialSecurityNumber. Use the
standard input mask for social security numbers.

i
6. Create a Lookup column for the ParkingLotCode field. Specify that the Lookup

r
list be based on the values in tblParkingInfo. Display the ParkingLotCode and
ParkingLot fields as columns in the Lookup list. Store the value from the

te
ParkingLotCode field.

7. In Datasheet View, enter values in a new record. Experiment by leaving some


values null where they are required. Attempt to move to the next record and
respond to the error messages, as necessary.

a
y
op
LESSON 10 LAB 1
eM
tC
Finding Data with Filters and Joins No
Activity Time:
c
15 minutes

Data Files:
n
Do

• GourmetShop.mdb

Scenario:
e

You run a Gourmet Foods Shop that supplies gourmet foods to other retailers. When reviewing
your product line and pricing structure, you need to create and apply filters to display only the
se
r

data of interest to you: only the Salad Dressing products; only the products with a price of
$6.50; only the products that are either Grilling Sauces or have a price of $6.00; and only
those orders from customer number 245 after 8/31/2001. You also need to display related data
fe

from multiple tables so you will use query joins to display the products ordered with the
ea

related Rep and OrderID number for each order. You also need a query that displays the
OrderID, Quantity, and Customer names for each order that included a Grilling Sauce product.
Pl
Re

The SolutionGourmetShop.mdb file, located in the LessonLabsSolutions folder, is a completed file of this activity.
It includes the finished queries for this activity

1. Open the GourmetShop database. Open the tblProducts table.

Lesson Labs 353


LESSON
2. Use a Filter By Selection to display only those products that are Salad
LABS Dressings. Remove the filter. Your results should include six records.

3. Use a Filter By Selection to display only those products with a price of $6.50.
Remove the filter. Your results should include three records.

al
4. Use a Filter By Form to display only those products that are either Grilling
Sauces or have a price of $6.00. Remove the filters and close that table. Your
results should include five records, as one product fits both criteria.

i
5. Open tblOrders. Use an Advanced Filter to display orders by customer number

r
245 after 8/31/2001. Then remove all filters. Your results should include 13
records.

te
6. Create a query named qselRepProducts that for each Order displays the Rep
number, the Order Number, the Quantity, and the Product name.

a
7. Create a query named qselGSCustomers that displays the OrderID, Quantity,
and Customer names for each order that included a Grilling Sauce product.

y
Your results should include 143 records.

op
eM
tC
LESSON 11 LAB 1 No
Creating Flexible Queries
c
Activity Time:
15 minutes
n
Do

Data Files:

e

MusicShop.mdb

Scenario:
se
r

You are in charge of training at The Music Shop. You keep track of the courses offered to
employees, the employees who have registered for the courses, and available rooms by using
fe

the MusicShop database. You have decided to improve your queries by making them flexible.
ea

First, you want to know how many students are registered for each course; and, beyond that,
you want to see the top five courses, in terms of students enrolled. Second, you want to be
able to enter a student ID and get a listing of all the courses for which that student is
registered.
Pl
Re

The SolutionMusicShop.mdb file, located in the LessonLabsSolutions folder, is a completed file of this activity. It
includes the finished queries for this activity.

354 Microsoft® Office Access 2003 - Level 1


LESSON
1. Open the MusicShop database. Review the tables to become familiar with the LABS
data they contain.

2. Open qselCourseRegistration, which shows students who are registered for each

al
course.

3. In the query results, show the count of students registered for each course.

i
4. Sort the datasheet so that the highest count is displayed first.

r
5. Display the records for only the top five courses according to the count value.

te
6. Save the revised query as qselMyTop5Courses.

7. Open qselStudentRegistration which lists student information along with courses


they are registered for.

a
y
8. Change this into a parameter query that prompts for student ID.

op
9. Save the revised query as qselMyStudentRegistration.eM
10. Test the query with sample student IDs (for example, 1640 or 4944).

LESSON 12 LAB 1 tC
No
c

Creating a Form that Combines Data from Two Tables


n
Do

Activity Time:
e

15 minutes

Data Files:
se
r

• TrainingCenter.mdb
fe

Scenario:
ea

As head of training at The Music Shop you use the TrainingCenter database to track students
and courses. You need a quick way to look up course attendees by course and modify their
addresses and phone numbers. You will create a form that includes basic course information,
Pl
Re

along with a subform that displays data about the students registered for that course. You will
also enhance the appearance and usability of the form by adding a title, graphic elements, and
a command button that enables a user to find a record.

The SolutionTrainingCenter.mdb file, located in the LessonLabsSolutions folder, provides examples of possible
solutions for the main form and subform for this activity.

Lesson Labs 355


LESSON
LABS 1. In the TrainingCenter database, use the Form Wizard to create a form with a
subform.

2. To create the main form use the Form Wizard. Select tblCourseSchedule as the

al
data source and choose fields for the main form including CourseCode,
StartDate, Instructor, and other relevant course data. Save the form as
frmMyCourseSchedule.

i
3. With your new form open in design view, create the subForm using the Subform/
Subreport Wizard. Select qselStudentAttendance as the data source and

r
choose fields for the subform including LastName, FirstName, Address,
HomePhone, and others as desired. Use the CourseScheduleID field as the link

te
field. Save the subform as fsubMyStudentSubform.

4. Enhance the appearance of the form by adding a title and using the line and
rectangle tools to set off and group controls.

a
5. Add a command button to search for a record and name it Find Record.

y
op
eM
LESSON 13 LAB 1
tC
Customizing Your Reports
No
c
Activity Time:
20 minutes
n

Data Files:
Do

• ClothesShop.mdb
e

Scenario:
You work for a small clothes manufacturing business and you use the ClothesShop database to
se
r

track customers, products, and orders. You need to create a report that details customer order
information. The report will be based on a query called qselCustomerOrders that draws data
from several tables in this database. In your report, include all the fields from the query and
fe

group the customers by state. Under each state, you’ll also want to show totals for quantity
ea

and order totals for that state. For convenience, you’ve been asked to show the quantity sold
totals for each date at the end of this report.
Pl
Re

The SolutionClothesShop.mdb file, located in the LessonLabsSolutions folder, provides an example of a possible
solution for this activity.

356 Microsoft® Office Access 2003 - Level 1


LESSON
1. Open the ClothesShop database. Use the Report Wizard to create a new report LABS
based on qselCustomerOrders query. Include all of the fields in this report.

2. Rather than grouping by ProductID, group customers by State. Within each

al
grouping, sort the customers by the OrderDate.

3. Include summary values to total Quantity and OrderTotals.

i
4. Lay out the report in Landscape orientation. Choose a format and style for the
report. Use an appropriate title for the report, such as rptCustomerOrders.

r
5. Identify some of the things that you can improve about your data layout,

te
depending on which report style you chose.

6. Fine-tune the report design by customizing the Caption, Text Align, and Can
Grow properties of the controls that call for those specifications. Adjust the

a
whitespace and page breaks, as necessary, to improve the layout.

y
7. Using the Subform/Subreport Wizard, add a subreport to the Report footer that

op
eM
will display the total quantity sold each day. Use qselQuantityByDate as the
datasource and do not define a link field between the subreport and the main
report. Fine tune its appearance and placement on the main report as desired.

LESSON 14 LAB 1 tC
No
c
Using Access Data in Other Office Programs
n
Do

Activity Time:
15 minutes
e

Data Files:
se
r

• ClothesShop.mdb
fe

Scenario:
ea

At The Clothes Shop, your colleagues have requested that you provide the total products
ordered data as a Word document. They said they would also like to see the data as a pie chart
as well. And they will need the data in text format in order to later import it into another
application.
Pl
Re

The SolutionMyTotals.xls, SolutionMyTotals.doc, and SolutionMyTotals.txt files, located in the


LessonLabsSolutions folder, are completed solutions for this activity.

Lesson Labs 357


LESSON
LABS 1. Open the ClothesShop database and review the qselTotProdOrd query and
rptTotProdOrd reports.

2. Publish rptTotProdOrd with Word. Save the Word document as MyTotals.doc.

al
3. Analyze the qselTotProdOrd query in Excel.

4. Create a 3-D exploded pie chart as a new sheet.

i
Save the Excel spreadsheet as MyTotals.xls.

r
5.

te
6. Add the chart to the end of the MyTotals Word document by choosing Insert→
Object in Word. Select the Create From File tab and browse to the MyTotals.
xls file.

7. Export the data in qselTotProdOrd to a text file. Delimit the data with a

a
semicolon.

y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re

358 Microsoft® Office Access 2003 - Level 1


SOLUTIONS
SOLUTIONS

al
Lesson 1

i
Activity 1-1

r
1. What are some examples of collections of data that you use in your personal life?

te
Answers may include a cookbook, a TV program guide, mail-order catalogs, and a house-
hold inventory.

2. What are some examples of collections of data that you use in your job?

a
Answers may include personnel records, customer or vendor lists, and purchasing

y
information.

op
3. eM
Which of the following is representative of a relational database?
a) Note card
✓ b) Library file system

tC
c) Index in a book
d) Glossary in a book

4. Which of the following is not an advantage of the relational database?


No
a) Flexibility
c
b) Simplicity
✓ c) Redundancy
n

d) Ease of management
Do

e) Power
e

Activity 1-2
se
r

4. By default, which of the following toolbar options are activated when you launch the
Access application?
✓ a) New
fe
ea

✓ b) Open
c) Save
d) Cut
Pl
Re

✓ e) Microsoft Office Access Help


f) Undo
g) Code
✓ h) File Search

Solutions 359
SOLUTIONS
Activity 1-3

4. Match the type of Access object with the description of the function(s) that it
performs.

al
b report a. Displays data for editing.
d table b. Arranges data for printed output.
c query c. Displays selected data.
a form d. Stores data on a single topic.

i
Activity 1-4

r
4. What is the data type of the EmployeeID field in tblEmployees?

te
a) Currency
b) Date
c) Number
✓ d) Text

a
y
5. What is the data type of the DeptCode field in the tblEmployees table?
a) Currency

op
b) Date
✓ c) Number
eM
tC
d) Text

6. What is the field size of EmployeeID?


a) 2 characters
✓ b) 4 characters
No
c
c) 20 characters
d) 20 digits
n
Do

Lesson 2
e
se

Activity 2-1
r
fe

2. How many fields are displayed in the form?


ea

Nine.

3. What field is highlighted by default?


Pl
Re

CustomerID.

4. How many records are in the table?


Fourteen.

360 Microsoft® Office Access 2003 - Level 1


SOLUTIONS
Activity 2-2

3. How many records are in the table?


a) 12

al
b) 13
c) 14
✓ d) 15

i
Activity 2-3

r
4. How is the table sorted?

te
✓ a) By OrderID
b) By ItemNum
c) By Quantity

a
y
Activity 2-6

op
2. eM
Was it necessary for any of the tables to be open for the report to run?
No.

tC
6. Did the information that appeared in the report come from a single table?
No. It came from more than one table.

7. Why was it possible for the report to draw information from more than one table?
No
Because there is a field in both tables that can be related. This shows the benefit of using
c
a relational database application such as Access.
n
Do

Lesson 3
e

Activity 3-1
se
r

2. According to the Relationships window, how many tables are connected in this data-
base?
fe

a) One
ea

b) Three
✓ c) Five
Pl

d) Seven
Re

3. How many tables have more than one link to them?


a) One
✓ b) Two
c) Three

Solutions 361
SOLUTIONS
d) Four

4. How many have more than two links?


✓ a) One
b) Two

al
c) Three
d) Four

5. In the Relationships window, to which table(s) is the tblNotes table linked?

i
✓ a) tblComputers

r
b) tblDepartments

te
c) tblEmployees
d) tblManufacturers
e) tblNotes

a
Activity 3-2

y
2. In tblDepartments, what type of key is DeptCode in the tblDepartments–tblEmployees

op
relationship?
✓ a) Primary key
b) Foreign key
eM
tC
c) Primary and foreign key

3. In tblEmployees, what type of key is DeptCode in the tblDepartments–tblEmployees


relationship?
a) Primary key
No
c
✓ b) Foreign key
c) Primary and foreign key
n

4. In the tblComputers–tblNotes relationship, in which table is AssetTag a primary key?


Do

a) tblComputers
b) tblNotes
e

c) Neither
✓ d) Both
se
r
fe
ea
Pl
Re

362 Microsoft® Office Access 2003 - Level 1


SOLUTIONS
Lesson 4
Activity 4-1

al
3. How many records are now displayed?
a) 7
b) 12

i
✓ c) 19

r
d) 25

te
Activity 4-3

2. How many records are displayed?


a) 11

a
b) 21

y
✓ c) 23

op
7.
d) 32

How many records are displayed?


a) 5
eM
tC
✓ b) 10
c) 15
d) 20
No
c
Activity 4-4
n

1. What is the answer to: 4 + (3 * 5)?


Do

a) 12
b) 14
e

c) 17
✓ d) 19
se
r

e) 35
fe

2. What is the answer to: (4 + 3) * 5?


ea

✓ a) 35
b) 12
c) 19
Pl
Re

d) 17
e) 60

Activity 4-5

3. What is Rob Abbott’s weekly pay?

Solutions 363
SOLUTIONS
a) 56
b) 250
✓ c) 760
d) 2,500

al
Lesson 5

ri
Activity 5-1

te
1. When designing a form, who should you keep foremost in mind?
a) Your boss
b) Your co-worker

a
✓ c) The user

y
d) The consultant

op
2. eM
In Design view, which section of a form would typically contain page numbering infor-
mation?
a) Header

tC
b) Detail
✓ c) Footer

3. Which of the Form Wizard layout styles shows multiple records per page?
a) Columnar
No
c
✓ b) Tabular
✓ c) Datasheet
n

d) Justified
Do

Activity 5-2
e

3. True True or False? The number of fields in the form is the same as the number of
fields in the table.
se
r

4. True True or False? New records can be added to the table with the AutoForm you
created.
fe
ea

7. True True or False? The subdatasheet will expand if you click the plus sign (+) in
the form.

Activity 5-5
Pl
Re

2. Which text box controls appear to be too small?


✓ a) Address text box
b) Postal Code label
✓ c) Postal Code text box

364 Microsoft® Office Access 2003 - Level 1


SOLUTIONS
d) Region label

Lesson 6

al
Activity 6-1

i
2. What features does the printed datasheet have?

r
The name of the data source and the current date would be printed at the top of each
page. The column headings would also be printed. The data is easy to read with each

te
record arranged horizontally in a grid.

3. What disadvantages are there to printing the query datasheet?


There are no totals, and there is no formatting. In addition, the data is split across two
pages.

a
y
5. How does the AutoReport compare to the printed datasheet?

op
The fields are arranged in a vertical column. An extra blank line separates each record.
eM
There’s no heading, date, or page numbers. The report is eight pages long.

Activity 6-3

tC
2. Where does the Report Header print?
✓ a) On the first page of the report.
b) On the last page of the report.
No
c
c) At the bottom of each page.
d) At the top of each page.
n

3. What information is in the Report Header?


Do

a) Name and Address


✓ b) Title and Date
e

c) Page Number
d) Date and Time
se
r

4. What information does the Page Footer provide?


fe

a) Date
ea

b) Time
c) Name
✓ d) Page Number
Pl
Re

Activity 6-7

2. Why are there blank pages between the printed pages?


a) There is not enough text on the pages.
b) The font is too large.

Solutions 365
SOLUTIONS
c) The margin setting is too narrow.
✓ d) The margin setting is too wide.

4. Why are these settings causing the blank pages?


The report is in Portrait orientation, which means the page is 8.5 inches wide. The report

al
width of 6.75 inches plus 1 inch left and right margins exceeds this width and causes the
blank pages.

What do you think your options might be for fixing this problem?

i
You could:

r
Decrease the width of the lines and then decrease the width of the report in Design
view.

te
• Change the report to Landscape orientation.
• Make the margins smaller.

a
Lesson 7

y
op
Activity 7-1
eM
tC
1. Place the steps of the relational database design process in the correct order.
5 Enter sample data, review for possible maintenance problems, and revise the table
design as necessary.
4 Organize the fields into tables.
No
c
3 Make a preliminary list of fields.
1 Identify the purpose of the database.
n

6 Identify primary and foreign keys for use in relating the data in the tables.
Do

2 Review the existing data.


e

Activity 7-2
se
r

1. Given the preceding scenario, write a statement of purpose for the new database.
Answers will vary somewhat, but should be something like: “The database will hold infor-
fe

mation on the company’s inventory of computers and their assignment to employees.”


ea

2. What is wrong with this statement of purpose: “The database will have tables for com-
puters, personnel, manufacturers, product sales, salaries, and company suggestions.”
✓ a) The statement of purpose should not attempt to list specific tables.
Pl
Re

✓ b) The statement of purpose is too broad.


c) There is nothing wrong with this statement of purpose.

3. What is wrong with this statement of purpose: “The database will allow the user to
generate reports that list the computers used by each employee, as well as queries
that sort records by the date the computer was purchased and the manufacturer of the
computer.”

366 Microsoft® Office Access 2003 - Level 1


SOLUTIONS
✓ a) It doesn’t discuss the scope of information to be included in the database.
✓ b) It doesn’t mention or imply how its information will be related.
✓ c) It discusses specific features (queries and reports) that you would like to see
provided.

al
d) There is nothing wrong with this statement of purpose.

Activity 7-3

i
1. What pieces of data from the sample ticket do you think should be included in your
database?

r
✓ a) Date computer acquired

te
✓ b) Manufacturer name
✓ c) Asset tag number
✓ d) Department of employee

2. What other sources of data might you use for determining what data should be

a
included in the database?

y
Answers will vary, but might include annual departmental computer inventory reports,

op
interviews with selected members of various departments, or interviews with potential
users of the database.

Activity 7-4
eM
tC
1. What additional data will you need to include about each employee?
✓ a) Name
b) Salary
No
c
c) Date of birth
✓ d) Computers assigned
✓ e) Manager of employee
n
Do

2. What additional fields will you need to include in the database to enable the Technical
Services manager’s weekly reports and the Finance manager’s monthly report?
e

✓ a) Warranty coverage
✓ b) Purchase price
se
r

c) Software games included


d) Number of current files on the computer
fe
ea

Activity 7-5

1. Based on the information you have now, which two tables would be minimally required
Pl
Re

for this database?


a) Computers and Notes
✓ b) Computers and Employees
c) Computers and Departments
d) Employees and Departments

Solutions 367
SOLUTIONS
2. With only these two tables as options, which fields would go in an Employee table?
✓ a) Name
b) Computer manufacturer
✓ c) Department

al
d) Warranty coverage

3. Of the remaining fields, six of them could go in a Computers table.

i
Activity 7-6

r
1. What should be done with the EmployeeName field to normalize the data?

te
a) It should list the last name first, with a comma and then the first name.
✓ b) It should be broken up into two separate fields, one for the first name and one for
the last name.
c) It should include the last name data only.

a
d) Nothing, it is fully normalized as it is.

y
2. True or False? Since the Department field holds repeated values, a Departments table

op
should hold those values.
✓ True
False
eM
tC
3. True or False? Since not all records have an entry in the Note field, strict adherence to
normalization guidelines would require the note field be moved to a separate table.
✓ True
False
No
c
4. What can be done to normalize the data in the Manufacturer field?
a) The entries should be in all lowercase.
b) The entries should be in all uppercase.
n
Do

✓ c) Since it has repeated entries, there should be a Manufacturers table to hold that
data.
d) Nothing, it is fully normalized already.
e

5. If you chose to not normalize the data in the Manufacturer field in this way, that would
be an example of denormalizing the data.
se
r

6. What needs to be done to normalize the Warranty field’s data?


fe

a) It should be a text field.


ea

b) Because some check boxes are not checked, that data belongs in a separate table.
✓ c) Nothing, it is fully normalized already.
Pl
Re

Activity 7-7

1.

368 Microsoft® Office Access 2003 - Level 1


SOLUTIONS
The Address field does not contain the smallest meaningful values.

2. Based on the data shown, which additional fields would you need to add to normalize
this data?

al
✓ a) City
✓ b) State
✓ c) Zip Code
d) Country

ri
3.

a te
What data normalization problems does this table have?

y
a) The LastName field appears before the FirstName field.

op
eM
✓ b) There is a repeated group of Project fields.
✓ c) There is a repeated group of Time fields.
d) The sets of Project and Time fields are not adjacent.

tC
4. Why would these be data maintenance problems?
It would be difficult to total the amount of time devoted to a specific project. Also, if a
single person was assigned to a third project, you would have to add two more fields to
No
the table.
c
5. True or False? This data could be normalized by separating it into two related tables:
one for the LastName and FirstName data, and one for the Project and Time data.
n

✓ True
Do

False

6.
e
se
r
fe
ea

The Phone field contains unnecessarily repeated values that rely on a non-key field.
Pl
Re

7. What data maintenance problem does this cause?


You would need to edit the phone numbers in more than one record.

8. True or False? You could normalize this data by moving the ProjectManager and Phone
fields into a second but related table.
✓ True

Solutions 369
SOLUTIONS
False

Activity 7-8

al
1. Which field in the Employees table would be best as a primary key?
a) EmployeeLastName
b) EmployeeFirstName
c) DeptCode

i
✓ d) A new field, EmployeeID

r
2. In which table should the EmployeeID field appear as a foreign key field?

te
a) Departments
✓ b) Computers
c) Manufacturers
d) Notes

a
y
3. The DeptCode field should be the primary key field for the Departments table.

op
4.
eM
Which table should have DeptCode as a foreign key field?
✓ a) Employees
b) Computers

tC
c) Manufacturers
d) Notes

5. The AssetTag field can serve as a primary key field for both the Computers and Notes
tables.
No
c
6. If you were to add a ManufacturerID field to serve as the primary field for the Manufac-
turers table, what other table should have a ManufacturerID field as a foreign key?
a) Employees
n

b) Departments
Do

✓ c) Computers
e

d) Notes
se
r

Lesson 8
fe
ea

Activity 8-1
Pl
Re

2. The initial description of this template looks promising. Which of your planned data-
base tables seem to match to the information listed?
✓ a) Employees
✓ b) Departments
✓ c) Manufacturers
✓ d) Computers

370 Microsoft® Office Access 2003 - Level 1


SOLUTIONS
e) Notes

Activity 8-4

al
2. What is the default Field Size for the AutoNumber data type?
a) Byte
✓ b) Long Integer
c) Decimal

i
d) Currency

r
Activity 8-5

te
2. Referring to your database diagram, you see that the next field, ManufacturerID is a
foreign key field. What data type and field size must it therefore have?
a) AutoNumber and Byte

a
b) Number and Byte

y
c) AutoNumber and Long Integer

op
6.
✓ d) Number and Long Integer eM
Because PurchasePrice is a field with financial data, what datatype would likely be
better than number?

tC
a) Text
✓ b) Currency
c) Yes/No No
d) Memo
c
Activity 8-7
n

3. The tables in the Relationships window are arranged in alphabetical order by default.
Do

5. What sort of relationship is there between the tblDepartments and tblEmployees tables
and why?
e

a) There is a one-to-one relationship because for every department record there will be
one employee record.
se
r

✓ b) There is a one-to-many relationship because for each department record there could
be many employee records.
fe

c) There is a one-to-many relationship because for each employee record there could
ea

be many department records.

7. In the Edit Relationships window, what kind of relationship is given as the Relationship
type?
Pl
Re

a) One-to-One
✓ b) One-to-Many
c) Many-to-One
d) Many-to-Many

9. What sort of relationship is there between the tblComputers and tblNotes tables

Solutions 371
SOLUTIONS
and why?
✓ a) There is a one-to-one relationship because for each computer record there will be at
most one note record, and vice-versa.
b) There is a one-to-many relationship because for each computer record there could
be many note records.

al
c) There is a one-to-many relationship because for each note record there could be
many computer records.

ri
Lesson 9

te
Activity 9-1

7. A default value of 40 is displayed in the Hours field.

a
y
op
Lesson 10
Activity 10-1
eM
tC
2. How many records matched the filter?
a) 13
No
✓ b) 14
c
c) 15
d) 20
n

5. How many records matched this filter?


Do

a) 3
e

b) 5
✓ c) 6
se

d) 7
r

7. How many records match either salesperson en1-20 or have a country of Canada?
fe

a) 6
ea

✓ b) 8
c) 10
Pl

d) 12
Re

Activity 10-2

3. How many records match both criteria?


a) 2

372 Microsoft® Office Access 2003 - Level 1


SOLUTIONS
b) 3
c) 4
✓ d) 5

al
Activity 10-3

2. 2900 records are in the query results.

i
3. True or False? The reason this many records appear is because no join between the
tables has been established, so each record from tblBookProject is combined with each

r
record from tblBookSales.
✓ True

te
False

4. What fields should you use to join these tables?


a) Part# and OrderID
✓ b) Part# and PartNumber

a
y
c) BookTitle and OrderID
d) BookTitle and PartNumber

op
6.
eM
Only books with sales are displayed. How many records for such books are in the
result?
a) 29

tC
b) 90
✓ c) 100
d) 2900
No
c
8. All the records from tblBookProject are displayed. Only the matching records from
tblBookSales are displayed. How many results are displayed?
a) 29
n

b) 100
Do

✓ c) 108
d) 2900
e

Activity 10-4
se
r

4. True or False? Books that lack sales will not appear because this is an equi-join and not
fe

a left-outer join.
ea

✓ True
False
Pl
Re

Activity 10-5

1. In order to design a query to display supervisor names for each employee, which two
fields in tblSupervisors will need to be related?
a) Id and LastName
✓ b) Id and SupervisorId

Solutions 373
SOLUTIONS
c) Dept and SupervisorId
d) LastName and SupervisorId

al
Lesson 11
Activity 11-1

ri
2. 14 records are included in the query results.

te
4. What order are the top five records displayed in?
a) By total sales, ascending
b) By total sales, descending
✓ c) Alphabetical

a
d) No particular order

y
op
Activity 11-2 eM
2. There are 100 total records returned by this query.

tC
3. There are 3 records with a customer of Allendale Books and a book title of “Improving
Your Tennis Game.”

6. There are now 81 total records displayed by the query.


No
7. There is now 1 record with a customer of Allendale Books and a book title of “Improv-
c
ing Your Tennis Game.”

Activity 11-4
n
Do

4. How many records satisfy the three criteria you set with parameters?
a) 10
e

b) 12
✓ c) 15
se
r

d) 20
fe

Activity 11-5
ea

2. True or False? For books with part numbers that begin with 31 or 34, the prices range
from $25.95 to $45.95.
Pl
Re

✓ True
False

4. There are 12 records that have a part number that begins with either 31 or 34.

7. What is the new range of prices for books with part numbers beginning with 31 or 34?
a) $25.95 to $45.95

374 Microsoft® Office Access 2003 - Level 1


SOLUTIONS
✓ b) $27.25 to $48.25
c) $30 to $50

8. What would happen to the values in the BookPrice field if you ran the query again?
a) Nothing, they would remain the same because they have already been increased by 5

al
percent.
✓ b) The values in the BookPrice field in the underlying table would again be increased by
5 percent.
c) The previous prices would be reinstated: the 5 percent increase in price would be

i
revoked.

r
d) An error would result.

te
Activity 11-6

4. 4 records are displayed by this query.

7. The tblBookProject table had 26 records before the append query was run. How many

a
records does it have now?

y
a) 26

op
b) 29
✓ c) 30
d) 33
eM
Lesson 12
tC
No
c
Activity 12-5
n

5. True or False? Although the CustomerID field is not found in the subform, because the
Do

tblCustomer and tblBookSales are related, the data in the CustomerID field in the main
form will be used for the CustomerID data in the related table as well.
e

✓ True
False
se
r
fe
ea
Pl
Re

Solutions 375
SOLUTIONS
Lesson 13
Activity 13-1

al
5. What are some things you could improve about the data layout?
Captions, widths, and alignment could be improved.

i
6. What are some things you could improve about the pagination? For example, is there a
lot or a little white space? Where do pages break?

r
There is too much white space under the text box controls in the Detail section. Data is
grouped by book title. Groups are broken from one page to the next. It would be better if

te
you could control where the pages break.

7. What are some things you could improve about the summary data in each group and
the end of the report?
The summary information for each group indicates the number of detail records in the

a
group and the sum of the quantity sold. You might want to add other group information,

y
such as the quantity in stock and on order, and a total quantity. The grand total figure is
on the last page of the report; it indicates the grand total of the number of books sold.

op
eM
Lesson 14

tC
Activity 14-3 No
c
3. True or False? The headings for each column of data were not exported with the
values.
✓ True
n

False
Do

4. True or False? When a value was empty (null) a space is placed between the two semi-
colons that delimit this field from the previous and next fields.
e

True
✓ False
se
r

5. In order for this exported data to be optimally used by another application, which
character must not appear in the data?
fe

a) Comma
ea

✓ b) Semicolon
c) Space
Pl
Re

d) Ampersand

376 Microsoft® Office Access 2003 - Level 1


INDEX

al
INDEX

ri
A Caption control property, 285, 286
Access environment, 5 columnar form, 73

te
Access objects, 8 combo boxes, 254, 256
action queries Command Button Wizard, 266, 267
adding, 232, 236, 239 command buttons, 266
append queries, 230 adding, 267

a
creating, 231, 232, 235, 236, 239 creating, 266

y
defining, 229 comparison operator, 56
delete queries, 231 conditional operator, 56

op
identifying types, 231
update queries, 229
Additional Wizard, 263
eM
adding to a query, 57
control, 82
aligning, 88, 91

tC
adjusting line spacing, 291, 292 modifying properties of a, 110
Advanced Filter/Sort technique, 192, 193, 196 moving a, 89
aliases, 209 selecting a, 82, 91
append queries, 230, 235, 236 sizing a, 85, 91
arithmetic calculation, 63 spacing, 88, 91
No
c
arithmetic operator, 61 control properties, 285, 286
order of operation, 61 control source, 307
AutoForm, 72, 73 Control Wizards, 245, 254, 256, 257, 262, 263,
n

creating an, 75 279


Do

AutoFormat, 113 controls


AutoNumber field, 158 adding a combo box, 256, 257
e

AutoReport, 96 adding a list box, 256


creating an, 96 adding an option box, 262, 263
combo box, 254
se
r

B list box, 254


Between... And operator, 224, 227 option box group, 255
fe

blank databases creating, 152


ea

creating, 152 criteria, 193, 194, 196, 225, 227


blank values, 134 entering, 223, 224, 225, 227
Boolean using, 223, 224, 225, 227
Pl
Re

See: conditional operator cross-product queries, 201


business rules, 131 Current Record Indicator, 12

C D
calculated field, 63, 108 data
Can Grow control property, 285, 286 creating an Excel chart, 317
Can Shrink control property, 285 exporting, 317, 321, 322, 323

Index 377
INDEX
merging Access data with Word, 326 removing, 194
publishing Access data as Word document, 315 using criteria, 193, 194, 196
data relationships Force New Page property, 290
many-to-many, 164 foreign key, 41, 42
one-to-many, 164 foreign key fields, 140

al
one-to-one, 163 form, 8, 18
data types, 13 columnar, 73
database, 2, 152 creating, 78
creating, 152 creating a, 72, 73, 75

i
opening, 9 datasheet, 73

r
relational, 2 Design view, 74
viewing, 9 Detail section, 74

te
databases Footer section, 74
creating, 144, 145 Header section, 74
determining its purpose, 122 justified, 73
eliminating potential problems, 133 modifying a, 91

a
existing data, 124 navigating in, 19
datasheet form, 73 tabular, 73

y
Datasheet view, 12 form control, 82

op
delete queries, 231, 239
denormalization, 134
design enhancements, 278
eM
Default Value field property, 172, 174 aligning, 88, 91
moving a, 89
selecting a, 82, 91
sizing a, 85, 91

tC
Design view, 13 spacing, 88, 91
Form Design toolbar, 245
E Form Design view window, 245
existing data Form Wizard, 73
No
reviewing, 124 creating a form, 78
c
exporting, 317, 321, 322, 323 layouts, 73
expression, 61 Format field property, 172, 174
Expression Builder, 62
n

formatting palettes, 246, 248


Do

Formatting toolbar, 245, 246, 248, 279


F
forms
field, 2, 12
e

adding a command button, 267


Field list, 245, 279
designing, 246, 247, 248
field name, 13
se

field names, 132 G


r

field properties, 13, 172, 174 Group Footer section, 291


fe

modifying, 173, 174, 217, 220 Group Header section, 291


ea

setting, 173, 174, 217, 220 grouped controls, 247


Field Size property, 158
filter H
removing a, 28 Height control property, 285, 286
Pl
Re

Filter By Form technique, 192, 193, 194 Hide Duplicates control property, 285
Filter By Selection technique, 192, 193, 194
Filter Excluding Selection technique, 192 I
filters icon, 5
creating an advanced filter/sort, 193 inner joins, 198, 202
finding data, 193, 194, 196 Input Mask field property, 177
Input Mask Wizard, 178, 179

378 Microsoft® Office Access 2003 - Level 1


INDEX
input masks office links
adding, 179 sharing data, 314
creating, 179 one-to-many relationship, 164
defining, 177 one-to-one relationship, 163
option boxes, 255

al
J option groups, 255, 262, 263
join lines, 198, 206 order of operation, 61
creating, 201, 202, 209 outer joins, 199, 202
joins, 198, 199, 205, 206, 208

i
changing the type, 201 P

r
creating, 201, 202, 209 parameter queries
defining, 198 creating, 224, 225, 227

te
removing, 201 defining, 222
query joins running, 224, 225, 227
justified form, 73 prefix, 28
primary key, 41, 42
K primary keys, 139

a
Keep Together property, 290 setting, 154

y
prompt messages, 224
L

op
Like operator, 223, 225, 227
list boxes, 254, 256
logical operator
eM
Properties dialog box, 245, 279

Q
query, 8, 27

tC
See: conditional operator adding a calculated field, 63
lookup lists Select query, 50
creating, 185 Query Design toolbar, 51
defining, 183 query joins, 198, 199, 205, 206, 208
using, 185
No
changing the type, 201
c
Lookup Wizard, 185 creating, 201, 202, 209
defining, 198
M
n

Mailing Label Report Wizard, 307, 308 R


Do

mailing labels record, 2, 12


creating, 307, 308 adding a, 22
e

main forms, 269 calculation on groups of, 67


main reports, 300 deleting a, 22
many-to-many relationship, 164
se

sorting, 25
r

margin settings, 115 updating a, 30


menu bar, 5 record grouping, 280, 281
fe

multiple parameter queries record selector, 12


ea

creating, 227 record sorting, 280, 281


defining, 222 record source, 307
records
Pl

N
Re

appending, 235, 236


naming conventions, 9
deleting, 239
navigation bar, 12
filtering, 193, 194, 196
normalization, 133, 134
grouping, 280, 281
O sorting, 280, 281
objects, 8 updating, 231, 232
recordset

Index 379
INDEX
displaying a, 28 expanding a, 44
referential integrity, 165, 166 finding data in a, 44
relational database, 2, 3 Subform/Subreport Wizard, 270, 271, 301
relational databases subforms, 269, 270
designing, 120 adding, 271

al
determining fields, 128 creating, 270
eliminating potential problems, 133 subreports, 300
relationships between tables, 38 adding, 301
Relationships window, 38, 166 creating, 301

i
Remove Filter button, 194 summary fields, 294, 295

r
removing, 201
report, 8 T

te
adding a calculated field, 108 tab order, 91
adjusting the margins of a, 115 table, 2, 8
AutoFormat a, 113 relationships, 38
components, 104 table names, 132
Table Wizard, 155

a
creating a, 96, 98, 99
Design view, 104 tables

y
modifying controls on a, 110 creating, 153, 155, 157, 158, 160

op
running a, 33
Report Design toolbar, 279
Report Design view window, 279
Report Footer section, 300
eM creating relationships, 165, 166
designating a primary key, 139
enforcing referential integrity, 164, 165, 166
grouping fields, 130, 131

tC
report pagination, 291, 292 joining, 205, 206, 209
Report Wizard, 98, 281 saving, 158
creating a report, 99 using an alias, 209
reports, 291, 292 tabular form, 73
No
adding fields, 295 task pane, 5
c
moving controls, 295 templates, 145
summarizing data, 294, 295 creating a database, 144, 145
Text Align control property, 285, 286
n

troubleshooting, 291
Do

using enhancements, 278, 285, 286 toolbar, 5


Required field property, 172, 174 toolbox, 107, 245, 279
top values, 216, 217
e

S Top Values field property, 217


section selectors, 247 troubleshooting, 291
se
r

Select query, 50
creating a, 53 U
fe

select query properties unbound controls, 247


ea

top values, 216 unique records, 216


unique records, 216 Unique Records field property, 217
unique values, 216 unique values, 216
Unique Values field property, 217, 220
Pl

selection conditions
Re

adding, 57 update queries, 229, 231, 232


self join, 209
V
self joins, 208, 209
Validation Rule field property, 172, 174
statement of purpose, 122
Validation Text field property, 172, 174
subdatasheet, 43
value, 2
collapsing a, 44

380 Microsoft® Office Access 2003 - Level 1


INDEX
W
Width control property, 285, 286
wildcards, 223, 225, 227, 232
wizards, 153, 155
Additional, 263

al
Command Button, 266, 267
Control, 245, 254, 256, 257, 262, 263
Input Mask, 178, 179
Lookup, 185

i
Mailing Label Report, 307, 308

r
Report, 281
setting the primary key, 154

te
Subform/Subreport, 270, 271

Z
Zoom dialog box, 224

a
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re

Index 381
NOTES

rial
a te
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re

382 Microsoft® Office Access 2003 - Level 1

Vous aimerez peut-être aussi