Access Level 1
Access Level 1
a te
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
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
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
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
D. Display Recordsets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
se
Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
r
E. Update Records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
fe
F. Run a Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
ea
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
Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
Selecting Form Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
se
r
A. Create an AutoReport . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
AutoReport . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
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
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
Contents vii
CONTENTS
B. Create an Input Mask . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
Input Masks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
C. Create a Lookup Field. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
al
Lookup List Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
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
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
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
Subreports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300
e
Contents ix
CONTENTS
D. Merge Access Data with a Word Document. . . . . . . . . . . . . . . . . . . . . . . . . 326
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
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
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
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
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
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
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
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
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.
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
b) Simplicity
c) Redundancy
se
r
d) Ease of management
fe
e) Power
ea
Pl
Re
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.
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
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
a
Office Access 2003.
y
In Windows 2000, choose Start→Programs→
op
2.
eM
Examine the menus on the menu
Microsoft Access.
tC
bar. File menu. The commands are similar to
those in other applications.
menus.
se
r
al
inactive menu items.
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
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
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
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
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
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
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
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
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
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.
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
al
fields.
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
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
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
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
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
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
view.
ea
• In addition to displaying table data, forms can include calculations, graphics, and
other objects.
Pl
Re
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
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
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.
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
tblCustomers table.
ea
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.
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.
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
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
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
• Region: NY
• Country: US
se
•
r
2. Display tblCustomers and view the a. Display tblCustomers and locate the new
new record. record.
Pl
Re
al
d) 15
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
database.
fe
ea
Pl
Re
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
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.
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
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.
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
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
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.
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
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
al
to display any existing queries.
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
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
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.
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
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
al
Ballantyne.
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
al
log Box. Select the Replace tab.
i
text box.
r
d. Click Find Next.
te
e. Click Replace.
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.
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
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
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
_______________
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.
a
recorded to verify that they are the
y
same.
op
eM d. Close tblEmployees.
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
1. What types of operations can you perform on a table with an Access form?
Pl
Re
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
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
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
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
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.
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
b) Two
c) Three
fe
d) Four
ea
b) Two
c) Three
d) Four
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
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
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.
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
a) Primary key
b) Foreign key
fe
a) Primary key
b) Foreign key
c) Primary and foreign key
al
d) Both
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.
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
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.
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
al
c. From tblEmployees, record her Employee
ID: _______________.
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.
EmployeeID column.
e
al
c. Click the plus sign in the left column to
display the subdatasheet.
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.
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
rial
a te
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re
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
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
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
al
Query Type Selects the query type.
ri
Show Table Opens the Show Table dialog box.
te
Totals Adds the Totals row to the query in
Design view.
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
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
al
c. Click the View button to return to
Datasheet view.
i
a) 7
r
b) 12
c) 19
te
d) 25
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
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
DateReceived.
ea
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.
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
grid.
e
se
r
fe
ea
Pl
Re
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.)
tC
Operator Value Example
= Equals = 11/29/1961
No
c
< Less than <K
<= Less than or equal to <= 2500
> Greater than >K
n
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
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
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.
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
d. Type >2000
fe
ea
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.
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.
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
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.
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.
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
three records.
ea
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.
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
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.
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
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 application’s built-in operators and functions, build formulas and calculations that are used
with queries and reports.
fe
ea
Pl
Re
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
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
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.
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.
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
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.
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.
it.
b. Click OK.
e
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
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.
b. Press Delete.
4. In the Total row for the WeeklyHours a. Click in the Total row for the
fe
al
c. Run the query.
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.
select 1.
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
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
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
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.
formatted.
Datasheet • Multiple records appear per page.
• Looks and feels like a spreadsheet to the user.
Pl
Re
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
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
b) Your co-worker
c) The user
d) The consultant
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
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
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.
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
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
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.
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
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
9. Enter a title for the form and, if necessary, the subform. Select the view in which
Re
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
AssetTag is selected.
fe
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.
g. Click Next.
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.
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.
TOPIC D
e
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
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.
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
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
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
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
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
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.
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
Sizing controls to be proportionate to their use is a critical design component. There are three
ea
The same options available from the Format menu are available by right-clicking a selected control and
choosing Size from the shortcut menu.
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.
tC
Record button three times.
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
6. Make the Fax text box the same a. Select the Fax and Phone text boxes.
ea
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
Design view, align the right side to select the CustomerID, Phone,
ea
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
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.
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
al
pointing finger.
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
• 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
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
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
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
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.
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.
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
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
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
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.
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.
tC
c. Enlarge the preview to 100%.
you on this.
e
al
5. Examine the preview of the AutoReport.
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.
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
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
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
Activity Time:
se
15 minutes
r
Setup:
fe
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.
al
Wizard.
ri
a te
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re
rial
a te
y
op
eM
b. In the Selected Fields list, select
ManufacturerID.
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
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.
rial
te
c. Click Next.
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
dow as well.
e
se
r
fe
ea
Pl
Re
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
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.
tC
window.
No
n c
Do
e
Close.
fe
e. Open rptDepartmentalInventory in
ea
Design view.
al
d) Date and Time
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
log box.
r
6. Close the property sheet. a. In the properties dialog box, click the
fe
Close button.
ea
Pl
Re
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
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
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.
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.
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
4. Click the report design surface where you wish to place the calculated control.
r
6. Type an equal sign (=) and the formula for the calculation.
ea
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
al
c. In the Toolbox, click the Label tool.
i
create the label control.
r
e. Type Amortized
te
f. In the Toolbox, click the Close 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
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
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.
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.
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
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
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
AutoFormat button.
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.
tC
b. Click Save.
TOPIC G
e
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
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
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.
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
6. Close the UseReports database and a. In the Database window, click the Close
close Access. button.
Pl
Re
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
rial
a te
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re
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
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.
6. Designate primary and foreign keys that can be used to relate your tables together.
fe
ea
Pl
Re
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
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
database.
ea
Pl
Re
rial
a te
y
op
Figure 7-3: A poor statement of purpose for an employee benefit plans
eM
database.
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
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
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
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
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
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.
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
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
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.
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
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
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
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.
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.
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
1. Based on the information you have now, which two tables would be minimally required
for this database?
fe
al
d) Warranty coverage
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.
Guidelines:
Common data normalization guidelines are as follows:
e
field).
• There should be no unnecessarily repeated data values.
fe
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
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
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:
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
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.
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
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
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.
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
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
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.
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.
mary keys and, where necessary, foreign keys. In doing so you are preparing your tables to be
Do
a) EmployeeLastName
b) EmployeeFirstName
c) DeptCode
d) A new field, EmployeeID
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
2. What fields might you include in the first database you need to build on your job? How
Pl
Re
rial
a te
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re
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
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
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
6. In the File New Database dialog box, navigate to the folder in which you wish to
ea
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.
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
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.
a
y
op
eM
tC
No
c
f. Click OK.
n
Do
MyComputersTemp
r
fe
i. Click Create.
ea
Pl
Re
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
rial
a te
y
c. Select Department Information in the
op
eM left pane to see its three fields.
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
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.
tC
selecting the default Corporate bold report style.
style and continuing with the
wizard. No
n c
Do
e
se
r
fe
d. Click Next.
rial
te
b. Click Next.
a
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re
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
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
2. Name the new database a. In the File Name text box, type
Do
c. Click Create.
fe
ea
Pl
Re
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
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
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.
al
c. In the Sample Fields list, select
EmployeeID.
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
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
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.
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
b. Click in the Data Type column for the field, display the drop-down list, and
ea
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.
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
ManufacturerID record.
r
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
b. Type Manufacturer
al
c. Press Tab. The Text data type is the
default.
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.
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
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
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
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
al
c. Click in the Format property box.
i
select Short Date.
r
5. Create a number field named a. In the next Field Name field, type
te
PurchasePrice. PurchasePrice
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
8. Create a Warranty field as a Yes/No a. In the next Field Name field, type War-
Do
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
•
Do
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
Information about employees might be separated into two tables for security access reasons.
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
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
Guidelines:
You can set referential integrity between two tables if the following are true:
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
To create a relationship between two tables and enforce referential integrity between
them:
e
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.
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.
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
tionships window.
Do
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
double-headed arrow.
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
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.
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
c. Click Create.
Pl
Re
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
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?
rial
a te
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re
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
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
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.
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.
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.
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.
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
3. Set the default for the Hours field a. Display the properties for the Hours
to 40. field.
Pl
Re
c. Press Enter.
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.
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
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
9. In the PayRate field, test the valida- a. In the PayRate field, type 32.50
e
c. Click OK.
al
e. Click OK.
ri
f. Enter 22.50
te
g. Press Enter.
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.
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
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.
enters) are stored. By not storing the literal display characters, you can reduce the
Do
rial
te
Figure 9-1: The input mask for a standard telephone number including area
code.
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
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.
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
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
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
al
c. Click the Build button.
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.
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.
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
al
c. Type Jeremy and press Tab.
i
e. Type Dresden and press Tab.
r
f. Type ny and press Tab.
te
g. Type 145278788 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.
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.
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.
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
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 .)
al
Figure 9-5: A lookup list that displays department codes and names.
ri
What You Do How You Do It
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
column.
e
se
r
click Next.
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
DeptCode
fe
c. Click Finish.
ea
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.
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
headings.
r
fe
ea
Pl
Re
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.
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
rial
a te
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re
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
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
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
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.
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.
• 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
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
Rubenstein.
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
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
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
Data Files:
• Join.mdb
se
r
Setup:
fe
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.
al
greater than $12,000.
Filter/Sort.
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
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
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
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.
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
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
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.
False
e
se
r
fe
ea
Pl
Re
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
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
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
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.
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
You can create more than one join between a pair of tables.
se
r
fe
ea
Pl
Re
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.
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
al
3. Run qselCustomerNames. a. Run the query.
ri
a te
y
op
eMb. Verify that 100 records are displayed.
Save the updated 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
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
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
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.
tC
erwise, you will get an error message.
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
al
field LastName to the second Field cell
of the query design grid.
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
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.
tC
Join database.
b. Close the query.
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?
rial
a te
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re
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
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
Access provides properties you can set for a select query to restrict what records will be
shown.
e
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
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.
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
Scenario:
fe
For an upcoming presentation you need a query that will display the top five book customers
ea
rial
te
There are four field lists, so this query can display
information from four different tables.
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
rial
b. Select 5.
te
Make sure you select 5, not 5%.
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
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
3. There are records with a customer of Allendale Books and a book title of “Improving
Your Tennis Game.”
fe
ea
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.
qselMyCustomerNames
Do
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.
Figure 11-1: A parameter query that generates a prompt for the user to enter
a State criterion.
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.
You can use wildcard characters in the Criteria cell for select queries or in response to parameter query prompts.
Do
? Matches any single alphabetic Like “B?nd” would match Band, Bind, and
ea
[! ] 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.
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
4. When you are prompted to enter a parameter value, enter the value of the data
you want to view and click OK.
e
When you specify a prompt message, it should be brief but meaningful. Access can
r
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.
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
tC
b. Switch to design view.
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
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.
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
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
al
d) 20
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
An Update query changes specified values in a table for all the records or for those
ea
It is generally a good idea to make a backup of your data before using update and delete action
Pl
queries.
Re
rial
a te
y
op
Figure 11-3: An Update query that increases prices by five percent.
tC
to another.
No
n c
Do
e
se
r
fe
ea
Pl
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.
rial
a te
y
op
eM
tC
Figure 11-5: A Delete query that deletes matching records in a table.
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
5. When a dialog box appears indicating the number of records that will be affected,
al
click Yes.
6. If desired, save this 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
rial
te
f. Click OK. The copied table has been
added to the database.
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
4. There are records that have a part number that begins with either 31 or 34.
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.
tC
query, and view the results.
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
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
6. When a dialog box appears indicating the number of records that will be
appended, click Yes.
e
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
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
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.
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
d. Open tblBookProject.
fe
7. The tblBookProject table had 26 records before the append query was run. How many
ea
c) 30
d) 33
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
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
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
rial
a te
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re
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
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.
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
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
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
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.
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
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
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
table query.
b. Open frmSalesAndProfit, and then
switch to Design view.
se
r
fe
ea
Pl
Re
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
f. Click Undo .
se
r
unit.
h. Click Undo.
Pl
Re
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
drop-down arrow.
ea
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.
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
20.
fe
7. Insert the Book file image and size a. Choose the Image tool .
it so that it is smaller.
Pl
Re
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.
smaller.
al
c. Close the properties dialog box.
i
frmMySalesAndProfit.
r
b. Switch to Form view.
a te
y
op
eM
tC
No
c
TOPIC B
n
Do
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.
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.
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.
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
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
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
5. Choose the table or query that will provide the values. Click Next.
e
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.
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
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 .
rial
a te
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re
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.
6. Specify that Access should store the a. Select Store That Value In This Field.
e
PartNumber.
r
fe
ea
Pl
Re
c. Click Next.
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.
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
4. Enter the labels for the options you want to show on the form and click Next.
fe
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
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.
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
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
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.
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
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
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
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
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
ton .
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.
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
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
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
al
the Tables/Queries drop-down list and
select Table: tblBookSales.
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
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.
rial
a te
c. In the Width property box, enter 4”
y
op
eM
d. Close the properties dialog box.
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re
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
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?
rial
a te
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re
rial
a te
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re
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
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
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
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
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
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
3. In the New Report dialog box, select Report Wizard and click OK.
e
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
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.
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
Click Next.
fe
ea
Pl
Re
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
al
the left section of the dialog box.
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
7. What are some things you could improve about the summary data in each group and
r
8. Close the Print Preview of the a. To display Design view, click Close
Re
b. Close qselSalesAndProfit.
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
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.
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
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.
a
label control.
y
d. Change the label’s Caption property to
op
eM Book Sales
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
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”.
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.
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.
tC
the report.
No
n c
Do
e
se
r
fe
ea
as rptMyOrders
Re
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.
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
the report. This property can guarantee that critical information is shown on a fresh page.
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
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.
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
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
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.
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
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.
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
1. Make room on the report for two a. Display the properties dialog box for the
se
r
rial
te
c. Close the property dialog box.
a
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re
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
3. Create a Text Box control to show a. From the toolbox, choose the Text Box
ea
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
Align→Bottom.
r
fe
ea
Pl
Re
al
mark to the 5” mark on the horizontal
ruler.
ri
d. Change the line’s Border Style property
to Dashes.
te
e. Change the line’s Border Width property
to 2 pt.
a
y
op
eM
tC
g. Save the updated 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.
Figure 13-2: A subreport to display product names in a bound main report dis-
playing orders.
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
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
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
Next.
Re
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
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.
al
b. On the Page tab, change the orientation
to Landscape. Click OK.
i
d. Verify that the blank pages in the report
r
have been eliminated. Close the
preview.
te
e. Choose File→Page Setup.
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.
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
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
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
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.
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
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
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
rial
a te
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re
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
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
Analyze It With Microsoft Office Forms, Reports, Tables, Queries Saves Access data as an Excel
ea
in 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.
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
You have seen how Access data can be used in Word. Now you’re ready to see what you can
fe
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
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.
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
rial
a te
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re
al
Type heading, select 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
As Object In qselQuantitySold is
selected, and then click Finish.
Pl
Re
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
rptQuantitySold
d. Click Save.
e. Close Excel.
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
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.
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
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.
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
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.
a
g. For the export format, verify that Delim-
y
ited is selected. Click Next.
op
eM
tC
No
n c
Do
e
i. Click Next.
Pl
Re
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
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
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
7. Click Next: Preview Your Letters and review the resulting merged letters.
8. Click Next: Complete The Merge.
Pl
Re
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
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
rial
a te
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re
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
al
comma and a space.
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
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
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
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
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
Wizard
Modifying table properties or 2-4, 2-5, 2-6,
e
structure 3-1
Define and Modify Field Types
se
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
tables
Create and Modify Calculated Fields and Aggregate Functions
Adding calculated fields to 4-5
Pl
Re
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
(e.g., Excel)
Back Up a Database
se
rial
a te
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re
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
Wizard
Modifying table properties or 2-4, 2-5, 2-6,
e
structure 3-1
Define and Modify Field Types
se
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
tables
Create and Modify Calculated Fields and Aggregate Functions
Adding calculated fields to 4-5
Pl
Re
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
Back Up a Database
Backing up a database 7-2
se
r
rial
a te
y
op
eM
tC
No
n c
Do
e
se
r
fe
ea
Pl
Re
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
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.
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
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
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.
tC
3. Right-click in the header of the Orders table and choose Table Design to display
the table in Design view.
6. Close the subdatasheets, close the table, close the Relationships window, and
then close the Database window.
e
se
r
fe
ea
Pl
Re
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
4.
r
fe
ea
Pl
Re
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
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
5. Customize the appearance of the form by selecting, sizing, aligning, and mov-
ing controls.
se
r
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
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
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.
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
tables together.
fe
4. Designate fields to be used as primary and foreign keys for each table.
ea
Pl
Re
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
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
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
2. Change the design of the table so that data entry is required in these three
fields: EmpID, Dept, and Hours.
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.
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
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.
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.
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
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.
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.
al
grouping, sort the customers by the OrderDate.
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
al
3. Analyze the qselTotProdOrd query in Excel.
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
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
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
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
Lesson 2
e
se
Activity 2-1
r
fe
Nine.
CustomerID.
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
Solutions 361
SOLUTIONS
d) Four
al
c) Three
d) Four
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
a) tblComputers
b) tblNotes
e
c) Neither
✓ d) Both
se
r
fe
ea
Pl
Re
al
3. How many records are now displayed?
a) 7
b) 12
i
✓ c) 19
r
d) 25
te
Activity 4-3
a
b) 21
y
✓ c) 23
op
7.
d) 32
a) 12
b) 14
e
c) 17
✓ d) 19
se
r
e) 35
fe
✓ a) 35
b) 12
c) 19
Pl
Re
d) 17
e) 60
Activity 4-5
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
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.
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
c) Page Number
d) Date and Time
se
r
a) Date
ea
b) Time
c) Name
✓ d) Page Number
Pl
Re
Activity 6-7
Solutions 365
SOLUTIONS
c) The margin setting is too narrow.
✓ d) The margin setting is too wide.
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
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
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
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.”
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
Activity 7-5
1. Based on the information you have now, which two tables would be minimally required
Pl
Re
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
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
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.
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
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
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
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
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
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
al
Activity 10-3
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
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.”
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
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
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
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
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
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
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
sorting, 25
r
N
Re
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
Select query, 50
creating a, 53 U
fe
selection conditions
Re
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