You are on page 1of 386

rE to ru c In st

DO NO T DU

Microsoft Office Access 2003 Level 1

PL

IC

AT
1631IGEE

di tio n

rE to ru c In st
DO NO T DU

PL

IC

AT

di tio n

Microsoft Office Access 2003 Level 1

Microsoft Office Access 2003 Level 1


ACKNOWLEDGMENTS
Project Team

Curriculum Developer and Technical Writer: Michael Sullivan Content Manager: Cheryl Russo Content Editors: Angie J. 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

rE
NO T

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 tness for a particular purpose. The name used in the data les for this course is that of a ctitious company. Any resemblance to current or future companies is purely coincidental. We do not believe we have used anyones name in creating this course, but if we have, please notify us and we will change the name in 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 entitys product, or another entitys 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 afliation 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.

to
DO

In st

ru c
ii

DU
Microsoft Ofce Access 2003 Level 1

PL

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.

IC

Copyright 2005 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 LLCs World Wide Web site is located at www.elementkcourseware.com.

AT

Microsoft Access 2003 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.

di tio n

Part Number: 1631IGEE Course Edition: 1.12

This logo means that this courseware has been approved by the Microsoft Ofce Specialist Program to be among the nest available for learning Microsoft Access 2003. It also means that upon completion of this courseware, you may be prepared to take an exam for Microsoft Ofces Specialist qualication.

What is a Microsoft Ofce Specialist? A Microsoft Ofce Specialist is an individual who has passed exams for certifying his or her skills in one or more of the Microsoft Ofce desktop applications such as Microsoft Word, Microsoft Excel, Microsoft PowerPoint, Microsoft Outlook, Microsoft Access, or Microsoft Project. The Microsoft Ofce Specialist Program typically offers certication exams at the Core and Expert skill levels. The Microsoft Ofce Specialist Program is the only program in the world approved by Microsoft for testing prociency in Microsoft Ofce 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 Ofce Specialist, visit www.microsoft.com/ofcespecialist. To learn more about other Microsoft Ofce Specialist approved courseware from Element K, visit www.elementkcourseware.com. *The availability of Microsoft Ofce Specialist certication exams varies by application, application version, and language. Visit www.microsoft.com/ofcespecialist for exam availability.

Element K is independent from Microsoft Corporation, and not afliated with Microsoft in any manner. This publication may be used in assisting students to prepare for a Microsoft Ofce 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.

rE
NO T

Microsoft, the Microsoft Ofce Logo, PowerPoint, and Outlook are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries, and the Microsoft Ofce Specialist Logo is used under license from owner.

to In st
DO

ru c

DU

PL

IC

AT
iii

di tio n

NOTES

rE to ru c In st
iv

DO

NO

T
Microsoft Ofce Access 2003 Level 1

DU

PL

IC

AT

di tio n

MICROSOFT OFFICE ACCESS 2003 LEVEL 1


LESSON 1 - AN OVERVIEW OF ACCESS 2003

CONTENTS

A. Understand Relational Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Database Terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

B. Examine the Access Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C. Open the Database Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Access Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

D. Examine an Access Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 Table Datasheet View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

rE
NO T

Naming Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

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

to
DO

LESSON 2 - MANAGING DATA

A. Examine an Access Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 B. Add and Delete Records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 C. Sort Records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 D. Display Recordsets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 E. Update Records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

LESSON 3 - ESTABLISHING TABLE RELATIONSHIPS


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

Contents

In st

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

ru c

DU

PL

IC

AT

E
v

di tio n
2 2 5 8 8 9

CONTENTS
C. Work with Subdatasheets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 Subdatasheets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43

LESSON 4 - QUERYING THE DATABASE


A. Create a Select Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 The Query Design Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 B. Add Criteria to a Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 Comparison Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 Conditional Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 C. Add a Calculated Field to a Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 Arithmetic Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 Access Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 The Expression Builder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 D. Perform a Calculation on a Record Grouping . . . . . . . . . . . . . . . . . . . . . . . 67

rE
NO T

A. Examine Form Design Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72

B. Create a Form Using AutoForm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75

In st

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

LESSON 6 - PRODUCING REPORTS


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

DO

ru c
vi

D. Modify the Design of a Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 Selecting Form Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 Sizing Form Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 Aligning and Spacing Form Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88

DU

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

PL

The Form Wizard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73

Microsoft Ofce Access 2003 Level 1

IC

AutoForms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72

to

AT

LESSON 5 - DESIGNING FORMS

di tio n

CONTENTS
B. Create a Report by Using the Wizard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 The Report Wizard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 C. Examine a Report in Design View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 Report Design View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 D. Add a Calculated Field to a Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 The Toolbox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107

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

F. AutoFormat a Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 G. Adjust the Width of a Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114

LESSON 7 - PLANNING A DATABASE

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

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

C. Review Existing Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124

F. Normalize the Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133

to
DO

LESSON 8 - BUILDING THE STRUCTURE OF A DATABASE

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

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

LESSON 9 - CONTROLLING DATA ENTRY


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

Contents

In st

One-to-Many Relationship . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 Enforce Referential Integrity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164

NO

D. Create Relationships between Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163

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

ru c

DU

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

PL

IC

G. Designate Primary and Foreign Keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139

AT

E. Group Fields into Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130

E
vii

D. Determine Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128

rE

di tio n

CONTENTS
B. Create an Input Mask . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 Input Masks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 C. Create a Lookup Field. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183 Lookup List Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183

LESSON 10 - FINDING AND JOINING DATA

A. Find Data with Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192 Types of Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192 B. Create Query Joins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198 Query Joins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198 Inner Join . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198 Outer Join . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199 C. Join Unrelated Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205 D. Relate Data Within a Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208

LESSON 11 - CREATING FLEXIBLE QUERIES

B. Create Parameter Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222

ru c

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

In st

LESSON 12 - IMPROVING YOUR FORMS


A. Enhance the Appearance of a Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244 Form Design View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245

DO

NO

Action Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229

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

DU

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

viii

PL

Select Query Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216

Microsoft Ofce Access 2003 Level 1

IC

A. Set Select Query Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216

to

AT

Self Joins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208

rE

di tio n

CONTENTS
B. Restrict Data Entry in Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253 Control Wizards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254 Combo Box Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254 List Box Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254 Option Group Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255

C. Add Command Buttons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266 Command Buttons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266

D. Create a Subform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269 Subforms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269

LESSON 13 - CUSTOMIZING YOUR REPORTS

A. Organize Report Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278 Report Design Enhancements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278 Report Design View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279

C. Control Report Pagination . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290

to
DO

D. Summarize Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294

Subreports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300

LESSON 14 - EXPANDING THE REACH OF YOUR DATA

Contents

In st

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

B. Analyze Access Data in Excel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316 Excel Office Links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316

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

NO

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

ru c

DU

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

PL

Force New Page Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290

IC

Keep Together Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290

AT

Display Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285

E
ix

B. Set Report Control Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285

rE

di tio n

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

APPENDIX A - MICROSOFT OFFICE SPECIALIST PROGRAM APPENDIX B - MICROSOFT OFFICE SPECIALIST PROGRAM LESSON LABS GLOSSARY

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359

INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363

rE to ru c In st
x

DO

NO

T
Microsoft Ofce Access 2003 Level 1

DU

PL

IC

AT

di tio n

INTRODUCTION

ABOUT THIS COURSE

to
DO

Target Student

ru c

Course Prerequisites

To ensure the successful completion of Microsoft Offce Access 2003 Level 1, we recommend completion of one of the following New Horizons courses, or equivalent knowledge from another source: Windows 2000 Introduction Windows XP Introduction Windows XP Professional Level 1 Windows XP Professional Level 2

Introduction

In st

NO

This course is designed for students who wish to learn the basic operations of the Access 2003 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 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 technical Access responsibilities, such as creating and maintaining new databases and using programming techniques that enhance Access applications.

DU

PL

IC

Course Description

AT
xi

Managing large amounts of complex information is common in todays business environment and, if done properly, can provide any business an edge over the competition. However, mismanaged and lost information can cause you to fall behind. An implementation of the Access 2003 database application can give your business that positive edge.

rE

Most organizations maintain and manage large amounts of information. One of the most efficient and powerful information management computer applications is the relational database. 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 database by using the Microsoft Office Access 2003 relational database application and its information management tools.

di tio n

INTRODUCTION

How to Use This Book


As a Learning Guide

We organized each lesson into results-oriented topics. Topics include all the relevant and supporting information you need to master Access 2003, and activities allow you to apply this information to practical hands-on examples. You get to try out each new skill on a specially prepared sample le. This saves you typing time and allows you to concentrate on the skill at hand. Through the use of sample les, hands-on activities, illustrations that give you feedback at crucial steps, and supporting background information, this book provides you with the foundation and structure to learn Access 2003 quickly and easily.

As a Review Tool

rE
NO T

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 Microsofts business desktop software and who seek recognition for their expertise with specic Microsoft products. Certication candidates must pass one or more prociency exams in order to earn Office Specialist certication.

In st

In this course, you will be introduced to the features of the Access 2003 application. You will: examine the Microsoft Office Access 2003 database application. manage the data in a database. examine existing table relationships. query the database. design simple forms.

DO

Course Objectives

ru c

DU

xii

PL

The organization and layout of the book make it easy to use as a learning tool and as an afterclass reference. You can use this book as a rst source for denitions of terms, background information on given topics, and summaries of procedures.

Microsoft Ofce Access 2003 Level 1

IC

As a Reference

to

AT

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 when reviewing activities, try the What You Do column before looking at the How You Do It column.

di tio n

Each lesson covers one broad topic or set of related topics. Lessons are arranged in order of increasing prociency with Access 2003; skills you acquire in one lesson are used and developed in subsequent lessons. For this reason, you should work through the lessons in sequence.

INTRODUCTION
create and modify Access reports. follow the steps required to properly design a simple database. create a new database with related tables. control data entry by modifying the design of a table to streamline data entry and maintain data integrity. nd and retrieve desired data by using lters and joins between tables and within a single table. create exible queries to display specied records; allow for user-determined query criteria; and add, update, and delete data with queries. enhance the appearance, data entry, and data access capabilities of your forms. customize reports to better organize the displayed information and produce specic print layouts such as mailing labels. use Access data in other applications, including Microsoft Word and Excel.

Course Requirements
Hardware

A 133 MHz Pentium-class processor if you use Windows 2000 Professional as your operating system. 128 MB of RAM. A 6 GB hard disk. A oppy disk drive. A mouse or other pointing device. An 800 x 600resolution monitor.

ru c

Network cards and cabling for local network access. Internet access (see your local network administrator). A printer (optional).

In st

A projection system to display the instructors computer screen.

Software

Either Windows XP Professional with Service Pack 1, or Windows 2000 Professional with Service Pack 4. Microsoft Office Professional Edition 2003.

Introduction

DO

NO

DU

PL

IC

to

AT

For this course, you will need one computer for each student and one for the instructor. Each computer will need the following minimum hardware components: A 233 MHz Pentium-class processor if you use Windows XP Professional as your operating system. 300 MHz is recommended.

rE

E
xiii

di tio n

INTRODUCTION

Class Setup
For Initial Class Setup
1. Install Windows 2000 Professional or Windows XP Professional on an empty partition. 2. Leave the Administrator password blank. For all other installation parameters, use values that are appropriate for your environment (see your local network administrator if you need details).

On Windows 2000 Professional, when the Network Identication Wizard runs after installation, select the Users Must Enter A User Name And Password To Use This Computer option. (This step ensures that students will be able to log on as the Administrator user regardless of what other user accounts exist on the computer.) On Windows 2000 Professional, in the Getting Started With Windows 2000 dialog box, uncheck Show This Screen At Startup. Click Exit. On Windows 2000 Professional, set 800 x 600 display resolution: Right-click the desktop and choose Properties. Select the Settings tab. Move the Screen Area slider to 800 By 600 Pixels. Click OK twice, and then click Yes.

3. 4.

6.

to
DO

9.

10. Log on to the computer as the Administrator user if you have not already done so. 11. Perform a Complete installation of Microsoft Office System, Version 2003. 12. Minimize the Language Bar if it appears. a. Open Access 2003.

In st

13. Set the security level of Access 2003 to Low. b. c. Choose ToolsMacroSecurity. Select the Low option. Click OK. Choose HelpSample Databases. Follow the instructions for installation of the Northwind database.

d. a.

14. Install the Northwind.mdb sample database. b.

NO

Run the Internet Connection Wizard to set up the Internet connection as appropriate for your environment if you did not do so during installation.

ru c

For Windows 2000 Professional, click Start and choose SettingsPrinters. Run the Add Printer Wizard and follow the prompts.

DU

For Windows XP Professional, click Start and choose Printers And Faxes. Under Printer Tasks, click Add A Printer and follow the prompts.

xiv

PL

8.

On either operating system, install a printer driver (a physical print device is optional).

Microsoft Ofce Access 2003 Level 1

IC

7.

On Windows XP Professional, install Service Pack 1. Use the Service Pack installation defaults.

AT

On Windows XP Professional, disable the Welcome screen. (This step ensures that students will be able to log on as the Administrator user regardless of what other user accounts exist on the computer.) Click Start and choose Control PanelUser Accounts. Click Change The Way Users Log On And Off. Uncheck Use Welcome Screen. Click Apply Options.

rE

5.

On Windows 2000 Professional, install Service Pack 4. Use the Service Pack installation defaults.

di tio n

INTRODUCTION
c. Close Access 2003. 15. On the course CD-ROM, open the 084_460 folder. Then, open the Data folder. Run the 084460dd.exe self-extracting le located within. This will install a folder named 084460Data on your C drive. This folder contains all the data les that you will use to complete this course. Copy all of the data les in the 084460Data folder and paste them into the My Documents folder.

Before Every Class


1. 2. 3. Log on to the computer as the Administrator user.

Delete any existing data les from the My Documents folder.

Extract a fresh copy of the course data les from the CD-ROM provided with the course manual. Copy all of the data les in the 084460Data folder and paste them into the My Documents folder.

List of Additional Files

rE
NO T

Printed with each activity is a list of les students open to complete that activity. Many activities also require additional les that students do not open, but are needed to support the le(s) students are working with. These supporting les are included with the student data les on the course CD-ROM or data disk. Do not delete these les.

to In st
Introduction

DO

ru c

DU

PL

IC

AT
xv

di tio n

NOTES

rE to ru c In st
xvi

DO

NO

T
Microsoft Ofce Access 2003 Level 1

DU

PL

IC

AT

di tio n

LESSON 1

LESSON 1

An Overview of Access 2003


You will: Dene the relational database concept. Examine an Access databases environment. Examine a table in an Access database.

In this lesson, you will examine the Microsoft Office Access 2003 database application.

rE
NO T DU

Examine the Access 2003 program environment.

to In st
Lesson 1: An Overview of Access 2003

DO

ru c

PL

IC

AT
1

di tio n

Lesson Time 45 minutes

LESSON 1
Introduction
In most businesses, working with large amounts of varying types of data is a daily requirement. Understanding the composition of databasesand, in particular, the Access relational database programwill provide you with a foundation for using Microsoft Office 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 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 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 managing your data.

TOPIC A

to
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.

ru c
Meaning

Term
Table Field

A group of records stored in rows and columns. A set of data about one person or thing. A category of information that pertains to all records. A single piece of data.

In st

Record Value

NO

T
Microsoft Ofce Access 2003 Level 1

DU

Database Terminology

PL

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 to use and being versed in its terminology is a much better starting point.

IC

AT

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 with the terms used to describe a database is the rst step to becoming a competent database user. In this topic, you will be introduced to the relational database and the terminology that denes its components.

rE

Understand Relational Databases

di tio n

LESSON 1
Relational Databases
Denition: Simply put, a database is a collection of information. A relational database takes that concept one step further. A relational database is a le that stores information in multiple tables. Each table stores one specic 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. A relational database offers several benets: Flexbility Simplicity Ease of management Power

rE
NO T

to In st
Figure 1-1: The relational database.
Lesson 1: An Overview of Access 2003

DO

ru c

DU

PL

IC

AT
3

Example: A travel agent maintains two client tables. The rst table contains information on the time of year clients prefer to travel, while the second table contains data on the clients 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.

di tio n

LESSON 1

ACTIVITY 1-1
Identifying a Relational Database
5 minutes

Scenario: 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 these concepts.
What You Do 1. How You Do It

What are some examples of collections of data that you use in your personal life? Answers may include a cookbook, a TV program guide, mail-order catalogs, and a household inventory.

2.

What are some examples of collections of data that you use in your job? Answers may include personnel records, customer or vendor lists, and purchasing information.

rE
NO T

3.

Which of the following is representative of a relational database?

to
DO

a) Note card

c) Index in a book

d) Glossary in a book 4.

Which of the following is not an advantage of the relational database? a) Flexibility b) Simplicity

In st

ru c
c) Redundancy e) Power d) Ease of management

DU

PL
Microsoft Ofce Access 2003 Level 1

b) Library file system

IC

AT

di tio n

Activity Time:

TOPIC B
Examine the Access Environment
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 examine the environment used to create new Access database les and interface with existing ones. When you launch Access, you have not yet opened a real database; youve only opened the interface that allows you to create new databases and open and manage existing databases. 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 les that hold your information, your relationship to the database is extremely limited. An understanding of the interface that performs these actions is essential to managing your information.

LESSON 1

Access Environment Components

The toolbar is a row of icons used to execute commands.

to ru c In st
Lesson 1: An Overview of Access 2003

Figure 1-2: The Access 2003 application environment.

DO

NO

DU

PL

IC

AT
5

The task pane is where you can search for les and consult the Microsoft Office online product information.

rE

The Access 2003 environment enables you to open existing databases and create new databases. There are three primary components of the application environment: The menu bar is where commands are displayed and executed.

di tio n

LESSON 1

ACTIVITY 1-2
Examining the Access Environment
10 minutes

Scenario: Access is installed on your computer. Its now time to launch the application and explore its basic features.
What You Do 1. Launch Access. How You Do It

to ru c In st
6

NO

DO

DU

c. In the File menu, point to Close. Because this command is inactive, nothing happens when you point to it.
Inactive items appear grayed out in all of the menus.

d. On the menu bar, display the other menus and examine the choices. e. Click a blank area of the screen to close the open menu.

PL

Microsoft Ofce Access 2003 Level 1

IC

b. In the File menu, point to New. When you point to an active command, Access highlights the command.

AT

2.

Examine the menus on the menu bar.

rE

di tio n

Activity Time:

a. From the Start menu, choose All ProgramsMicrosoft OfficeMicrosoft Office Access 2003.
In Windows 2000, choose StartPrograms Microsoft Access.

a. On the menu bar, click File to display the File menu. The commands are similar to those in other applications.

LESSON 1
3. In the Access application, use the tooltips to examine the tools on the toolbar. a. On the toolbar, hover the mouse pointer over the first button on the left to display the tooltip.
Inactive buttons appear grayed out, as did the inactive menu items.

b. Moving from left to right, display the tooltip for each button. 4.

By default, which of the following toolbar options are activated when you launch the Access application? a) New b) Open c) Save d) Cut e) Microsoft Office Access Help f) Undo g) Code h) File Search

rE
NO T

5.

to In st
f.

DO

ru c
Lesson 1: An Overview of Access 2003

to return to c. Click the Back button the Basic File Search task pane.

d. On the toolbar, click the New button to display the New File task pane. e. In the task panes navigation bar, click the Back button to display the Basic File Search task pane again. Click the Forward button the New File task pane. to display

g. Click the Home button to display the Getting Started task pane.

DU

PL

b. In the task panes navigation bar, click the Home button to return to the Getting Started task pane.

IC

AT

Navigate through the available task panes.

a. On the toolbar, click the File Search button to display the Basic File Search task pane in which you can search for a database file.

E
7

di tio n

LESSON 1

TOPIC C
Open the Database Environment
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. 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 le structure within Access. Doing so will allow you to open the les that hold your data and employ the tools to manage it.

Access Objects

The Database window displays the Access objects in the left pane. Access objects are the tools that are used to store and work with your data.

rE to
DO
Description

In st

Object
Tables

Storage container for the data. Question that retrieves data from tables. Queries may be saved for reuse. Queries always display either record level output (list format) or summary information (a query cannot display both detail and summary). Graphical interface used for data entry and/or displaying data and other objects. Screen output of data arranged in an order specied by the user.

Queries

Forms

Reports

NO

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.

ru c

DU

Figure 1-3: Selecting an object in the Objects pane on the left side of the Database window allows you to view all instances of that Access object within the database file.

PL

Microsoft Ofce Access 2003 Level 1

IC

AT

di tio n

LESSON 1
Naming Conventions
Naming conventions are sets of rules that can be applied to Access objects in order to identify them. The rules call for a unique prex to be assigned to the beginning of an object name. Common Applications of Naming Conventions Some, but not all developers use naming conventions at the eld 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 convention utilized is strictly up to the user. The following table illustrates examples of commonly used naming conventions.

Object
Table Select Queries Forms Subforms Reports Subreports

Prex
tbl qry frm fsub rpt rsub

Example

tblSampleTable

qrySampleQuery or qryselSampleQuery frmSampleForm

fsubSampleSubform

rE
NO T

rptSampleReport

rsubSampleSubReport

How to Open and View an Access Database


Procedure Reference: Open and View a Database To open and view a database:
1. 2. 3. 4.

to
DO

Start Access. Locate the database les.

Select the database le to open. Click Open.

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

Lesson 1: An Overview of Access 2003

In st

ru c

DU

PL

IC

AT
9

di tio n

LESSON 1

ACTIVITY 1-3
Opening and Viewing an Access Database
5 minutes Data Files: Computers.mdb

Setup: Access is running. No les are open.

rE
NO T

Scenario: A consultant has created an inventory database, Computers.mdb, containing information on all of the organizations computers, including who uses them, in which department they are used, 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 of the companys computer inventory.

to In st
DO

ru c
10

DU
Microsoft Ofce Access 2003 Level 1

PL

IC

AT

di tio n

Activity Time:

LESSON 1
What You Do 1. In the Computers.mdb database, in the Objects pane, verify that the Tables object is highlighted and examine the table objects. How You Do It a. On the Getting Started task pane, click the Open link. b. From the My Documents folder, locate and double-click Computers.mdb to open the database and display the Database window. c. Examine the Objects pane on the left side of the Computers Database window. d. If necessary, in the Objects pane, click Tables to display the table objects.

rE to
2. Display the queries, forms, and reports in the Computers.mdb database.

ru c

In st

c. In the Objects pane, select Reports. The right pane displays report creation tools and a report stored in the database.

Lesson 1: An Overview of Access 2003

DO

b. In the Objects pane, select Forms. The right pane changes to display a list of form creation tools and the forms stored in the database.

NO

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

DU

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 of existing tables in the Computers.mdb database.

PL

IC

AT
11

di tio n

LESSON 1
3. In the left pane, collapse and expand the Objects listing.
Groups is an advanced feature discussed in a future course.

a. In the left pane, click Groups to collapse the Objects listing. b. Click Objects to expand the listing again.

4.

Match the type of Access object with the description of the function(s) that it performs.

b d c a

report table query form

a. Displays data for editing. b. Arranges data for printed output. c. Displays selected data. d. Stores data on a single topic.

TOPIC D

Examine an Access Table


Understanding the application interface and the structure of the database les is like knowing the directions to a bank and how the safe deposit boxes are organized. It is essential to know, but not very useful unless you know how to open the safe deposit boxes and access the valuables. Opening an Access table that contains your information and using the Access programs views to work with the tables is like having the keys to the safe deposit boxes.

rE
NO T

to
DO

Table Datasheet View

Datasheet view is the default view a user sees when opening a table or using a query. The data is arranged in rows and columns and the format resembles an Excel worksheet. In Datasheet view: Record selectors appear to the left of each record, allowing users to select an entire record to copy or delete.

In st

A navigation bar allows the user to navigate to a specic record.

ru c

DU

12

PL

Microsoft Ofce Access 2003 Level 1

IC

AT

You have toured the Access interface and viewed an MDB database le where your information, 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.

di tio n

LESSON 1

Figure 1-4: Table displayed in Datasheet view.

Table Design View

rE
NO T

to In st
Figure 1-5: Table displayed in Design view.
Lesson 1: An Overview of Access 2003

Working with an Access Table in Datasheet and Design Views


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 individual user of a single database to work with a table in Datasheet view and, simultaneously, to open the same table in Design view.

DO

ru c

DU

PL

IC

AT
13

Design view is displayed when the user clicks the View button when a table is open in Datasheet view. In Design view, the user is looking at the components that make up the table from a developers perspective. Field names, data types, and eld properties are set, dened, and described within the Design view.

di tio n

LESSON 1

ACTIVITY 1-4
Comparing Datasheet and Design Views of an Access Table
Activity Time: 10 minutes Setup: Computers.mdb is open.

Scenario: Knowing that there are different ways to view a table, you would like to obtain a better understanding of the differences between those views. By viewing the tblEmployees table in Datasheet view and then in Design view, you can see the differences.
What You Do 1. Open the tblEmployees table. How You Do It

rE
NO T

to In st
DO

ru c
14

DU
Microsoft Ofce Access 2003 Level 1

PL

IC

AT

di tio n

a. In the Database window, with Tables selected, double-click tblEmployees.

LESSON 1
2. Using the Tab and arrow keys, the mouse pointer, and the tables navigation bar, move through the tblEmployees table. a. Press the Tab key three times to move through the fields in the table. b. Hold down the Shift key and press Tab three times to move back through the fields. c. Press the arrow keys to move around the fields in the table. d. Click the record selector (the gray left column) of EmployeeID 0036 to select Andrea Browns entire record.

e. In the Record Navigation bar at the bottom of the table, click the First Record button to select the first record in the table. f. In the Record Navigation bar, click the Next Record button to select the second record in the table.

rE
NO T

to
f.

3.

In st

e. Press the down arrow a final time to move to the last field and observe the properties in the lower panel. In the upper pane, select the EmployeeID field.

Lesson 1: An Overview of Access 2003

DO

ru c

b. Click the table windows Maximize button to maximize the display. c. Press the down arrow to move to the next field and observe the change in the properties in the lower panel. d. Press the down arrow again to move to the next fields and observe the properties in the lower panel.

DU

PL

Display the tblEmployees table in Design view and examine the properties of the EmployeeID field.

a. On the far left of the table datasheets toolbar, click the View button to display the tblEmployees table in Design view.

IC

AT
15

g. In the Record Navigation bar, click the Last Record button to select the last record in the table, Edward Bernsteins record.

di tio n

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

What is the data type of the DeptCode field in the tblEmployees table? a) Currency b) Date c) Number d) Text

6.

What is the field size of EmployeeID? a) 2 characters b) 4 characters c) 20 characters d) 20 digits

7.

Close the table and database.

rE
NO T

to
DO

Lesson 1 Follow-up
1.

Why is it important to understand the way the database objects interact? Answers will vary, but should include a discussion of how all data is stored in tables and that queries, forms, and reports are views of that data.

2.

What kinds of information do you plan to build databases for? Answers will vary.

In st

ru c

DU

In this lesson, you were introduced to the composition of databases and the Access relational database program. In addition, you opened and briey examined the Access database application environment and an Access relational database.

16

PL

Microsoft Ofce Access 2003 Level 1

IC

AT

b. Choose FileClose to close the database.

di tio n
a. Choose FileClose to close the table.

LESSON 2

LESSON 2
Managing Data
In this lesson, you will manage the data in a database. You will: Examine an Access 2003 form. Add and delete records from a table. Use Select queries to display recordsets.

Use different criteria to sort the records in a table.

rE
NO T

to
DO

Lesson 2: Managing Data

In st

ru c

DU

PL

IC

Run a report to display a tables records in a report format.

AT

Update the records in a table by working in the table, by using a form, and then by using a query.

E
17

di tio n

Lesson Time 45 minutes

LESSON 2
Introduction
Understanding the Access environment is the rst step in managing the information in the database. Knowing how to use the data management tools that are provided with the application is the next step. In this lesson, you will work directly within a table to manage the tables 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 benets of your database and ensure that you have more time to spend on your other responsibilities.

TOPIC A

Examine an Access Form

to
DO

ru c

Forms can be based on a table or a query. Forms can be viewed in one of three ways: Datasheet view, Design view, or Form view. In addition to displaying table data, forms can include calculations, graphics, and other objects.

In st

NO

When using a form, keep in mind that: The data is never stored in the form, the form only displays the data stored in the table.

DU

Denition: An Access form is the object that is used to display, add, delete, and edit data in a table.

18

PL

Forms

Microsoft Ofce Access 2003 Level 1

IC

You have opened, examined, and toured a table. Now, imagine a table with thousands of records and each record containing multiple elds. Moving about the table to locate and modify a single eld in an individual record could be a challenging task. The Access form object simplies the process by allowing you to manage data through a graphical user interface.

rE

Now that you have worked in the Access environment, it is time to begin using the data management objects provided by Access. In this topic, you will examine an Access form, an object that allows you to locate and manage individual records.

AT

di tio n

LESSON 2
Example:

Figure 2-1: A sample form.

Navigation in an Access Form

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 displayed in the form, you can use the mouse or the keys and keystroke combinations found in the following table.

Keystroke

Movement

Shift+Tab, left arrow, up arrow Page Up Page Down Home End Ctrl+Home Ctrl+End

to
DO

Pressing Page Down will move you to the same eld in the next record. (This will only work if the form is built properly.)

ru c

Pressing Home will move you to the rst eld of the record you are currently in.

Lesson 2: Managing Data

In st

Pressing Ctrl+End will move you to the last eld in the last record of the table with which you are working.

NO

Pressing Ctrl+Home will move you to the rst eld in the rst record of the table with which you are working.

Pressing End will move you to the last eld of the record you are currently in.

DU

PL

Pressing Page Up will move you to the same eld in the previous record. (This will only work if the form is built properly.)

IC

Pressing Shift+Tab, or the left arrow or up arrow, will move you to the previous eld in the form. If it is the rst eld in the form, it moves you to the last eld of the previous record.

AT

Tab, Enter, right arrow, down Pressing Tab or Enter, or the right or down arrow, moves you to the next arrow eld in the form. If it is the last eld in the form, it moves you to the rst eld of the next record.

rE

E
19

di tio n

LESSON 2

ACTIVITY 2-1
Navigating in Access Forms
5 minutes Data Files: UseForms.mdb

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 companys needs.
What You Do 1. On the toolbar, click the File Search button and, in the task pane, open the UseForms.mdb database, then open the frmCustomers form. How You Do It

rE
NO T
f.

c. Click Go.

to ru c In st
2. Nine. 3. CustomerID. What field is highlighted by default?

How many fields are displayed in the form?

DO

DU

e. Close the Search Results task pane. In the Objects pane, select Forms.

g. In the Database windows right pane, double-click frmCustomers to open the form and display the first record in the tblCustomers table.

20

PL

d. When the UseForms.mdb file list appears, determine which file is in My Documents then click the My Documents\ UseForms.mdb file.

Microsoft Ofce Access 2003 Level 1

IC

AT

di tio n

Activity Time:

a. On the toolbar, click the File Search button.

b. In the Basic File Search task panes Search Text text box, type UseForms.mdb

LESSON 2
4. How many records are in the table? Fourteen. 5. Move through the records fields, to the next record, and then return to the first record in the table. a. With the CustomerID field selected, press the Tab key to move to the CustomerName field. b. Press the Tab key until the Postal Code field is selected.

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

6.

to
DO

7.

Move to the last field in the last record, move to the Fax field of the last record, and then return to the first field in the first record.

ru c

a. With the last field of the first record selected, press Ctrl+End to move to the last field in the last record in the table. b. Press Shift+Tab to move to the Fax field in the last record. c. With the Fax field of the last record selected, press Ctrl+Home to return to the first field in the first record.

Lesson 2: Managing Data

In st

NO

DU

PL

b. Press End to move to the last field of the record, Postal Code.

IC

Move to the first field in the record and then to the last field in the record.

a. With the Fax field of the first record selected, press Home to move to the CustomerID field.

AT
21

e. Using the Shift+Tab key combination, move to record number ones Fax field.

rE

d. Press Shift+Tab to move back to the first record in the tblCustomers table.

di tio n

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

rE
NO T

TOPIC B

to
DO

How to Add and Delete Records


Procedure Reference: Add a Record to a Table To add a record and enter the data:
1. 2. 3.

In st

Procedure Reference: Delete a Record from a Table To delete a record: Select the record to be deleted. Either press Delete or choose EditDelete.

ru c
1. 2.

On the tables navigation bar, click the New Record button. Enter the new record data.

Press Enter to accept the new record.

DU

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 will provide reliable, up-to-the-moment information. It will also prevent the database from becoming outdated.

22

PL

Microsoft Ofce Access 2003 Level 1

IC

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 this topic, you will add new records to a table and delete existing records from a table.

AT

Add and Delete Records

di tio n

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

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

ACTIVITY 2-2
Adding and Deleting Records in a Table
10 minutes Activity Time:

LESSON 2

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

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.
What You Do 1. Add a new customer record to the table. How You Do It

rE

a. In the frmCustomers forms navigation bar, click the New Record button to clear the form in preparation for entry of a new record. b. In the blank form, enter the following data:

to ru c In st
2. Display tblCustomers and view the new record.

Phone: (456) 777-6668

Address: 39 Rosey Blvd. City: Camptown Country: US Postal Code: 13355-0000 Region: NY

c. Close the form. a. Display tblCustomers and locate the new record.

Lesson 2: Managing Data

DO

NO

DU

Fax: (456) 777-6669

PL

CustomerName: Brave New Shoppers

IC

CustomerID: 21998

AT
23

di tio n

LESSON 2
3. How many records are in the table? a) 12 b) 13 c) 14 d) 15 4. Delete the Household Helper record.

5.

Use the navigation bar to add a new record to the table.

rE

b. Enter the following data:

CustomerID: 21999 CustomerName: Super Savers City: Coalville Region: UT Country: US Postal Code: 13365-0000 Phone: (454) 888-6668 Fax: (454) 888-6667

to ru c
6.

NO

Close the table and the database.

In st

DO

DU

a. Close tblCustomers and the UseForms database.

24

PL

Microsoft Ofce Access 2003 Level 1

IC

Address: 3669 Windy Way

AT

di tio n
c. Choose EditDelete.

a. In tblCustomers, verify that the right pointing Current Record Indicator is located in the first record, Household Helper. b. Choose EditSelect Record to highlight the Household Helper record.

d. When prompted to verify the record deletion, click Yes to complete the operation. a. In the tblCustomers tables navigation bar, click the New Record button.

TOPIC C
Sort Records
You have been asked to locate all of the individuals in a specic 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 nd are located throughout the table. In this topic, you will use several techniques to order the tables data and locate the desired records. Viewing and locating specic records in a large table can be difficult and time-consuming. To simplify the process and reduce the time you spend searching, Access provides you with several techniques to assist you in sorting and locating the desired records.

LESSON 2

How to Sort Records


Procedure Reference: Sort Records in a Table To sort the records in a table:
1. 2. 3. 4.

Open the table you wish to sort.

to
DO

Sorting Records in a Table


Activity Time: 10 minutes Data Files: SampleTables.mdb

ru c

Scenario: Your sales manager has learned that you have an abundance of information available at your ngertips 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 Zilinskis Home Store and how many have been placed by Household Helper. With the Access sorting tools, youll accomplish this task in no time.

Lesson 2: Managing Data

In st

NO

DU

ACTIVITY 2-3

PL

IC

Or, choose either RecordsSortSort Ascending or RecordsSortSort Descending.

AT

Sort the table: From the toolbar, select either the Sort Ascending or Sort Descending option;

E
25

In the table, select a eld in the column by which you wish to sort the table.

rE

In the Database window, select Tables.

di tio n

LESSON 2
What You Do 1. From the SampleTables.mdb database, open the tblCustomers table. How You Do It a. Open the SampleTables.mdb database. b. Open tblCustomers.

2.

Locate the CustomerID numbers for Household Helper and Zilinskis Home Store.

rE
NO T

to
DO

c. Close the table.

In st

4.

How is the table sorted? a) By OrderID b) By ItemNum c) By Quantity

ru c

Open tblOrders.

DU

3.

a. Open tblOrders.

26

PL

Microsoft Ofce Access 2003 Level 1

IC

b. Locate the Zilinskis Home Store record and record the CustomerID number _________________. (It is the highest number in the database).

AT

di tio n
a. Locate the Household Helper record and record the CustomerID number _________________. (It is the lowest number in the table.)

LESSON 2
5. Sort the table in ascending order, displaying the Household Helper orders at the top of the table. a. With the tblOrders table displayed, place the insertion point in the first field in the CustomerID column. b. Choose RecordsSortSort Ascending. Examine the results; there are three Household Helper orders at the top of the list. 6. Sort the table in descending order, displaying Zilinskis orders at the top of the table. a. With the tblOrders table displayed, place the insertion point in the first field in the CustomerID column.

b. Choose RecordsSortSort Descending. There are 10 Zilinskis Home Store orders at the top of the list. 7. Sort the OrderID column in ascending order. a. Click in any field in the OrderID column.

rE
NO T

b. Click the Sort Ascending button on the toolbar to sort the OrderID column in ascending order, restoring it to its original state.

to
DO

Sorting the records in a table in ascending or descending order, based on the values in a eld, is a very useful operation. However, there are times when you need to extract groups of related 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 specic criteria. You have been asked to locate all employees whose pay rate is between $12.50 and $15.00 per hour in a table that has several thousand records. You know that doing this in a tables 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.

Queries

Denition: A query displays data from one or more tables in an ordered manner, as dened by the querys developer.

Lesson 2: Managing Data

In st

ru c

DU

Display Recordsets

PL

TOPIC D

IC

AT
27

di tio n

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

How to Display Sets of Records


Procedure Reference: Display Sets of Records To display a recordset:
1. 2. 3. 4.

In the Database window, select Tables. Open the table you wish to sort.

In the table, locate and select a single occurrence of the value you wish to nd. Display the recordset: On the toolbar, click the Filter By Selection button; Or, choose RecordsFilterFilter By Selection.

Procedure Reference: Remove a Filter To remove the lter:


1.

rE
NO T

to
DO

Displaying Sets of Records


Activity Time: 10 minutes

Setup: The SampleTables.mdb database is open and the tblOrders table is displayed. Scenario: The Sales Managers would like a printout of only Zilinskis Home Store orders and a printout 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.

In st

ru c

DU
Microsoft Ofce Access 2003 Level 1

28

PL

IC

ACTIVITY 2-4

AT

Either click the toolbars Remove Filter button or choose RecordsRemove Filter/Sort.

di tio n

LESSON 2
What You Do 1. Use the Filter By Selection tool to display the Household Helper order recordset, and then view it in Print Preview. How You Do It a. In the CustomerID column, place the insertion point in any field with a 20151 value. This is the Household Helper Customer ID number. b. From the toolbar, click the Filter By Selection button to display the recordset of Household Helper orders.

2.

c. Press Esc to close the Print Preview window and return to the table.

to
DO

ru c

4.

In st

Use Print Preview to display the Zilinskis Home Stores recordset. Then, close the Print Preview window and remove the filter to close the recordset and return to the tblOrders table.

a. Choose FilePrint Preview and size the display to the screen to preview how the printed page would appear. b. Press Esc to close the Print Preview window. c. Choose RecordsRemove Filter/Sort to view all the records.

Lesson 2: Managing Data

NO

b. From the menu, choose Records FilterFilter By Selection to display the recordset of Zilinski Home Stores orders.

DU

3.

Locate one of the Zilinskis Home Stores CustomerID fields and apply a filter to display the recordset of their orders.

a. In the CustomerID column, place the insertion point in any field with a 21965 value. This is the Zilinskis Home Stores Customer ID number.

PL

d. On the toolbar, click the Remove Filter button to close the recordset display and return to the tblOrders table.

IC

AT
29

b. Using the Zoom feature, click in the preview to enlarge the display.

rE

Use Print Preview to view the Household Helper recordset. Then, close the Preview window and use the Remove Filter tool to close the recordset.

a. On the toolbar, click the Print Preview button to preview how the printed recordset would appear.

di tio n

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

rE to
DO NO T DU

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 other responsibilities. By using a table, you will be able to quickly locate the records you need and display them in edit mode.

How to Update Records

In st

Procedure Reference: Update Records To update a record:


1. 2. 3. 4. 5.

ru c

In the previous topics, you used a form to view data and a lter to display specic data. In this topic, you will use the form and query objects together to locate, edit, and update the records in a table that meet specic criteria.

In the Database window, in the Objects pane, select Tables. From the list of tables, open the table you wish to update. Locate the eld with the information that requires updating. Select the value of this eld and modify the data. Press the down arrow or Enter to accept the changes.

30

PL

Update Records

Microsoft Ofce Access 2003 Level 1

IC

AT

TOPIC E

di tio n
e. Close the recordset.

c. Examine the right pane and verify that the qryHouseholdHelperOrders query is present. d. In the right pane, double-click the qryHouseholdHelperOrders query to run 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.

LESSON 2
6.

Close the table.

ACTIVITY 2-5
Activity Time: 10 minutes Setup: 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 is your rst attempt at editing elds in a table and there are several editing techniques you can use. By trying several, you can determine which work best for you.
What You Do 1. In the tblEmployees table, change Shelly Griffiths ZIP Code from 72308 to 99336. How You Do It

to ru c In st
Lesson 2: Managing Data

c. Press Tab six times to highlight the ZIP Code. d. With the ZIP Code selected, type 99336
Notice that the Current Record Indicator to the

DU

PL

far left changes to a pencil

DO

e. Press the down arrow. The Record Indicator returns to its original state and the change is accepted.

NO

IC
.

b. Click in the EmployeeID field with a value of 0057. This is Shelly Griffiths record.

AT
31

a. Open and maximize the tblEmployees table.

rE

di tio n

Updating Records

LESSON 2
2. Locate Employee ID Number 0078, and correct the spelling of the name to Ballantine. a. In the EmployeeID column, locate EmployeeID 0078. This is Carl Ballantynes record. b. Click between the t and the y in Ballantyne.

3.

Change Lisa Fitzpatricks phone number from (607) 5553310 to (585) 5555595.

rE to ru c In st
32

c. Verify that the following criteria are selected:

NO

DO

T
f.

DU

d. In the Find What text box, type Fitzpatrick and then click Find Next to locate Lisa Fitzpatricks record. e. Click Cancel to close the Find And Replace dialog box. With the insertion point located in Lisa Fitzpatricks record, press Tab six times to the HomePhone field and change the value to (585) 5555595

g. Press the down arrow to accept the change.

PL

Look In: LastName Match: Whole Field Search: All

Microsoft Ofce Access 2003 Level 1

IC

AT

di tio n

c. Type i and delete the y to change Ballantyne to Ballantine. d. Press the down arrow to accept the edit. a. Position the insertion point in any field in the LastName column. b. Choose EditFind to display the Find And Replace dialog box.

LESSON 2
4. Use the Find And Replace option to change Lisa Fitzpatricks last name to Fitzgerald and close the database. a. Position the insertion point in the LastName column. b. On the toolbar, click the Find button to launch the Find And Replace Dialog Box. Select the Replace tab. c. With Fitzpatrick in the Find What text box, type Fitzgerald in the Replace With text box. d. Click Find Next. e. Click Replace. f.

Click Cancel to close the Find And Replace dialog box.

h. Close the SampleTables.mdb database.

rE
NO T

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

to
DO

Youve used forms and queries to make working with table data easier and more efficient. Youve even combined the skills to create an easy-to-use updating technique. Now its time to add the nishing touch. In this topic, you will run a report that displays your data as a professionally formatted presentation. You have been invited to a sales meeting and asked to distribute a listing of company products, organized by product line. This can be done by sorting the table or using different queries for each product line, but neither displays the data in a format you like. By running an Access report, you can produce a professionally formatted presentation you will be proud to distribute.

How to Run a Report


Procedure Reference: Run a Report To run a report:
1. 2.

Lesson 2: Managing Data

In st

In the Database window, in the Objects pane, select Reports. Run a report:

ru c

DU

Run a Report

PL

TOPIC F

IC

AT
33

di tio n

LESSON 2
3.

Double-click the report you wish to run; Or, select the report you wish to run and press Enter.

Click Close to close the report.

Running a Report
Activity Time: 5 minutes Data Files: UseReports.mdb

rE
NO T

to In st
DO

ru c
34

DU
Microsoft Ofce Access 2003 Level 1

PL

IC

AT

Scenario: The consultant who set up your Access database created several reports and stored them in the 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.

di tio n

ACTIVITY 2-6

LESSON 2
What You Do 1. In the UseReports.mdb database, run the rptFinalReport report. How You Do It a. Open the UseReports.mdb database.

d. Move though the report, then return to the top of the first page.

to

2.

Was it necessary for any of the tables to be open for the report to run? No.

ru c

In st

c. Close the report.

Lesson 2: Managing Data

DO

NO

Asset Tag: ___________________ Department Number: ___________ Purchase Price: _______________

b. From the entry, record the following information:

DU

3.

Record Rachel Middlebrooks asset tag, department number, and purchase price.

a. In the Departmental Inventory report, locate the entry for Rachel Middlebrook.

PL

IC

AT

E
35

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

rE

b. With Reports selected in the Objects pane, double-click rptFinalReport to run the report.

di tio n

LESSON 2
4. Open tblComputers and locate the Asset Tag and purchase price you recorded. a. Open tblComputers. b. Locate the asset tag number you recorded. c. Locate the purchase price and compare it with the purchase price you recorded to verify that they match. d. Close tblComputers.

5.

Verify that Rachel Middlebrooks department number in the report matches the one in the table.

rE
NO T

6.

Did the information that appeared in the report come from a single table?

to
DO

Because there is a field in both tables that can be related. This shows the benefit of using a relational database application such as Access.

Lesson 2 Follow-up

In st

In this lesson, you worked directly within an Access table to manage the tables data. You then used forms, queries, and reports to indirectly manage table data.
1. What types of operations can you perform on a table with an Access form? A form can be used to view, add, delete, and edit table data. It can also be used to filter, find, and sort data. How would you display a recordset? To display a recordset, you would first determine the criteria on which you wish to base the recordset. Then, you would select a field in the table that contains an occurrence of that value and apply the Filter By Selection tool.

2.

ru c

DU
Microsoft Ofce Access 2003 Level 1

36

PL

7.

Why was it possible for the report to draw information from more than one table?

IC

No. It came from more than one table.

AT

di tio n
a. Open the tblEmployees table. d. Close tblEmployees. e. Close the database.

b. Locate Rachel Middlebrooks record. c. Locate the department number and compare it with the number you recorded to verify that they are the same.

LESSON 3

LESSON 3
Establishing Table Relationships
In this lesson, you will examine existing table relationships. You will: Examine tables with established relationships. Identify a tables primary and foreign keys.

rE
NO T DU

to In st
Lesson 3: Establishing Table Relationships

DO

ru c

PL

IC

AT
37

Examine and work with a tables Subdatasheets.

di tio n

Lesson Time 45 minutes

LESSON 3
Introduction
As you have learned, the heart of any Access database is the table. Because Access is a relational database, it allows the data in different tables to be connected. This is a powerful concept that allows you to make use of the data in various tables, as if they were in a single 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 tables to be connected and provides you with a feature that allows you to gather and summarize the information from the different tables in one convenient location.

TOPIC A

Identify Table Relationships

rE
NO T

to
DO

Table Relationships and the Relationships Window


Denition: The purpose of relationships between tables is to link one set of information to another set of information. Example: The Access Relationships window is a graphic display of these relationships. The lines that connect the tables provide a visual indication of how the relationships work.

In st

ru c

DU

38

PL

Organizing complex data is the job of a relational database. For example, if your business has ve 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 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 simplied manner. Understanding how tables are connected and how to display the connections will allow you to make full use of the relational concept.

Microsoft Ofce Access 2003 Level 1

IC

AT

Using the form, query, and report objects, you have managed the records in a table. But working 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 connections and launch a window with a visual display of the relationships.

di tio n

LESSON 3

Figure 3-1: The Relationships window.

rE
NO T

to
DO

Activity Time: 5 minutes Data Files: Computers.mdb

Lesson 3: Establishing Table Relationships

In st

Scenario: If you could see a picture of how the tables are connected to one another it would help illustrate 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.

ru c

DU

PL

Using the Relationships Window to Identify Table Relationships

IC

ACTIVITY 3-1

AT
39

Analogy: A highway system connecting Chicago, Dallas, New York, Los Angeles, San Francisco, 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.

di tio n

LESSON 3
What You Do 1. Open the Computers database and the Relationships window. How You Do It a. Open the Computers database.

rE to
DO
2. a) One b) Three c) Five d) Seven b) Two c) Three d) Four

According to the Relationships window, how many tables are connected in this database?

In st

4.

How many have more than two links? a) One b) Two

c) Three d) Four

NO

a) One

3.

How many tables have more than one link to them?

ru c

DU
Microsoft Ofce Access 2003 Level 1

40

PL

IC

AT

di tio n

b. On the toolbar, click the Relationships button to launch the Relationships window. This displays a graphic representation of the links between tables.

c. If necessary, maximize the window and resize the table displays so all of the tables and connections in the display are visible.

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

TOPIC B

Identify Primary and Foreign Keys in the Relationships Window

to
DO

Primary Keys

A primary key is a eld or combination of elds containing a value that uniquely identies a record. Primary keys are set in table Design view and identied by the small key icon to the left of the eld name.

ru c

Foreign Keys

A foreign key is a eld in one table that links to a primary key in another table.

Lesson 3: Establishing Table Relationships

In st

Table relationships with referential integrity cannot be set without establishing 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.

NO

Primary Key Characteristics The following list describes several characteristics and functions of primary keys: Primary keys are not required, but are strongly recommended in each table.

DU

PL

IC

Much of the power of a relational database is derived from the ability to connect information in different tables. The eld is the point of connection. In order to establish the proper relationships, the connected elds 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 the keys that make up the table connections.

AT

E
41

You have launched the Relationships window and displayed the connections between the tables in your database. There are eld 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 individual links that connect the tables.

rE

di tio n

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

2. 3.

On the toolbar, click the Relationships button.

Observe the links and keys. At a links termination point (on either end), a bold eld name represents a primary key, and a non-bold eld name represents a foreign key.

ACTIVITY 3-2
Activity Time: 10 minutes

Identifying the Keys in Table Relationships

to
DO

What You Do 1.

How You Do It

ru c
a) Primary key b) Foreign key a) Primary key b) Foreign key

2.

In st

c) Primary and foreign key

3.

In tblEmployees, what type of key is DeptCode in the tblDepartmentstblEmployees relationship?

c) Primary and foreign key

NO

In tblDepartments, what type of key is DeptCode in the tblDepartmentstblEmployees relationship?

DU

Identify the Primary and Foreign keys in the Relationships window.

a. Examine the Relationships window and verify that there are links between all of the tables.

42

PL

Microsoft Ofce Access 2003 Level 1

IC

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.

AT

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

rE

di tio n

1.

Open the database.

LESSON 3
4. In the tblComputerstblNotes relationship, in which table is AssetTag a primary key? a) tblComputers b) tblNotes c) Neither d) Both
A Primary key can consist of multiple elds.

5.

Close the Relationships window.

a. Click Close.

b. If prompted, do not save your changes.

to
DO

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

Lesson 3: Establishing Table Relationships

In st

Denition: A subdatasheet is a datasheet that is nested within another datasheet and that contains data related or joined to the rst datasheet. The subdatasheet is launched and the data in the joined table is displayed when the plus sign in the left column is clicked. The plus sign (+) in the rst table is changed to a minus sign () when the subdatasheet is opened and then returns to a plus sign when the subdatasheet is closed.

NO

Subdatasheets

ru c

DU

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 launch a window from any record that is linked to another table and display the data from the linked table.

PL

IC

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 accessing the information in a table to which it is linked. In this topic, from an individual record in a table, you will launch a window that displays information from a linked table.

AT

E
43

Work with Subdatasheets

rE

TOPIC C

di tio n

LESSON 3

Figure 3-2: A subdatasheet.

How to Find Data in Subdatasheets


Procedure Reference: Find Data in Subdatasheets To expand and collapse a subdatasheet:
1. 2. 3. 4. 5.

rE
NO T

Locate the record you wish to view.

to
DO

Click the minus sign () to the left of the record to collapse the subdatasheet. Close the table.

In st

ru c
44

DU
Microsoft Ofce Access 2003 Level 1

PL

IC

Click the plus sign (+) to the left of the record to expand the subdatasheet.

AT

Open the table you wish to use.

di tio n

ACTIVITY 3-3
Viewing Data in Subdatasheets
5 minutes Setup: The Computers.mdb database is open. Activity Time:

LESSON 3

Scenario: Youve been asked to locate purchase prices and warranty information on the companys computers. The only information youve been given are the employees names. You thought there was a report, but there isnt. The information you need is contained in the tblEmployees tables.
What You Do 1. Open the tblComputers table and locate the purchase price of Lynne McMillans computer, and then close the table. How You Do It

a. Open the tblComputers table. b. Attempt to locate Lynne McMillans computer in the table. While the information you need is in there, there is no way to identify it. c. Close tblComputers.

rE
NO T

to In st
Lesson 3: Establishing Table Relationships

DO

ru c

DU

PL

IC

AT

E
45

di tio n

LESSON 3
2. Open tblEmployees, locate Lynne McMillan, and record her Employee ID number. Then, expand her subdatasheet and record the purchase price of her computer. a. Open tblEmployees. b. Locate Lynne McMillans record. c. From tblEmployees, record her Employee ID: _______________. d. In the column to the left, click the plus sign and expand the subdatasheet.

rE
f.

Close the table without saving changes.

to
NO DO

b. Locate Lynne McMillans employee ID.

ru c In st
46

DU

c. Verify that the value in the PurchasePrice field matches the value you recorded from the subdatasheet.
The values displayed in the subdatasheet were extracted from the tblComputers table.

d. Close tblComputers. If prompted, dont save changes. e. Close the database.

PL

You can use the Find button and search in the EmployeeID column.

Microsoft Ofce Access 2003 Level 1

IC

3.

If prompted, open tblComputers and verify that the purchase price in the table matches the value in the subdatasheet. Then, close the table without saving.

a. Open tblComputers.

AT

di tio n

Notice that the plus sign turns to a minus sign indicating it is expanded.

e. Record the computers purchase price: _______________.

LESSON 3
4. Display the tblEmployees table and expand the subdatasheets for Eric Haygood and Norman Grakowsky. a. Display the tblEmployees table. b. In the tblEmployees table, locate Eric Haygoods record. c. Click the plus sign in the left column to display the subdatasheet. d. Locate Norman Grakowskys record.

e. Click the plus sign in the left column to display the subdatasheet, and notice that all of the subdatasheets youve opened remain open. f. Close tblEmployees and the Computers database.

to
DO

2.

Primary and Foreign keys.

ru c

Lesson 3: Establishing Table Relationships

In st

NO

DU

What are the two types of keys that can be used to designate connections between linked tables?

PL

To display the links between the tables, you open the Relationships window. The links between tables are represented by solid lines that connect fields in the tables.

IC

1.

What window do you open to display the links between the tables in an Access database, and how are the links represented in the display?

AT
47

In this lesson, you launched the Relationships window and displayed and examined the links that connect the tables in an Access database.

Lesson 3 Follow-up

rE

di tio n

NOTES

rE to ru c In st
48

DO

NO

T
Microsoft Ofce Access 2003 Level 1

DU

PL

IC

AT

di tio n

LESSON 4

LESSON 4
In this lesson, you will query the database. You will: Use the Access Query Wizard to create and name a query. Add selection criteria to the query using Design view. Add a calculated eld to an Access query.

Querying the Database

rE
NO T

Modify a query to perform a summary calculation on a record grouping.

to In st
Lesson 4: Querying the Database

DO

ru c

DU

PL

IC

AT
49

di tio n

Lesson Time 1 hour(s), 15 minutes

LESSON 4
Introduction
In a previous lesson, you were introduced to the tools used to manage table data. One of the tools was a query. A query is a question that searches a database for information matching a specic set of conditions that you dene. Queries can be developed and customized to your 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. Opening a table and searching through it one record at a time is inefficient, not to mention tiring. Theres 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 meets specied criteria, whenever you need it.

TOPIC A

Create a Select Query

to
DO

In st

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

NO

A Select query is an Access object that selects and displays data that meets user-dened criteria from a table. The query may be viewed in Datasheet or Design view. When in Design view, the querys structure, properties, and function may be modied.

ru c

DU

The Query Design Environment

50

PL

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 information 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 Design Wizard, you can create those custom queries and bring your dreams to life.

Microsoft Ofce Access 2003 Level 1

IC

AT

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 commonly 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 database responsibilities. You will also use the Query Design Wizard to create a query.

rE

di tio n

LESSON 4
The Query Design Buttons The following table describes a few of the buttons on the Query Design toolbar. Icon Button Name
Query Type Run Show Table Totals Properties

Description

Runs the query and displays the results. Opens the Show Table dialog box.

Adds the Totals row to the query in Design view. Opens the query property sheet.

Build

Launches the Expression Builder.

rE
NO T DU

to
DO

5 minutes Data Files: SelectQueries.mdb

Scenario: Your manager has asked you to nd out which of the companys computers arent covered by a warranty. You decide to use a Select query in order to quickly gather this information.

Lesson 4: Querying the Database

In st

ru c

PL

Activity Time:

IC

Examining the Select Query Type

AT
51

ACTIVITY 4-1

di tio n

Selects the query type.

LESSON 4
What You Do 1. In the SelectQueries database, open the qryNoWarranty query and examine the datasheet, and then switch to Design view. How You Do It a. Open the SelectQueries database.

rE to ru c In st
52

DO

NO

DU
d. Click the View button to change to Design view.

PL
Microsoft Ofce Access 2003 Level 1

IC

AT

di tio n

b. With Queries selected in the Objects pane, double-click qryNoWarranty to open the query.

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

LESSON 4
2. In the Warranty column, change the criteria from No to Yes and run the query. a. In the design grid, in the Criteria row of the Warranty field, select No. b. Replace it with Yes c. Click the View button to return to Datasheet view. 3. How many records are now displayed? a) 7 b) 12 c) 19 d) 25 4. Close the qryNoWarranty query window without saving changes to the design of the query.

a. Click Close. b. Click No.

Procedure Reference: Create a Select Query To create a query using the wizard:
1. 2. 3. 4. 5. 6. 7. 8. 9.

to
DO

In the Database window, in the Objects pane, select Queries. Double-click Create Query By Using Wizard.

Select the rst table (or query) you wish to include in the query. Add the elds you wish to include to the Selected Fields list.

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

Click Next.

Lesson 4: Querying the Database

In st

Name the query and select whether you want to open the query in Datasheet view or Design view.

10. Click Finish.

NO

Select whether you want to view detail or summary information.

Click Next.

ru c

DU

PL

IC

AT
53

How to Create a Select Query

rE

di tio n

LESSON 4

ACTIVITY 4-2
Creating a Select Query
10 minutes Setup: The SelectQueries.mdb database is open.

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 elds in the tblComputers and tblManufacturers tables. By using the Query Wizard, you can create a query to locate and display the required data.
What You Do 1. Launch the Query Wizard. How You Do It

rE
NO T

to
DO

ru c In st
54

DU

b. Click the right-pointing single arrow to add the AssetTag field to the Selected Fields box. c. In the Available Fields list box, select DateReceived. d. Click the right-pointing arrow.

PL
Microsoft Ofce Access 2003 Level 1

IC

AT

2.

Using tblComputers, add the AssetTag, DateReceived, and PurchasePrice fields to the Selected Fields box.

a. From the Tables/Queries drop-down list, select Table: tblComputers.

di tio n

Activity Time:

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

LESSON 4
e. In the Available Fields list box, doubleclick PurchasePrice.

3.

Using the tblManufacturers table, add the Manufacturer field to the query.

a. From the Tables/Queries drop-down list, select Table: tblManufacturers. b. In the Available Fields list box, doubleclick Manufacturer. c. Click Next.

4.

5.

b. Verify that Open The Query To View Information is selected and click Finish. c. In the toolbar, click the View button to change to Design view. The two tables are displayed and are joined on the ManufacturerID field. The fields you selected in the wizard are in the design grid.

to ru c In st
Lesson 4: Querying the Database

d. Close the query.

DO

NO

DU

PL

IC

AT

Give your query a title of qryMyBrands, complete the process and view the results of the query, and then examine the query in Design view.

E
55

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

rE

Verify that you want to see the detail records and continue.

a. Verify that Detail is selected, and then click Next.

di tio n

LESSON 4

TOPIC B
Add Criteria to a Query
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. Lets 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 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 extract it, but how do you do it? By incorporating comparison operators and conditional operators into your query, youll be able to access this information.

Comparison Operators

Operator
= < <= > >= <>

Value

Example
<K >K

to
Equals Less than Greater than Not equal to Within a range Null values

= 11/29/1961

Less than or equal to Greater than or equal to

ru c
Between And Is Null

T NO

In st

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 exibility and power. The Conditional Operators The following table summarizes the conditional operators.

DO

Conditional Operators

DU

56

PL

<= 2500

>= 2500 <> Michigan

Between 5/1/2001 And 8/31/2001 Is Null (just using Null will also work)

Microsoft Ofce Access 2003 Level 1

IC

AT

The Comparison Operators The following table summarizes the comparison operators.

rE

Including the comparison operators in an expression allows one data value to be compared against another, using a set of criteria that has been dened by the user. (An expression is a combination of symbols that produces a result. Youll learn more about them in the next topic.)

di tio n

LESSON 4
Operator
AND OR NOT

Description
True if both conditions are true True if either condition is true True if the single instance is not true

Example
> 5 AND <> 100 < 5 OR > 500 NOT Between 100 And 200

Examples of Conditional Operators The premise on which conditionals are based is that of truth. If the criteria in the expression are met, it is evaluated to be true. If the criteria is not met, it is evaluated to be false.

rE
NO T

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 eld is greater than $100, you could type >100 in the criteria row that is below the price eld. Using ANDs and ORs would allow you to expand or narrow the search. If you want to select all the records where the price eld is greater than $100 AND where the location of the sale is the state of California, you would add the word California to the criteria row below the State eld. Both criteria should be placed on the 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. 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 eld is greater than $100 as well as all records where the state eld is equal to California. Some prices may well be less than $100but if they are in California, they meet the criteria. Some sales may be in Michigan, but as long as they are over $100, they meet the criteria.

to
DO

How to Add Selection Conditions to the Query


Procedure Reference: Add Selection Conditions to the Query To add selection criteria:
1. 2. 3. 4. 5.

Lesson 4: Querying the Database

In st

In the design grid, include the eld or elds for which you want to set criteria. Enter the rst criterion in the Criteria row for the eld. To create an AND or OR condition on a single eld, include the appropriate word in the criteria. To create an AND condition on more than one eld, enter the other criteria in the same Criteria row. To create an OR condition on more than one eld, enter the other criteria in the Or row.

ru c

DU

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 either state. Typing California and Michigan in a state criteria row would return no records, because the value in the state eld cannot be equal to both.

PL

IC

AT

E
57

di tio n

LESSON 4

ACTIVITY 4-3
Adding Selection Conditions to the Query
10 minutes

Setup: The SelectQueries Database window is displayed.

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 specic price, department code, or manufacturer criteria, and even looking for Null or blank elds in records will familiarize you with the operation of these features.
What You Do 1. 2. How You Do It

Run the qryInventory query.

rE
NO T

How many records are displayed? a) 11 b) 21 c) 23 d) 32

to
DO

3.

ru c

In st

DU

In Design view, use the > comparison operator in the PurchasePrice fields Criteria row to determine which computers cost more than $2,000, and then run the query.

a. Click the Design view button. b. Scroll to the right to view the PurchasePrice field in the design grid. c. Click in the Criteria row for the PurchasePrice field. d. Type >2000 e. Click the Datasheet view button and note that six records satisfy the condition.

58

PL

Microsoft Ofce Access 2003 Level 1

IC

AT

di tio n
a. Double-click qryInventory.

Activity Time:

LESSON 4
4. Remove the PurchasePrice criteria and set the DeptCode equal to 500, choose to not display the DeptCode field in the query datasheet, and then run the query.
You do not have to enter the equal sign = in the criteria, and you do not have to display the eld you use to set a condition.

a. Switch to Design view. b. In the PurchasePrice field, delete the >2000 criteria. c. Click in the Criteria row for the DeptCode field. d. Type 500

e. In the Show row, uncheck the box for the DeptCode field. f. Switch to Datasheet view and observe the data.

5.

c. Type Atlas

rE
NO T

Switch to Design view, and in the Manufacturer fields Criteria row enter Atlas to add Atlas to the criteria. Then, return to Datasheet view.

a. Switch to Design view.

b. Click in the Criteria row for the Manufacturer field.

to
6.

In st

d. Type Cyber e. Switch to Datasheet view to run the query.

Remember that you can create AND and OR conditions for the same eld by including those operators in the criteria. For example, if you wanted to know how many Atlas and Cyber computers you have, you can enter the criteria Atlas or Cyber.

Lesson 4: Querying the Database

DO

Switch to Design view and delete the existing condition in the Criteria row of the Manufacturer field, click in the Or row of the Manufacturer field and enter the manufacturer name Cyber, and then switch to Datasheet view to run the query and examine the results.

ru c

a. Switch to Design view.

b. In the Criteria row of the Manufacturer field, delete the existing condition. c. In the Manufacturer field, click in the Or row.

DU

PL

e. Examine the results. Only two records satisfy this condition. By entering two conditions on the same Criteria row in the design grid, you create an AND condition and records must satisfy both conditions to be displayed in the query datasheet.

IC

AT

d. Switch to Datasheet view.

E
59

di tio n

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

All computers assigned to the Technical Services department are included, as well as records for Cyber computers assigned to any department. 8. Use the Between operator to create the criteria to determine how many computers were acquired during the first quarter of 2001.
Access automatically enters pound signs (#) around date values.

b. In the upper pane, right-click the tblDepartments table. c. Choose Remove Table. d. Remove the tblManufacturers table from the query.

to ru c In st
60

T NO
f. i.

DO

DU

e. In the DateReceived field, delete the criteria. In the Criteria row for the ManufacturerID field, type Is Null

g. Run the query and note that there are three records. h. Save the query as qryMyMissingValues and click OK. Close the query window.

PL

Microsoft Ofce Access 2003 Level 1

IC

AT

9.

Use the Null operator to create a criterion in the tblComputers table to locate records with a blank value and save the query as qryMyMissingValues.

rE

di tio n
a. Switch to Design view. c. Click in the Criteria row for the DateReceived field. a. Switch to Design view.

b. Delete the Cyber and 500 criteria.

d. Type Between 1/1/2001 And 3/30/2001 e. Run the query and verify that six records are displayed.

TOPIC C
Add a Calculated Field to a Query
The ability to use Access comparison operators and conditional operators has greatly expanded your querying capacity. Now lets 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 querys output.

LESSON 4

Managing money is an important function in all businesses, and for that matter, in your day-today life. Imagine that your companys payroll department wants you to calculate the weekly salary for an individual who is paid by the hour. By including a calculated eld that uses the employees hourly rate, this is easily accomplished.

Arithmetic Operators

Operator
+ * /

Description
Addition Subtraction Multiplication Division

Example

Result

to
value1 + value2 value1 - value2 value1 / value2 value1 * value2

Value1 is added to value2 Value2 is subtracted from value1 Value1 is multiplied by value2 Value1 is divided by value2

In st

2. 3. 4.

Division

Addition

Subtraction

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

Lesson 4: Querying the Database

DO

Simply put, Access expressions are combinations of identiers, operators, and values that produce a result. Arithmetic expressions are composed of table data and the arithmetic operators + - * / . An expression may be simple or complex, but it usually results in a single value. The calculations are performed in a specic order, with the order of evaluation taking place from left to right. Precedence is dictated by the operators, in the following order: 1. Multiplication

NO

Access Expressions

ru c

DU

PL

IC

AT
61

The Arithmetic Operators The following table summarizes the arithmetic operators.

rE

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 behave in a similar manner.

di tio n

LESSON 4

ACTIVITY 4-4
Calculating Arithmetic Expressions
5 minutes

Scenario: 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.
What You Do 1. What is the answer to: 4 + (3 * 5)? a) 12 b) 14 c) 17 d) 19 e) 35 2. How You Do It

rE
NO T DU

a) 35 b) 12 c) 19 d) 17 e) 60

to
DO

The Expression Builder

The Expression Builder is a tool that allows the user to select database objects and then, using the applications built-in operators and functions, build formulas and calculations that are used with queries and reports.

In st

ru c

62

PL
Microsoft Ofce Access 2003 Level 1

IC

AT

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

di tio n

Activity Time:

LESSON 4

The following table describes the components that comprise the Expression Builder.

rE
NO T

Figure 4-2: The Expression Builder.

Component
Expression box Operator buttons Left box Middle box Right box

Function

The location where the expression is built.

How to Add a Calculated Field to the Query


To add an arithmetic calculation:
1. 2. 3. 4.

In the query design grid, right-click in the rst available blank column. Choose Build.

Using the operator buttons and the lists of elds and functions, select and paste each component of the expression. Click OK to enter the expression in the design grid.

Lesson 4: Querying the Database

DO

Procedure Reference: Add a Calculated Field to a Query

In st

ru c

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

DU

If a left box folder is opened, the middle box will display the elements within that folder.

PL

Displays the table, query, form, report object, user-dened function, and other folders.

IC

The location where the operators used in the expression are selected.

to

AT
63

di tio n

LESSON 4

ACTIVITY 4-5
Adding a Calculated Field to the Query
10 minutes Setup: The SelectQueries database is open.

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 eld, you can accomplish this task.
What You Do 1. Open the qryPayRates query in Design view and run the query. How You Do It

rE
NO T

to
DO

ru c

In st

DU

2.

Switch to Design view, right-click in the first blank column in the design grid and use the Expression Builder to create an arithmetic expression that multiplies weekly hours by the rate of pay, and then run the query and check the calculation.

a. Switch to Design view. b. In the design grid, right-click in the first blank column to the right and choose Build to open the Expression Builder. c. In the Expression Builder operator bar, click the equal sign (=). d. In the field list (the middle column), double-click WeeklyHours. Notice that the field name is added to the expression and is enclosed in brackets. e. In the operator bar, click the multiplication sign (*).

64

PL

d. Switch to Datasheet view to run the query.

Microsoft Ofce Access 2003 Level 1

IC

AT

c. Observe the design. It includes a tblHoursAndRates table and will display a list of employees and their hours and rates.

di tio n

Activity Time:

a. Right-click the qryPayRates query. b. From the shortcut menu, choose Design View.

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

g. Click OK to close the Expression Builder. h. Run the query. 3. What is Rob Abbotts weekly pay? a) 56 b) 250 c) 760 d) 2,500

rE to
DO
a. Switch to Design view.

4.

ru c

b. Right-click the calculated field and choose Zoom. c. Select Expr1 and type WeeklyGross d. Click OK to close the Zoom dialog box.

Lesson 4: Querying the Database

In st

NO

DU

Open the Zoom dialog box, change the name of the calculated field to WeeklyGross, and then run the query.

PL

Notice that the calculated field has a column heading of Expr1 and the values have a general number format.

IC

AT
65

di tio n

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

5.

Switch to Design view, open the Field Properties dialog box for the WeeklyGross field and set the Format property to Currency, and then run the query.

rE to
DO NO
f. 6.

ru c

In st

DU

Save the query as qryMyWeeklyGross, and then close it.

a. Save the query as qryMyWeeklyGross b. Click OK. c. Close the select query.

66

PL

Run the query and observe that the calculated values are displayed in currency format.

Microsoft Ofce Access 2003 Level 1

IC

AT

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

di tio n
a. Switch to Design view. d. From the drop-down list, select Currency.

b. Right-click the WeeklyGross field and choose Properties. c. Click in the Format property box.

TOPIC D
Perform a Calculation on a Record Grouping
You now know how to use a query to perform a calculation on a single record. It is also 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 calculation using all of the values in one of the groups elds. One common, on-the-job use for Access is calculating payrolls by department. Developing a 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.

LESSON 4

How to Perform a Calculation on a Group of Records


Procedure Reference: Perform a Calculation on a Record Grouping To perform a calculation on a group of records:
1. 2. 3. 4.

rE
NO T

Click the Totals button to display the Total row.

to
DO

Enter any criteria necessary to select the records you wish to view.

5. 6.

For each eld, from the Total drop-down list, select Group By or the summary function. Run the query.

Lesson 4: Querying the Database

In st

ru c

DU

PL

If you need to enter criteria for a eld on which you are not grouping records, include that eld in the design grid and, from the Total drop-down list, select Where.

IC

AT
67

To the design grid, add the eld(s) on which you want to group records and the eld(s) you wish to summarize.

di tio n

LESSON 4

ACTIVITY 4-6
Performing a Calculation on a Group of Records
10 minutes Setup: SelectQueries.mdb is open.

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.
What You Do 1. 2. Run the qryWeeklyInfo query. How You Do It

to
NO DO

Remove the LastName and FirstName columns from the design grid.

ru c

4.

In st

In the Total row for the WeeklyHours field, enter the appropriate summary function to calculate the average weekly hours for each department.

DU

b. Press Delete. c. Select and delete the FirstName column. a. Click in the Total row for the WeeklyHours field. b. From the drop-down list, select Avg.

68

PL

3.

a. In the design grid, place the mouse pointer over the selector for the LastName column until it becomes a downward-pointing arrow and click to select the column.

Microsoft Ofce Access 2003 Level 1

IC

c. Examine the Total row that has been added to the grid.

AT

Switch to Design view and, on the toolbar, click the Totals button to add the Total row to the design grid.

rE

b. Click the Totals button

di tio n
a. Run the qryWeeklyInfo query. a. Switch to Design view. .

Activity Time:

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

d. Compare your results to the following graphic.

6.

to ru c
f. 7.

d. Click in the Format property box. e. From the drop-down list, select Fixed. From the Decimal Places drop-down list, select 1.

In st

b. Save the file as qryMyTotals and close the datasheet. c. Close the database.

Lesson 4: Querying the Database

DO

Run the query, save the query as qryMyTotals and close the datasheet window, and then close the database window.

a. Run the query.

NO

g. Close the Field Properties dialog box.

DU

PL

IC

c. Right-click the WeeklyHours field and choose Properties.

AT
69

b. Switch to Design view.

Switch to Design view and modify the format of the WeeklyHours field to display the average with one decimal place.

a. If necessary, size the columns so you can see the full column headings.

rE

di tio n

LESSON 4
Lesson 4 Follow-up
In this lesson, you created a query. Working in a querys Design view, you also customized queries by adding comparison and conditional operators. You then used the Expression Builder to add a calculation to a eld. Finally, you performed a calculation on a record grouping.
1. What are the two views used with a query, and which view can be used to modify the query? The two views are the Datasheet and Design views. The Design view is used to modify the query. 2. What are the three types of operators used to build query expressions, and how are they used? The three types are the comparison operators, the conditional (or Boolean) operators, and the arithmetic operators. The comparison operators are used to compare one value against another, the conditional operators are used to test a value against a specified condition, and the arithmetic operators are used to build arithmetic expressions.

rE to ru c In st
70

DO

NO

T
Microsoft Ofce Access 2003 Level 1

DU

PL

IC

AT

di tio n

LESSON 5

LESSON 5
Designing Forms
In this lesson, you will design simple forms. You will: Discuss the form design overview. Create a form with the AutoForms feature.

Create a form with a hidden object using the wizard.

rE
NO T

Select and modify objects on a form to change the design of the form.

to In st
Lesson 5: Designing Forms

DO

ru c

DU

PL

IC

AT
71

di tio n

Lesson Time 1 hour(s)

LESSON 5
Introduction
You have seen several different ways to manage data. On the job, you may be required to enter and update data on a regular basis. A custom form stored in your database that can be recalled each time you are required to perform these tasks can make life much simpler. In this lesson, you will create custom forms, and then modify the forms to meet your specic needs. When opening a table in Datasheet view, the entire table, including all of the records and every eld in each record, is displayed. In large tables with thousands of records, this can be overwhelming. Searching for individual records or elds can be time consuming, and the 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 reduce errors.

TOPIC A

Examine Form Design Guidelines

to
DO

AutoForms

An AutoForm is a one-click form creation tool that automatically creates a form displaying every eld in all records from the table or query on which it is based.

ru c

In st

Figure 5-1: An AutoForm.


Microsoft Ofce Access 2003 Level 1

72

NO

DU

PL

IC

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 basic form design principles, you can develop forms that help ensure an efficient and error-free data entry process.

AT

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 appreciated by all. In this topic, you will identify some of the design principles that should be applied to any form.

rE

di tio n

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

By default, the AutoForm button places all elds from the underlying table or query on the form.

When launched with the New Object: AutoForm button, the nal form displays one record per page in what is called the columnar layout.

When working with multiple tables and/or when only specic elds need to be shown from a table, a query should be created rst. The AutoForm button can be created from the query. The AutoForm option is also available from within the form object in the Database window by clicking the New button. This option allows the user to select from multiple layout options.

Offers design choices for both tabular and datasheet views.

Columnar

ru c

Tabular

In st

Datasheet

Multiple records appear per page. Looks and feels like a spreadsheet to the user. Designer has minimal control over eld placement and formatting.

Justied

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

Lesson 5: Designing Forms

DO

Multiple records appear per page. Navigation typically done using the scroll bar. Field placement can be modied and individual eld controls can be formatted.

NO

One record appears per page. Navigation buttons used to scroll through records. Field placement easily modied. Ability to modify eld controls (e.g., fonts, colors, and background).

DU

Form Layout

Features

PL

IC

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

to

AT
73

Can build a form based on more than one table.

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.

rE

The Form Wizard

di tio n

It can be used directly on a table or query using the New Object: AutoForm button.

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

rE
NO T DU
How You Do It

Figure 5-2: A form displayed in Design view.

Examining the Form Design Guidelines


Activity Time: 5 minutes

Scenario: Reviewing some common-sense examples of the form design guidelines can assist you when you develop your rst form.

In st

What You Do 1.

When designing a form, who should you keep foremost in mind? a) Your boss b) Your co-worker d) The consultant

c) The user

DO

ru c

74

PL

ACTIVITY 5-1

to

Microsoft Ofce Access 2003 Level 1

IC

AT

di tio n

The Footer section is where the information to be displayed at the bottom of the form is located.

LESSON 5
2. In Design view, which section of a form would typically contain page numbering information? a) Header b) Detail c) Footer 3. Which of the Form Wizard layout styles shows multiple records per page? a) Columnar b) Tabular c) Datasheet d) Justified

Create a Form Using AutoForm

rE
NO T

TOPIC B

to
DO

How to Create an AutoForm


Procedure Reference: Create an AutoForm To create an AutoForm:
1. 2. 3. 4.

In the Database window, in the Objects pane, select Tables. From the table list, select the table for which you want to create an AutoForm. Click the NewObject: AutoForm button. Save the form.

Lesson 5: Designing Forms

In st

ru c

DU

Even the most experienced form designers need time to plan and create custom forms. Until 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 dont wish to invest the time to plan and create the perfect form. By using the AutoForm feature, you can quickly create a basic default form that can be used with any designated table.

PL

IC

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 principles, developing the perfect form requires time, which you dont have. Luckily, the AutoForm tool will allow you to create a usable form in a minimum amount of time.

AT

E
75

di tio n

LESSON 5

ACTIVITY 5-2
Creating a Form with the AutoForm Feature
5 minutes Data Files: UseForms.mdb

Scenario: A co-worker has asked if you can create a form to access data in the UseForms databases tblCustomers and tblEmployees tables. By using the AutoForms Wizard, you can produce forms for both tables.
What You Do 1. Open the tblCustomers table. How You Do It

3.

to
DO

ru c

NO

In st

6.

Create an AutoForm based on the tblEmployees table, with a link to another table that includes a subdatasheet display.

T
c. Type frmMyCustomers d. Click OK. e. Close tblCustomers. a. From the list of tables in the UseForms Database window, select tblEmployees. b. From the toolbar, click the New Object: AutoForm button.

DU

5.

Close the form and save it as frmMyCustomers.

a. Click the Close button to close the tblCustomers form. b. Click Yes.

76

PL

4.

True True or False? New records can be added to the table with the AutoForm you created.

Microsoft Ofce Access 2003 Level 1

IC

True True or False? The number of fields in the form is the same as the number of fields in the table.

AT

2.

Create an AutoForm based on the tblCustomers table.

rE

di tio n

Activity Time:

a. With the UseForms database open, open the tblCustomers table. a. On the toolbar, click the New Object: AutoForm button .

LESSON 5
c. Examine the form.

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

7.

8.

to
DO

b. Click the collapse indicator (-).

ru c In st
Lesson 5: Designing Forms

b. Click and drag the right edge of the form window to the right. c. Place the mouse pointer over the right edge of the datasheet. The horizontal sizing pointer is not displayed; the size of the datasheet must be adjusted in the forms Design view.
Column widths in the datasheet can be adjusted by dragging the right edge of the column heading.

NO

DU

PL

9.

Use the mouse pointer to widen the form window, and then attempt to widen the datasheet to view the entire record.

a. Place the mouse pointer over the right side of the form window until it becomes a horizontal double-headed arrow.

IC

AT

E
77

Expand the subdatasheet, and then close the subdatasheet.

a. In the first record displayed in the AutoForm, click the expand indicator (+) and notice that related data from a third table is displayed.

rE

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

di tio n

LESSON 5
10. Save and close the form. a. Save the form as frmMyEmployees and close the form. b. Close any open tables.

TOPIC C

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 data in an easily understood format and provides the user with a virtually error-proof data entry capability.

rE
NO T

How to Create a Form with the Form Wizard

to
DO

Procedure Reference: Create a Form with the Form Wizard

1. 2. 3. 4. 5. 6.

In the Database window, in the Objects pane, select Forms.

In st

ru c
7. 8. 9. 10. Click Finish. 11. Close the form.

From the Tables/Queries drop-down list, select the rst data source for the form. Add the elds you want in the form to the Selected Fields list. Repeat Steps 3 and 4 for any additional data sources and elds. Click Next. If you have elds 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 related data. Click Next. Choose the form layout and click Next. Choose the form style and click Next. Enter a title for the form and, if necessary, the subform. Select the view in which you want to open the form.

DU

Double-click Create Form By Using Wizard.

78

PL

To create a form with the wizard:

Microsoft Ofce Access 2003 Level 1

IC

AT

As the person in your business who has received training in Access, you may be looked upon 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.

di tio n

ACTIVITY 5-3
Creating a Form with the Form Wizard
10 minutes Setup: The UseForms database is open. Activity Time:

LESSON 5

Scenario: This time, your manager has asked you to create a more complex form that displays all of the elds from the tblEmployees table and the AssetTag, DateReceived, PurchasePrice, and Warranty elds from the tblComputers table of the UseForms database. He would also like a particular layout applied to the nished product. The Form Wizard will allow you to complete this task.
What You Do 1. Start the Form Wizard. How You Do It

a. In the Objects pane, select Forms. b. Double-click Create Form By Using Wizard.

rE
NO T

to
f.

In st

g. Click the right-pointing single arrow.

Lesson 5: Designing Forms

DO

ru c

c. From the Tables/Queries drop-down list, select Table: tblComputers. d. In the Available Fields list, verify that AssetTag is selected. e. Click the right-pointing single arrow. In the Available Fields list, select DateReceived.

DU

b. Click the right-pointing double arrow to add all the fields in the table to the Selected Fields list.

PL

IC

2.

Add all the tblEmployees fields to the form, and then, from the tblComputers table, add the AssetTag, DateReceived, PurchasePrice, and Warranty fields.

a. From the Tables/Queries drop-down list, select Table: tblEmployees.

AT
79

di tio n

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

3.

rE
NO T
f.

to In st
DO

e. Select Linked Forms and observe the preview.

ru c
80

DU
Select Form With Subform(s). g. Click Next.

PL

Microsoft Ofce Access 2003 Level 1

IC

d. Verify that Form With Subform(s) is selected and observe the preview.

AT

c. Select by tblEmployees.

Preview the form, decide whether you want a form with subforms or linked forms, and select the option that enables you to open only one form. Continue to the next page of the wizard.

di tio n
i. Click Next.

a. Observe the preview of the form. The view is by tblEmployees.

b. Select by tblComputers and observe the preview.

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

a. In the list of styles, select each style and observe the preview. b. Select the style you prefer. c. Click Next.

6.

Give the form a title of frmMyEmployees2, give the subform a title of sbfMyComputersSubform, and then open the form.

a. In the Form text box, type frmMyEmployees2

b. In the Subform text box, type sbfMyComputersSubform

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

rE
NO T

to
DO

TOPIC D

Modify the Design of a Form

The form you created with the wizard is perfectly usable and fullls its intended function. But, after using the form for a while, youve identied some possible changes in the design and 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 errorproof, and you will continue to enhance your reputation as the corporate Access expert.

Lesson 5: Designing Forms

In st

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 forms controls, and change the title of some of the labels. In this topic, you will modify the size, alignment, positions, and labels of the controls on your form.

ru c

DU

PL

IC

7.

Close the form.

a. Click Close.

AT
81

d. Click Finish and examine the form.

di tio n

LESSON 5
Controls
Denition: A control is an object that allows the user to control the program. Controls are used to 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-signicant names so that their purpose is easily identied by the user. Example: Some examples of controls include text boxes, labels, rectangles, combo boxes, lines, and graphics.

rE to
DO
Figure 5-3: Examples of controls.

Selecting Form Controls

Select contiguous controls with the lasso technique. Use the appropriate ruler to select all of the controls in a horizontal or vertical line. Use the Shift-click technique to select non-contiguous controls.

In st

NO

To modify a forms controls, they must rst be selected. There are four methods of selecting controls: Click to select a single control.

ru c

DU

82

PL
Microsoft Ofce Access 2003 Level 1

IC

AT

di tio n

ACTIVITY 5-4
Selecting Controls
5 minutes Setup: The UseForms.mdb database is open. Activity Time:

LESSON 5

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 forms.
What You Do 1. Open the frmSelectControls form in Design view and select the text box control holding the CustomerName field, and then select the label control for the field. How You Do It

a. Open the frmSelectControls form in Design view.

rE
NO T

to In st
2. Use the lasso technique to select controls and observe the selection handles, and then deselect the controls.

a. Position the mouse pointer above and to the left of the CustomerName label.

Lesson 5: Designing Forms

DO

ru c

c. Click the label control for the CustomerName field. The label control has selection handles and the text box has only a move handle.

DU

PL

IC

AT

b. Click the text box containing the CustomerName field. Note that the control has selection handles on all sides.

E
83

di tio n

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

3.

Use the click-in-ruler technique to select the labels and text boxes, observe the selection handles, and then deselect the controls.

rE to ru c In st
84

b. Click a blank portion of the form to deselect the controls.

DO

NO

T
Microsoft Ofce Access 2003 Level 1

DU

PL

IC

AT

di tio n

c. Click a blank portion of the form to deselect the controls. a. Click the vertical ruler at the 1.75-inch mark and observe the selection handles.

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

c. Deselect the controls. 5. Using the Shift-click technique to select controls, observe the selection handles and deselect the controls. a. Click the CustomerID text box.

rE
NO T

b. Click and drag the 0.5-inch mark on the horizontal ruler to about the 1.5-inch mark and observe the selection handles.

to
DO

c. Release the Shift key.

Sizing Form Controls

Sizing controls to be proportionate to their use is a critical design component. There are three methods of sizing controls: Drag a sizing handle to increase or decrease the size. From the menu, choose FormatSizeTo Fit. Select multiple controls, choose FormatSize, and choose whichever option is appropriate.
The same options available from the Format menu are available by right-clicking a selected control and choosing Size from the shortcut menu.

Lesson 5: Designing Forms

In st

ru c

d. Click a blank area to deselect the controls.

DU

PL

IC

b. Press and hold the Shift key, and then click both the Fax text box and the PostalCode text box.

AT
85

di tio n

LESSON 5

ACTIVITY 5-5
Sizing Controls
5 minutes

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

Scenario: Youve found that when you create an AutoForm or a form with the wizard, the controls are not always the right size. Sometimes theyre bigger than you need or they occupy extra space on the form. Other times, theyre not big enough and you cant view all of the data from a eld. You want to make them the correct size.
What You Do 1. View the data in three records. How You Do It

rE
NO T

2.

Which text box controls appear to be too small?

to
DO

b) Postal Code label d) Region label

In st

ru c
86

DU
Microsoft Ofce Access 2003 Level 1

PL

c) Postal Code text box

IC

a) Address text box

AT

di tio n
a. Switch to Form view.

Activity Time:

b. On the navigation bar, click the Next Record button three times.

LESSON 5
3. In Design view, resize the CustomerID and the Address text boxes. a. In Design view, click the CustomerID text box. b. Place the mouse pointer over the sizing handle in the middle of the right side of the text box until it becomes a horizontal 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 width.

4.

to
DO

Size the PostalCode text box to fit its contents.

a. Click the PostalCode text box. b. Choose FormatSizeTo Fit.

5.

ru c

b. Press and hold the Shift key and click the Customer Name text box.

d. Click the Undo button. a. Select the Fax and Phone text boxes. b. Right-click one of the selected text boxes. c. Choose SizeTo Narrowest.

Lesson 5: Designing Forms

In st

6.

Make the Fax text box the same size as the Phone text box.

NO

c. Choose FormatSizeTo Tallest.

DU

Make the CustomerID text box the height of the CustomerName text box, and then undo the sizing.

a. Click the CustomerID text box.

PL

IC

AT
87

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

rE

c. Click the Address text box.

di tio n

LESSON 5
7. Save the form as frmMyControls, and then view the form. a. Choose FileSave As. b. Save the form as frmMyControls c. View the form.

Aligning and Spacing Form Controls

Aligning controls and adjusting the spacing between them improves the appearance of a form or report. To do this: 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 either FormatHorizontal Spacing or FormatVertical Spacing. You can choose to adjust the spacing by selecting Make Equal, Increase, or Decrease.

to
DO

5 minutes

Setup: The frmSelectControls form of the UseForms database is displayed. Scenario: The format of frmSelectControls looks better, but the alignment still needs some work. By using alignment techniques you can improve the appearance.
What You Do 1.

ru c

NO

In st

With frmSelectControls open in Design view, align the right side label controls.

DU

How You Do It a. In Design view, click the horizontal ruler to select the CustomerID, Phone, Address, and City label controls. b. Right-click one of the selected controls and choose AlignRight.

88

PL

Microsoft Ofce Access 2003 Level 1

IC

Activity Time:

AT

Aligning and Spacing Controls

ACTIVITY 5-6

rE

di tio n

LESSON 5
2. Align the Phone and Fax labels and text boxes so the bottoms of the controls are even. a. Use the vertical ruler or the lasso technique to select the Phone and Fax labels and text boxes. b. Right-click a selected control and choose AlignBottom. 3. Make the spacing of the City, Region, Country, and PostalCode labels and text boxes equal. a. Select the City, Region, Country, and PostalCode labels and text boxes.

b. Choose FormatHorizontal Spacing Make Equal. 4. View and then save and close the form. a. View the form.

b. Save and close the form.

Moving Form Controls

to
DO

ru c
Lesson 5: Designing Forms

In st

NO

DU

PL

If you want to move the text box or label and its associated component, or a grouping of controls, the mouse pointer should look like a hand with all of the ngers extended .

IC

AT
89

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 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 nger

rE

di tio n

LESSON 5

ACTIVITY 5-7
Moving Controls
10 minutes Setup: The UseForms database is open.

Scenario: A few nal 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.
What You Do 1. Move the CustomerName text box closer to its label. How You Do It

rE
NO T

b. Select the CustomerName text box. 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 pointing finger. d. Click and drag the text box to the left to place it closer to the CustomerName label. a. Click the CustomerID text box. b. Place the mouse pointer over the top or bottom edge of the text box until it becomes an open hand. c. Click and drag the label and the text box to the upper-left corner of the form.

to
2. Move the CustomerID label and text box to the upper-left corner of the form.

In st

DO

ru c

DU

90

PL

Microsoft Ofce Access 2003 Level 1

IC

AT

di tio n

Activity Time:

a. In the UseForms Database window, rightclick frmMoveControls and choose Design View.

LESSON 5
3. Move the Fax label closer to the Fax text box. a. Click the Fax label. b. Place the mouse pointer over the move handle in the upper-left corner of the label until it becomes a hand with a pointing finger. c. Click and drag it closer to the Fax text box. 4. Move all the labels and text boxes containing address information lower on the form. a. Use the ruler or lasso technique to select all of the labels and text boxes containing address information.

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

c. Click and drag the controls down on the form. 5. Close the form without saving changes. a. Click the Close button. b. Click No.

rE
NO T

to
DO

How to Modify a Form


To modify a form:
1. 2. 3.

Procedure Reference: Modify a Form

Display the form in Design view.

Select the controls you wish to work with.

Move the 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 nger. If you want to move the text box or label and its associated component, or a grouping of controls, the mouse pointer should look like a hand with all of the ngers extended.

Lesson 5: Designing Forms

In st

4.

Size the controls. Drag a sizing handle to increase or decrease the size. From the menu, choose FormatSizeTo Fit. Select multiple controls, choose FormatSize, and choose whichever option is appropriate.

ru c

DU

PL

IC

AT
91

di tio n

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

5.

Align the controls and adjust their spacing.

To even out horizontal or vertical spacing of controls, select the controls and choose either FormatHorizontal Spacing or FormatVertical Spacing. You can choose to adjust the spacing by selecting Make Equal, Increase, or Decrease.

6.

If necessary, adjust the tab order of the form elds. a. In Design view, choose ViewTab Order. b. c. Click OK.

In the Tab Order dialog box, click Auto Order.

7. 8. 9.

Apply formatting to text boxes or labels. Add a title or other descriptive text. Change the size of the form.

10. Save your changes under an appropriate name.

rE
NO T

to
DO

Modifying a Form
Activity Time: 10 minutes

Setup: The UseForms Database window is displayed.

In st

Scenario: 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 form, you will turn it into a professional looking creation your organization will be proud of.

ru c

DU
Microsoft Ofce Access 2003 Level 1

92

PL

IC

AT

ACTIVITY 5-8

di tio n

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.

LESSON 5
What You Do 1. Open the frmGSCCustomers form and size the form to the screen. How You Do It a. Right-click frmGSCCustomers and choose Design View. b. Place the mouse pointer over the lowerright corner of the form window until it becomes an angled double-headed arrow. c. Drag down and to the right to enlarge the window.

d. Place the mouse pointer over the right edge of the form until it becomes a vertical line with a horizontal doubleheaded arrow. e. Click and drag the edge of the form to the 6-inch mark on the right of the ruler. f.

rE
NO T

2.

to
DO

Lesson 5: Designing Forms

In st

ru c

c. Size the Phone and Fax text boxes and move the labels closer to the text boxes. d. Align the controls so they are similar to the following graphic.

DU

PL

Using selection, moving, sizing, and alignment techniques, arrange the controls on the form so that it is similar to the graphic shown in Step 2d.

a. Move the CustomerName controls up next to the CustomerID controls.

b. Move the Address controls down on the form so you have room to arrange the Phone and Fax controls.

IC

AT
93

Place the mouse pointer over the bottom edge of the form and drag the edge down to the 3-inch mark.

di tio n

LESSON 5
3. Switch to Form view and check the tab order. a. Switch to Form view. b. Press the Tab key eight times to move from the first field in the form to the last. The Phone field would logically follow the CustomerName field in the forms new layout, but the tab order is based on the original layout. a. Switch to Design view.

4.

Return to Design view and correct the tab order.

5.

Return to Form view and check the tab order.

b. Close the form, then close the database.

to
DO NO

Lesson 5 Follow-up

In this lesson, you rst 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 specic needs.
1. What is the primary difference between creating a form with the AutoForm feature and the Form Wizard? The Form Wizard allows you flexibility in the design and structure of the form, while the AutoForm feature does not.

ru c

In st

2.

What types of forms will you create to work with your data? Answers will vary.

DU

94

PL
Microsoft Ofce Access 2003 Level 1

IC

AT

6.

Save the form as frmMyGSCCustomers, and then close the form.

rE

di tio n
b. Choose ViewTab Order. a. View the form.

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

b. Press the Tab key to move through the fields. The tab order has been corrected to better suit the forms new layout. a. Save the form as frmMyGSCCustomers

LESSON 6

LESSON 6
Producing Reports
In this lesson, you will create and modify Access reports. You will: Create a report with the AutoReport feature. Create a report with the wizard. Examine a report in Design view. Add a calculated eld to the report.

rE
NO T DU

Modify the format of a report by using the AutoFormat feature.

to
DO

Lesson 6: Producing Reports

In st

ru c

PL

IC

Adjust the width of a report.

AT
95

Modify the properties that set the appearance of a control.

di tio n

Lesson Time 1 hour(s)

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

TOPIC A

Create an AutoReport

to
DO

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

In st

How to Create an AutoReport


Procedure Reference: Create an AutoReport To create an AutoReport:
1. 2. 3.

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

NO

Is also available from within the Report Design Wizard for the three most common layout types (columnar, tabular, and justied).

Can make use of multiple tables.

ru c

DU

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 toolbars New Object: AutoReports button and works directly with a table or query.

96

PL

Microsoft Ofce Access 2003 Level 1

IC

AutoReport

AT

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 no need to create the perfect report. Using the AutoReport tool you can create a report that displays all of the elds for any given table.

rE

Much like the AutoForm feature, AutoReport can be used to quickly create a simple report that contains all of the elds in a specic table. This topic will introduce you to the AutoReport feature and how to use it to quickly create a simple report.

di tio n

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 customized Access reports can provide you with an efficient tool that simplies your reporting requirements and can be saved for future use.

ACTIVITY 6-1
Creating a Report with the AutoReport Wizard
10 minutes Data Files: UseReports.mdb Activity Time:

LESSON 6

Scenario: Before an urgent request for printed output of your data arises, youve decided to prepare for the situation and review the results of an AutoReport in Print Preview mode. This way, youll know what to expect before you actually print a report.
What You Do 1. In the UseReports database, run the qryInventory query and view the results in Print Preview format. Print the report. How You Do It

b. Click the Print Preview button. c. Enlarge the preview to 100%.

rE
NO T

a. In the UseReports database, double-click the qryInventory query.

to ru c
f.

e. From the menu, choose FilePrint and click OK to send the output to the printer. Examine the printed output.

In st

2.

What features does the printed datasheet have?

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 record arranged horizontally in a grid. What disadvantages are there to printing the query datasheet? There are no totals, and there is no formatting. In addition, the data is split across two pages.

3.

Lesson 6: Producing Reports

DO

DU

The ability to print will depend upon your classroom setup. Your instructor will advise you on this.

PL

d. Using the scroll and navigation bars, modify the display as necessary to view both pages.

IC

AT

di tio n
The ability to print will depend upon your classroom setup. Advise the students of the options.

97

LESSON 6
4. Create an AutoReport. a. Close Print Preview. If necessary, reopen qryInventory in Datasheet view. b. From the New Object: AutoForm dropdown list, choose AutoReport. 5. Examine the preview of the AutoReport.

How does the AutoReport compare to the printed datasheet?

The fields are arranged in a vertical column. An extra blank line separates each record. Theres no heading, date, or page numbers. The report is eight pages long. 6. Close the preview window and save the report as rptMyAutoReport. If necessary, close the report Design window. a. Close the preview window.

rE
f.

If necessary, close the qryInventory query.

to
DO NO

In st

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 report. The custom report can provide the business with a tool to evaluate past and present 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, you will be able to develop reports that display the information requested.

The Report Wizard


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

Create a Report by Using the Wizard

ru c

DU
Microsoft Ofce Access 2003 Level 1

TOPIC B

98

PL

IC

AT

di tio n
d. Click OK.

b. When prompted to save, click Yes. c. In the Report Name text box, type rptMyAutoReport

e. If necessary, close the report Design window.

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

How to Create a Report with Wizard


Procedure Reference: Create a Report with the Wizard To create a report with the wizard:
1. 2. 3. 4. 5. 6. 7. 8. 9.

In the Database window, in the Objects pane, select Reports. Double-click Create Report By Using Wizard.

From the Tables/Queries drop-down list, select the data source for the report.

Move the elds you want included in the report from the Available Fields list to the Selected Fields list by using the arrow buttons. Repeat Steps 3 and 4 for any additional data sources. Click Next.

Select the sort order for the detail records and click Next. Select the layout for the report and click Next.

rE
NO T

If necessary, choose the grouping levels and grouping options you want, and click Next.

11. Enter a title for the report and select whether you want the report displayed in

Print Preview or Design view.


12. Click Finish.

to
DO

Creating a Report with the Report Wizard


Activity Time: 15 minutes

Scenario: The Controller of your organization has asked for a report that lists, by department, the current computer inventory. You want to organize the information correctly and print it in a legible, professional-looking format. The Report Wizard will create a report that accomplishes this.

Lesson 6: Producing Reports

In st

Setup: The UseReports.mdb database is open.

ru c

DU

ACTIVITY 6-2

PL

IC

AT
99

10. Select the style for the report and click Next.

di tio n

LESSON 6
What You Do 1. Start the Report Wizard. How You Do It a. In the Database window, display Reports. b. Double-click Create Report By Using Wizard.

rE to ru c In st
100

DO

NO

T
Microsoft Ofce Access 2003 Level 1

DU

PL

IC

AT

di tio n

LESSON 6
2. From Query: qryInventory, select the fields with which you will be working. a. With Query: qryInventory selected in the Tables/Queries drop-down list, click the right-pointing double arrow to move all the available fields to the Selected Fields list.

rE
NO T

b. In the Selected Fields list, select ManufacturerID.

c. Click the left-pointing single arrow.

d. Remove the Warranty field from the Selected Fields list.

to In st
e. Click Next.

Lesson 6: Producing Reports

DO

ru c

DU

PL

IC

AT
101

di tio n

LESSON 6
3. View some examples of the available views and groupings. Then click Show Me More Information. a. In the list of views, click By tblEmployees and view the sample. b. In the list of views, click By tblComputers and view the sample.

4.

Close the Report Wizard Tips, and then choose tblDepartments and continue through the wizard.

rE
NO T

to
DO

ru c In st
7.

View the style samples and apply the Corporate style.

DU

b. Select Outline 1.

c. Click Next. a. In the list of styles, select each style and view the sample.

102

PL

6.

View the layout samples and apply the Outline 1 layout.

a. In the Layout section, select each option and view the sample.

Microsoft Ofce Access 2003 Level 1

IC

b. Click Next.

AT

5.

Sort the detail records in ascending order, by asset tag number.

a. From the drop-down list for the first sort box, select AssetTag.

di tio n
c. Click Next.

c. In the list of views, click By tblManufacturers and view the sample.

d. Click Show Me More Information to display the Report Wizard Tips. a. In the Report Wizard Tips dialog box, click Close.

b. If necessary, in the list of views, select tblDepartments.

d. Since you dont need any additional levels of groups, click Next.

LESSON 6
b. Select Corporate.

c. Click Next. 8. Enter a title of rptMyDepartments and preview your report.


When previewing a report, you can use the Two Pages and Multiple Pages buttons to get a big-picture look at the layout of your report.

a. In the title text box, type rptMyDepartments

c. Click Finish.

rE
NO T

b. Verify that Preview The Report is selected.

In st

Lesson 6: Producing Reports

DO

ru c

DU

If you click Close on the Print Preview toolbar, then the Design view of the report will be displayed. Close that window as well.

b. If necessary, close rptMyDepartments.

PL

IC

9.

Close the preview window and close the report.

to

a. In the preview window, click the Close button.

AT
103

d. Use the scroll and navigation bars to view all the data and pages.

di tio n

LESSON 6

TOPIC C
Examine a Report in Design View
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 reports 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. As with the form you created with the Form Wizard, the report you created can also be opened and viewed in Design view. A report is generally more complex to modify than a form.

Report Design View

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.

rE
NO T

If a professional presentation is your utmost consideration, then Design view may be the preferred report creation method. However, regardless of how a report is created, the layout of a report can always be modied in Design view. An existing report can be opened in Design view in three ways: You can right-click the report in the Database window and choose Design view.

to
DO

Procedure Reference: Identify the Components of a Report in Design View

1. 2. 3. 4. 5.

Select the report to examine. Open the report.

In st

ru c
Examine the report. Close the report.
104

Click the Design view button.

DU
Microsoft Ofce Access 2003 Level 1

PL

To identify the components of a report in Design view:

IC

AT

How to Examine a Report Displayed in Design View

di tio n

ACTIVITY 6-3
Identifying the Components of a Report Displayed in Design View
Activity Time: 10 minutes Setup: The UseReports.mdb database is open.

LESSON 6

Scenario: Knowing that you will be called upon to customize reports, youve decided to spend a little time familiarizing yourself with how the report design determines nal format. This way, you will be prepared to create a report.
What You Do 1. Open the rptDepartmentalInventory report, view all the pages, and then switch to Design view. How You Do It

a. Double-click rptDepartmentalInventory. b. If necessary, maximize the preview window.

rE
NO T

to In st
2. Where does the Report Header print? a) On the first page of the report. b) On the last page of the report. c) At the bottom of each page. d) At the top of each page.

Lesson 6: Producing Reports

DO

ru c

c. Use the navigation bar to view all pages. d. On the preview window toolbar, click Close. e. Open rptDepartmentalInventory in Design view.

DU

PL

IC

AT
105

di tio n

LESSON 6
3. What information is in the Report Header? a) Name and Address b) Title and Date c) Page Number d) Date and Time 4.

What information does the Page Footer provide? a) Date b) Time c) Name d) Page Number

5.

Determine which controls on the report are labels and which are text boxes.
You can move the property sheet by dragging it by the title bar.

rE to ru c In st
6.

NO

Close the property sheet.

DO

DU

This indicates that the control is a label that has been named Title.

d. Select other controls on the report and view the title bar of the properties dialog box. a. In the properties dialog box, click the Close button.

106

PL
Microsoft Ofce Access 2003 Level 1

IC

AT

di tio n

a. On the Report Design toolbar, click the Properties button . b. Select the report title Departmental Inventory control. c. Observe the properties dialog box title bar.

TOPIC D
Add a Calculated Field to a Report
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 eld in your report. 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 contains the salary amounts. By adding a control with a calculated eld to your report you can easily produce the requested result.

LESSON 6

The Toolbox

The toolbox is composed of design tools used to add controls to reports and forms. The same toolbox is used whether a form or report is being developed. The Toolbox Icons The following table displays most of the buttons in the toolbox.

rE
DU NO T

Icon

Tool Name
Label Text Box Option Group

Usage
Adds text only.

Wizard
No

PL

Provides the user with option button choices, which are buttons that can take on a variety of formats, from round circles to large rectangular boxes. A graphical button indicating a true/false or yes/no value.

Toggle Button

ru c

Option Button

This is similar to the option group, but each button operates independently. It can be used to designate true/false values, or multiple option buttons could be used to simulate an option group with multiple selections available.

In st

Check Box

DO

A square graphic where a check mark represents a true value. A graphical box that can contain elds, expressions, and text with a drop-down arrow showing additional choices. A graphical box that displays all the choices available. It is similar to an option group but the record source can be text. Used to place a button on the form, the button can be programmed to perform an action.

Combo Box

List Box

Command Button

Lesson 6: Producing Reports

IC
Yes No No No Yes Yes Yes

Adds a graphical box that can contain elds, expressions, and text.

to

AT
No

E
107

di tio n

LESSON 6
Icon Tool Name
Image Unbound Object Frame Bound Object Frame Page Break

Usage
Used to place a picture on the form or report. Used to place a variety of objects, including pictures, on a form or report. This is used to place an OLE object on a form or report.

Wizard
No No No No

This inserts a page break wherever this control is placed. Using the Page Down key on a form will move the insertion point to the top of a page break. In a report, a page break will be inserted upon printing.

Tab Control

The Tab Control places a graphical object on a form or report that positions data within pages accessed by a tab. Tab Controls are most often used in forms to maximize use of space. This is used to place a subform or subreport on a form or report object.

Subform (or) Subreport Line Rectangle

rE
DO NO T

This places a straight line on the report.

to

How to Add a Calculated Field to a Report


Procedure Reference: Add a Calculated Field to a Report

In st

ru c

1. 2. 3. 4. 5. 6. 7. 8.

Open the report in Design view.

If necessary, display the Toolbox by clicking the Toolbox button. In the Toolbox, click the Text Box tool. Click the report design surface where you wish to place the calculated control. Click in the text box control to place the insertion point. Type an equal sign (=) and the formula for the calculation. Press Enter or click away from the control. Save the report.

DU

To add a calculated eld:

108

PL

Microsoft Ofce Access 2003 Level 1

IC

AT

This places a rectangular box on the report and can be used to cluster similar elds together or to enhance the graphical display.

di tio n

No

Yes No

No

ACTIVITY 6-4
Adding a Calculated Field to a Report
10 minutes Activity Time:

LESSON 6

Setup: The rptDepartmentalInventory report of the UseReports database is open.

Scenario: Youve 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 calculation in the report. Adding a calculated eld to the report will accomplish the amortization request.
What You Do 1. Add a control containing an amortization formula.
Note that when you place the text box control, it contains the word Unbound. This is because you have not yet designated the contents of the control.

How You Do It

a. If necessary, on the Report Design toolbar, click the Toolbox button . b. In the Toolbox, click the Text Box tool.

rE
NO T

to In st
Lesson 6: Producing Reports

d. Click in the text box control. e. Type = [PurchasePrice]/3

The same techniques for selecting and moving controls used in the form design environment work in the report design environment. You can also move the Toolbox by dragging it by the title bar.

DO

ru c

DU

PL

IC

c. Click in the Detail section to the right of the PurchasePrice control to add the control.

AT

E
109

di tio n

LESSON 6
2. Delete the default label for the control, add a label with the caption Amortized to the right of the PurchasePrice heading, close the Toolbox, and preview the report. a. Click the default label control to select it. b. Press Delete. c. In the Toolbox, click the Label tool. d. In the LastName Header section to the right of the PurchasePrice label, drag to create the label control. e. Type Amortized f.

3.

rE
NO T

Save your report as rptMyInventoryReport and close the preview window.

to
DO

You have added a control and a calculated eld to your report and the resulting value is displayed in the reports output. You are not pleased with the default display of the value and wish to change it. By modifying the format properties of the control that performs the calculation, you can change the values appearance.

In st

Adding a control to a report can greatly enhance the output and the value it has to the 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.

How to Modify a Controls Properties


Procedure Reference: Modify a Controls Properties To modify a controls properties:
1.

ru c

Open the report in Design view.


Microsoft Ofce Access 2003 Level 1

110

DU

Modify the Format Properties of a Control

PL

TOPIC E

IC

AT

di tio n
g. Click the Print Preview button. a. Save the report as rptMyInventoryReport

In the Toolbox, click the Close button.

b. Click Close to close the Print Preview window.

LESSON 6
2. 3. 4. 5. 6. 7.

Select the control and click the Properties button, or right-click the control and choose Properties. If necessary, in the property sheet, select the Format tab. In the Format property box, from the drop-down list, choose the format you want.

Preview the report to see the new format. Save the report.

ACTIVITY 6-5
Activity Time: 10 minutes

Modifying a Controls Properties to Change the Outputs Display

to
DO

What You Do 1.

How You Do It

Change the format of the new calculated control to currency.

a. In the Detail section, select the control containing the formula you entered.

ru c In st
2. Change to Design view. In the Report Header section, select the text box with the Now() function in its control source and, from the Format drop-down list, select the Short Date choice. Preview the report, and then save the report.

b. On the Report Design toolbar, click the Properties button.

c. Select the Format tab. d. From the Format drop-down list, select Currency. e. Click Print Preview. a. Switch to Design view.

Lesson 6: Producing Reports

NO

DU

PL

IC

AT
111

Scenario: The amortized output format of the rptMyInventoryReport needs to be changed to currency.

Setup: The rptMyInventoryReport report of the UseReports database is open.

rE

di tio n

Close the property sheet.

LESSON 6
b. In the Report Header section, select the control containing the Now() function.

rE to
DO NO
TOPIC F
AutoFormat a Report

When you ran the Report Wizard, you probably noticed a list of styles that you could choose from. Wouldnt 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 topic, you will examine the different AutoFormat reports available and apply your selection to a report.

ru c

In st

Imagine that you have created a report that is to be used by several different departments in the organization. The contents of the report are just what they needed, but you have had several requests for different formats. This may seem to be a trivial matter, and you really dont wish to redesign the same report over and over. Using the AutoFormat feature, you can easily modify the reports format.

DU
Microsoft Ofce Access 2003 Level 1

112

PL

IC

AT

di tio n
d. Click Print Preview.

c. In the properties dialog box, from the Format drop-down list, select Short Date.

e. Return to Design view and save the report.

LESSON 6
How to Apply an AutoFormat Style to a Report
Procedure Reference: Apply an AutoFormat Style to a Report To AutoFormat a report:

2. 3. 4. 5. 6. 7.

Choose EditSelect Report, or click the Report Selector.

On the Report Design toolbar, click the AutoFormat button. In the Report AutoFormats list box, select the new format. Click OK. Preview the report to see the new style. Save the report.

ACTIVITY 6-6
Activity Time: 10 minutes

rE
NO T

Applying an AutoFormat Style to a Report

to
DO

What You Do 1.

With no controls selected, open the AutoFormat dialog box and choose a report format you like. Then, apply the format and preview the report.

In st

Lesson 6: Producing Reports

ru c

How You Do It

a. In the property sheet dialog box, click the Close button.

b. Click a blank area of the report to deselect all controls. c. Choose EditSelect Report. d. On the Report Design toolbar, click the AutoFormat button.

DU

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 the AutoFormat feature may provide the solution.

PL

IC

Setup: The rptMyInventoryReport report of the UseReports database is open in Design view.

AT
113

di tio n

1.

Open the report in Design view.

LESSON 6
e. In the Report AutoFormats list box, select the Bold format and observe the preview.

b. Click Save.

to
TOPIC G

ru c

In st

Imagine you have been asked to produce a lengthy report for an important business meeting. When you run and print the report, you nd that every other page is a blank page. This is certainly not an acceptable format for the presentation. By modifying the reports margin values you can eliminate the blank pages.

DO

There are times when a report contains so much information that the information to be displayed exceeds the size of the display area and causes blank pages to be printed in your report. In this topic, you will modify the margin settings to prevent this situation.

NO

Adjust the Width of a Report

DU
Microsoft Ofce Access 2003 Level 1

114

PL

IC

c. Click the Close button.

AT

2.

Switch to Design view. Save and close the report.

rE

di tio n
f. g. Click OK. h. Print Preview your report. a. Switch to Design view.

Preview each of the remaining formats and select the one you prefer.

LESSON 6
How to Adjust the Margin Settings on a Report
Procedure Reference: Adjust a Reports Margin Settings To adjust a reports margins:

2. 3. 4. 5. 6. 7.

On the horizontal ruler, note the width of the report.

Calculate left and right margin settings that, when added to the report width, are no greater than the width of the paper. Choose FilePage Setup and enter the Left and Right margin values. Click OK. Preview the report to check your results. Save the report.

ACTIVITY 6-7
Adjusting a Reports Margin Settings
Activity Time: 15 minutes Setup: The UseReports.mdb le is open.

rE
NO T DU

to
DO

What You Do 1.

Print Preview rptFixMargins, viewing two pages side by side.

In st

Lesson 6: Producing Reports

ru c

Scenario: Youve spent a lot of time perfecting your report and sent it off to the printer. When you picked it up, every other page is mostly blank. Adjusting the margin settings will x it.
How You Do It

a. In the Database window, right-click rptFixMargins and choose Print Preview. b. On the Print Preview toolbar, click the Two Pages button.

c. Page down and examine the entire report. The blank pages alternate between the printed pages.

PL

IC

AT
115

di tio n

1.

Open the report in Design view.

LESSON 6
2. Why are there blank pages between the printed pages? a) There is not enough text on the pages. b) The font is too large. c) The margin setting is too narrow. d) The margin setting is too wide. 3. In Design view, note the width of the report. Open the Page Setup dialog box and notice the margin settings.

4.

Why are these settings causing the blank pages?

The report is in Portrait orientation, which means the page is 8.5 inches wide. The report width of 6.75 inches plus 1 inch left and right margins exceeds this width and causes the blank pages.

You could:

Change the report to Landscape orientation. Make the margins smaller.

to
NO DO

5.

b. Click OK.

ru c In st
6.

T
f.

Close the UseReports database and close Access.

DU

c. Print Preview all pages of the report. The blank pages have been removed. d. Close Print Preview. e. Save the file as rptMyFixMargins Click the Close button.

a. In the Database window, click the Close button. b. In the Microsoft Access window, click the Close button.

116

PL

Change the margins to eliminate the blank pages. Then, preview the report, save it as rptMyFixMargins, and close it.

a. In the Page Setup dialog box, change the Left and Right margin values to 0.75.

Microsoft Ofce Access 2003 Level 1

IC

AT

Decrease the width of the lines and then decrease the width of the report in Design view.

rE

What do you think your options might be for fixing this problem?

di tio n

a. In Design view, on the horizontal ruler, note the width of the report. It is approximately 6.75 inches wide. b. Choose FilePage Setup and note the margin settings. Each margin is set to 1 inch.

LESSON 6
Lesson 6 Follow-up
In this lesson, you created an AutoReport and used the Report Wizard to create a report. Then, in Design view, you customized the report by adding a calculated eld, modifying the format properties of a control, using the AutoFormat feature to change the reports format, and adjusting the width of the report.
1. What kinds of reports will you create for your data? Answers will vary. 2.

What uses can you think of for calculated fields in your reports? Answers will vary.

rE to ru c In st
Lesson 6: Producing Reports

DO

NO

DU

PL

IC

AT
117

di tio n

NOTES

rE to ru c In st
118

DO

NO

T
Microsoft Ofce Access 2003 Level 1

DU

PL

IC

AT

di tio n

LESSON 7

LESSON 7

Planning a Database

In this lesson, you will follow the steps required to properly design a simple database.

Dene the purpose of a new database.

Logically group your elds in tables.

to
DO

Designate a primary key for each table, and where applicable, a foreign key.

ru c

Lesson 7: Planning a Database

In st

NO

DU

PL

IC

Apply database design principles to eliminate potential data maintenance problems.

AT
119

List the necessary elds for your database.

Use existing resources to help identify what data already exists and might be part of your database.

rE

You will: List and describe the steps of the process involved in designing a relational database.

di tio n

Lesson Time 40 minutes

LESSON 7
Introduction
You have data that needs to be stored in a database. You have used Microsoft Office Access 2003 databases before, but using a database and creating one are not the same thing. In this lesson, you will learn the basics of planning a new database, and in the next lesson, you will create a simple database. Just as you wouldnt attempt to build a house without a blueprint, you shouldnt create a database 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 nancial or Human Resources database, on the other hand, would require a lengthy planning phase with input from numerous groups in your organization.

TOPIC A

Design a Relational Database

to
DO

2. 3. 4. 5. 6.
Students will perform each stage of this process in the remaining topics in this lesson.

Review existing data.

Make a preliminary list of elds. Organize the elds into tables.

ru c

Designate primary and foreign keys that can be used to relate your tables together.

Relational Database Design Process

In st

NO

Enter sample data, review for possible data maintenance problems, and revise the table design as necessary.

DU
Microsoft Ofce Access 2003 Level 1

120

PL

The relational database design process is a simple process that can be used to produce a design plan for a relational database. It is composed of the following stages wherein you will: ] 1. Identify the purpose of the database.

IC

The Relational Database Design Process

AT

With any complicated activity, following a well-dened process will help you to stay on track, include all the appropriate inputs, and produce the best possible output. Creating a new Access 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.

rE

In order to create a new database effectively you should follow a plana process that includes all the phases necessary to create the best database for your needs.

di tio n

LESSON 7

rE
NO T DU

Figure 7-1: The relational database design process.

to
DO

1.

Place the steps of the relational database design process in the correct order.

Lesson 7: Planning a Database

In st

5 Enter sample data, review for possible maintenance problems, and revise the table design as necessary.

4 Organize the fields into tables. 3 Make a preliminary list of fields. 1 Identify the purpose of the database.

6 Identify primary and foreign keys for use in relating the data in the tables. 2 Review the existing data.

ru c

Scenario: 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 condent in the nal result.

PL

Following the Relational Database Design Process

IC

DISCOVERY ACTIVITY 7-1

AT
121

di tio n

LESSON 7

TOPIC B
Identify Database Purpose
The rst step in the design process is to determine what purpose you want the database to serve. As with any activity, if you dont have a clear purposea well-dened goalthen you run the 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 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.

Statement of Purpose

rE
NO T

Example:

to In st
DO

ru c
122

Figure 7-2: A good statement of purpose for an employee benefit plans database.

DU
Microsoft Ofce Access 2003 Level 1

PL

IC

AT

Denition: A statement of purpose is a clear statement that denes the scope of a database and helps to guide its design. It should imply the kinds of data that will be included in the database, but not state specic table or eld names. It can describe who the likely types of users of the database will be, but not state specic queries or reports they intend to run. It is sometimes useful to include a statement of what the database will not do.

di tio n

LESSON 7
Non-Example:

to
DO

1.

Given the preceding scenario, write a statement of purpose for the new database.

ru c

DU

Scenario: In your new position as head of Information Management for The Green Supply Co., youve decided you want to create a custom database to track your companys computers and what employees they are assigned to.

PL

IC

Writing a Statement of Purpose

AT
You might want to do this as a group activity.

DISCOVERY ACTIVITY 7-2

rE
NO

Figure 7-3: A poor statement of purpose for an employee benefit plans database.

Answers will vary somewhat, but should be something like: The database will hold information on the companys inventory of computers and their assignment to employees. 2. What is wrong with this statement of purpose: The database will have tables for computers, personnel, manufacturers, product sales, salaries, and company suggestions. a) The statement of purpose should not attempt to list specific tables. b) The statement of purpose is too broad. c) There is nothing wrong with this statement of purpose.

Lesson 7: Planning a Database

In st

E
123

di tio n

LESSON 7
3. What is wrong with this statement of purpose: The database will allow the user to generate reports that list the computers used by each employee, as well as queries that sort records by the date the computer was purchased and the manufacturer of the computer. a) It doesnt discuss the scope of information to be included in the database. b) It doesnt 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.

TOPIC C

Review Existing Data

to
DO

ru c

Denition: Existing data is information available for you to review that falls within the scope of your database as dened in your statement of purpose. This data can be in paper or electronic format.
An existing data source may also contain information that is outside the scope of the planned database. Use your statement of purpose to determine this as necessary.

In st

Example: Existing Data in Paper Format Existing data in paper format could include: Internal business forms or documents. Third-party or government forms or documents. Printed invoices, bills, or sales slips.

NO

T
Microsoft Ofce Access 2003 Level 1

124

DU

PL

Existing Data

IC

Although you may think you know exactly what data should be included in the database you are designing, youll be surprised how often youll miss something. By considering preexisting 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.

rE

Now that you know what you intend the database to do, you can start thinking about what data it will have to contain to fulll that purpose. This is the second step in the design process.

AT

di tio n

LESSON 7

to
DO

Word Processing documents, such as Microsoft Word. Other Databases, such as Access, SQL Server, or Oracle. Web pages.

ru c
Lesson 7: Planning a Database

In st

NO

DU

PL

IC

Example: Existing Data in Electronic Format Existing data in electronic format could include: Spreadsheets, such as Microsoft Excel.

AT
125

Figure 7-4: Existing data in paper format.

rE

di tio n

LESSON 7

to
DO

ru c

In st

NO

Scenario: The statement of purpose for your database is The database will hold information on the companys inventory of computers and their assignment to employees. In your search for existing data, you nd that the Receiving department lls out a ticket for each item that is delivered. See Figure 7-6.

DU

126

PL

Gathering and Reviewing Existing Data

Microsoft Ofce Access 2003 Level 1

IC

DISCOVERY ACTIVITY 7-3

AT

Figure 7-5: Existing data in electronic format.

rE

di tio n

LESSON 7

Figure 7-6: A sample Receiving ticket.

1.

a) Date computer acquired b) Manufacturer name c) Asset tag number d) Department of employee 2.

to
DO

What other sources of data might you use for determining what data should be included in the database?

ru c

Lesson 7: Planning a Database

In st

NO

DU

Answers will vary, but might include annual departmental computer inventory reports, interviews with selected members of various departments, or interviews with potential users of the database.

PL

IC

AT
127

What pieces of data from the sample ticket do you think should be included in your database?

rE

di tio n

LESSON 7

TOPIC D
Determine Fields
From reviewing the existing data, you have a good start on your eld list. You can complete step three in the design process by questioning potential users of the data about their expectations and, specically, what reports or summary information they would like. You can then reverse-engineer that into specic elds of data. You dont want to spend a lot of time creating a database and designing beautiful forms and reports only to nd out that they dont 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 possible about their information needs.

Determining Additional Fields

When you appropriately determine additional elds, you will meet your users needs while staying within the scope of your statement of purpose.

rE
NO T

Ask questions to gain a better understanding of the elds that will be required.

to
DO

What types of summary information do you expect the database to produce?

In st

Example: You are designing a database for tracking enrollment of employees in benet plans. You have reviewed existing data and now need to determine additional elds. In interviewing 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 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 elds.

ru c

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.

DU

What kinds of questions do you want the database to be able to easily answer?

128

PL

What kinds of reports would you like to be able to generate from the database?

Microsoft Ofce Access 2003 Level 1

IC

What sort of data do you expect the database to contain?

AT

Guidelines: When interviewing the potential users of a database to determine additional elds, be sure to: State your databases statement of purpose at the beginning of each conversation to help everyone stay focused.

di tio n

DISCOVERY ACTIVITY 7-4


Completing the List of Fields
Scenario: From the Receiving ticket and other sources you have been able to arrive at the following list of pre-existing data: Employee department Date received Asset tag number Manufacturer Note about each computer

LESSON 7

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 also like to know if the system is covered by a warranty. The Finance manager would like a monthly summary of departmental computer hardware purchases.

1.

What additional data will you need to include about each employee?

c) Date of birth d) Computers assigned e) Manager of employee 2.

to
DO

What additional fields will you need to include in the database to enable the Technical Services managers weekly reports and the Finance managers monthly report? a) Warranty coverage b) Purchase price

c) Software games included

ru c

d) Number of current files on the computer

Lesson 7: Planning a Database

In st

NO

DU

PL

IC

AT
129

b) Salary

a) Name

rE

di tio n

LESSON 7

TOPIC E
Group Fields into Tables
Once youve identied the elds you need in the database, you can move on to step four of the design process and decide how to organize them into tables. Thats what youll work on next. As you know, tables are the heart of any Access database. Theyre the objects that actually store your data and are what you use as the basis for queries, forms, and reports. While you can change the design of tables after theyre created, its much less work to try to get the right table design at the start.

Group Fields into Tables

Grouping elds into tables will allow you to effectively relate information in your database. Guidelines: Use these guidelines when grouping elds into tables: A table should hold information on only one subject.

to
DO

For intangible subjects, try to identify a collection of logically related information with common characteristics.
If ve different database designers followed the recommended design process for the same database, it is entirely possible they would arrive at ve slightly different designs. This is because each individual can have a different thought process and may make different assumptions along the way. Thats why the standard design process is so important. It helps ensure that, whatever the details of the nal design, it will comply with good design principles.

ru c

In st

Example: Employees and Benet Plans Tables In a database for tracking enrollment of employees in benet plans, you have one table for employees and another for benet plans. These are both entities that have related properties. Each employee has a name, department, phone number, current plan, and date of enrollment. Each benet plan has a plan name, provider, benets, and description.

NO

DU

130

PL

Microsoft Ofce Access 2003 Level 1

IC

AT

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 elds of the table.

Dont be concerned about having too many tables. Its much more likely that you wont have enough.

rE

di tio n

LESSON 7

rE
NO T

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 avors and prices. If you sold sundaes as well as cones, you would have a Toppings table that includes the topping name and its additional 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 avor and topping is used to make it.

to In st
Lesson 7: Planning a Database

Business Rules The procedures and policies of a company represent its business rules, and these can affect the design of a database. For example, if your company has an internal policy that computers are assigned to departments, rather than to specic 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 elds into tables, you should be aware of company policies. If you dont already know the pertinent company policies, you should inquire about them.

DO

ru c

DU

PL

IC

AT
131

di tio n

LESSON 7
Field and Table Names Access has constraints on eld and table names. Names: Can be no more than 64 characters. Cannot include a period (.), exclamation point (!), an accent grave (), brackets ([]), or double quotation marks (). Cannot have a leading space. (Access permits you to have spaces within table and eld names; however, if there is an internal space, you will have to enclose that table or eld name within brackets when you refer to it in expressions and other places. So, you might want to get in the habit of not using spaces in table and eld names. One option is to use the underscore character in place of a space in a eld name.)

Names should be brief but descriptive so that another user will know what they mean. Table names are usually plural.

DISCOVERY ACTIVITY 7-5

Asset tag number Date received

to
DO NO

Computer manufacturer

Computer note or comment Employee department Warranty coverage Purchase price

1.

Based on the information you have now, which two tables would be minimally required for this database? a) Computers and Notes b) Computers and Employees

In st

c) Computers and Departments

d) Employees and Departments

T
Microsoft Ofce Access 2003 Level 1

Now you need to group them into initial tables.

132

ru c

DU

PL

IC

AT

Scenario: Youre continuing work on designing your computer inventory database, and youve decided that you need the following elds: Employee name

rE

Deciding on Computer Inventory Tables

di tio n

LESSON 7
2. With only these two tables as options, which fields would go in an Employee table? a) Name b) Computer manufacturer c) Department d) Warranty coverage 3.

Of the remaining fields,sixof them could go in a Computers table.

TOPIC F
Normalize the Data

to
DO

Data Normalization Guidelines

Data normalization ensures that, when you implement the tables you have planned, the resulting database will be able to efficiently provide the queries and reports desired and ongoing data maintenance will be as simple as possible. Guidelines: Common data normalization guidelines are as follows: Each eld should contain the smallest meaningful value.

ru c

There should be no unnecessarily repeated data values. When reasonable, all elds in a table should pertain to every record.

Non-Example: In this example the elds are not normalized. The Name eld is not the smallest meaningful value. There are two email address elds, and the second will not always have a value. Full Name Work Phone Number Work Email Address 1 Work Email Address 2

Lesson 7: Planning a Database

In st

NO

There should be no repeated groups of elds (similar data belongs in the same eld).

DU

PL

IC

AT

Identifying possible data maintenance problems before you enter your real data and start working with your database will save you many headaches and extra work later on. Improperly designed tables can also result in inaccurate data, and you certainly dont want to be making decisions based on data that you cant trust.

rE

Once youve drafted the tables and elds you believe you need in your database, the next step is to enter some sample data in the tables and look for any potential problems with maintaining the data.

E
133

di tio n

LESSON 7

Social Security Number Begin Date

Employee Last Name Work Phone Number Work Email Address Social Security Number Begin Date

Completion Date 1 Project 2 Completion Date 2 Optional Assistant

to
DO

ru c

In st

In this case it is quite possible that while some employees do not have a Web site, some have more than one. This would be another reason that this eld belongs in a separate table, otherwise you would end up with two or more redundant elds in the same table.

Data Denormalization

Denition: 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:

NO

Blank Values Though not a strict rule, In many cases blank values in elds should appear because that value is temporarily missing or unknownnot because that eld does not pertain to a record. So, for example, if you have a table listing employees that contains a WebSite eld, that eld would contain a blank value for some employees (assuming that not everyone has a Web site, or likely ever will). The value isnt temporarily missing or unknown; the eld just doesnt apply to every record. Thats a sign that the eld might belong in a separate table.

DU

134

PL

Microsoft Ofce Access 2003 Level 1

IC

AT

Project 1

Department

rE

Non-Example: A table containing the following elds would violate the data normalization guidelines. The name eld should be split into at least First Name and Last Name, there are repeated elds for Projects and their Completion Dates, and the Optional Assistant eld would by denition not have a value for each record. Name

di tio n

Example: In this example, each eld has the smallest meaningful value, there are no repeated groups of elds or repeated data values, and every record in the table will have a value in each of these elds. Employee First Name

LESSON 7
Performance reasons, such as making queries run faster against very large tables. In order to keep similar data together. To keep the overall table structure simple, particularly when it is clear that breaking normalization guidelines will not negatively affect the ability to run queries or create reports.

Example: A common example of denormalization is allowing an occasional eld to be blank for some records. For instance, a database may contain a middle initial eld, but not all employees have or use a middle initial. Strict normalization rules would state that the eld should not be nullbut it is common practice to keep this eld in the same table with the rst and last names.

DISCOVERY ACTIVITY 7-6

Preventing Data Maintenance Problems

rE
NO T

to
DO

Figure 7-7: The Employees table with sample data.

Figure 7-8: The Computers table with sample data.

Lesson 7: Planning a Database

In st

ru c

DU

PL

IC

AT
135

Scenario: You have two draft tables for the computer inventory database. One is called Employees and has an EmployeeName eld and a Department eld. The other is called Computers and has the other six elds you decided upon. Now consider what potential data maintenance problems might exist by imagining them lled with data. See Figure 7-7 and Figure 7-8.

di tio n

LESSON 7
1. What should be done with the EmployeeName field to normalize the data? a) It should list the last name first, with a comma and then the first name. b) It should be broken up into two separate fields, one for the first name and one for the last name. d) Nothing, it is fully normalized as it is. 2.

True or False? Since the Department field holds repeated values, a Departments table should hold those values. True 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 False

a) The entries should be in all lowercase.

d) Nothing, it is fully normalized already.

to
DO

5.

6.

What needs to be done to normalize the Warranty fields data?

ru c In st
136

b) Because some check boxes are not checked, that data belongs in a separate table.

c) Nothing, it is fully normalized already.

NO

T
Microsoft Ofce Access 2003 Level 1

DU

a) It should be a text field.

PL

If you chose to not normalize the data in the Manufacturer field in this way, that would be an example ofdenormalizingthe data.

IC

AT

c) Since it has repeated entries, there should be a Manufacturers table to hold that data.

b) The entries should be in all uppercase.

rE

4.

What can be done to normalize the data in the Manufacturer field?

di tio n

c) It should include the last name data only.

PRACTICE ACTIVITY 7-7


Normalizing Additional Data
10 minutes Activity Time:

LESSON 7

Scenario: A colleague has asked you to help them denormalize some tables in their databases.

1.

TheAddresseld does not contain the smallest meaningful values.


2.

rE
NO T

a) City b) State c) Zip Code d) Country

to
DO

3.

Lesson 7: Planning a Database

In st

What data normalization problems does this table have? a) The LastName field appears before the FirstName field. 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.

ru c

DU

Zip Code information implies the City and State. If a lookup function were available, then having additional elds for City and State would, in this respect, amount to denormalizing this data.

PL

IC

AT
137

Based on the data shown, which additional fields would you need to add to normalize this data?

di tio n

LESSON 7
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 the table. 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 6.

You would need to edit the phone numbers in more than one record. 8.

to
DO

True False

ru c In st
138

NO

T
Microsoft Ofce Access 2003 Level 1

DU

PL

IC

True or False? You could normalize this data by moving the ProjectManager and Phone fields into a second but related table.

AT

7.

What data maintenance problem does this cause?

rE

ThePhoneeld contains unnecessarily repeated values that rely on a non-key eld.

di tio n

TOPIC G
Designate Primary and Foreign Keys
Now that youve modied the design of the tables so that youre condent that the data can be maintained accurately, its time to determine the primary and foreign keys for each table, which in turn determines how the tables can be related to each other. 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 creating useful relationships between your tables, and without them, you simply wont be able to use the full querying and reporting power of your database.

LESSON 7

Primary Keys

Have values that are never blank. Include as few elds as necessary. Never allow duplicates. Can be any datatype.

Have values that rarely (if ever) change.

rE
NO T

Denition: A primary key is a eld or combination of elds that contains a value that uniquely identies a record. The primary key is used in establishing appropriate relationships between tables. Primary key elds:

to
DO

AutoNumber is a common datatype choice for primary key elds because it guarantees uniqueness.

Access sorts the records by the values in the primary key.

Example: EmployeeID as a Primary Key

Lesson 7: Planning a Database

In st

Figure 7-9: An EmployeeID field is a good candidate to serve as a primary key for an Employees table.
Other common examples of primary key elds include: Student ID number, Order number, Item number, Part number, Serial number, ISBN number, and Date plus Time.

ru c

DU

PL

IC

AT
139

di tio n

LESSON 7
Non-Example: A LastName eld is not a good primary key eld because it can have duplicate values. An Email eld is also not a good primary key eld because it could allow for blank values and changes often.

Figure 7-10: Not all fields would be good primary keys.

rE
NO T

Foreign Keys A foreign key eld is a eld or combination of elds that contains a value that relates to a primary key eld. Its datatype must match that of the primary key eld. Duplicate values can appear in the foreign key eld. The combination of primary and foreign key elds is what gives Access its relational power.

to
DO

In st

Figure 7-11: Tables in the ComputerInventory database.

1.

Which field in the Employees table would be best as a primary key? a) EmployeeLastName b) EmployeeFirstName c) DeptCode

ru c

d) A new field, EmployeeID

DU

Scenario: Your database design now contains the following tables: Employees, Departments, Computers, Manufacturers, Notes. See Figure 7-11. Now you need to designate which elds will be primary keys and, where necessary, foreign keys. In doing so you are preparing your tables to be properly related together.

140

PL

Microsoft Ofce Access 2003 Level 1

IC

Identifying Primary and Foreign Key Fields

AT

DISCOVERY ACTIVITY 7-8

di tio n

LESSON 7
2. In which table should the EmployeeID field appear as a foreign key field? a) Departments b) Computers c) Manufacturers d) Notes 3. 4.

TheDeptCodefield should be the primary key field for the Departments table. Which table should have DeptCode as a foreign key field? a) Employees b) Computers c) Manufacturers d) Notes

5.

TheAssetTagfield can serve as a primary key field for both the Computers and Notes tables.

a) Employees b) Departments c) Computers d) Notes

rE
NO T

6.

If you were to add a ManufacturerID field to serve as the primary field for the Manufacturers table, what other table should have a ManufacturerID field as a foreign key?

to
DO

In this lesson, you learned all the steps required to plan a simple Access database. You followed a process that ensures that your resulting database will take into account your existing data, fulll the needs of users, and be both robust and easy to maintain. You can feel condent that the design that you now have can be implemented as an Access database appropriate to your goals.
1. Why is it important to create a plan before building your database? Answers will vary, but may include: Saving time, increased accuracy, and remaining focused on the goals of your database. Also, following the recommended procedure will ensure that the database meets the standards for good design, meets the needs of users, and will be easy to maintain. What fields might you include in the first database you need to build on your job? How would you group them into tables? Answers will vary.

2.

Lesson 7: Planning a Database

In st

ru c

DU

Lesson 7 Follow-up

PL

IC

AT
141

di tio n

NOTES

rE to ru c In st
142

DO

NO

T
Microsoft Ofce Access 2003 Level 1

DU

PL

IC

AT

di tio n

LESSON 8

LESSON 8

Building the Structure of a Database


In this lesson, you will create a new database with related tables. You will: Create a new blank database. Create a new table using a wizard. Create new tables in table Design view. Create relationships between tables.

rE
DO NO T DU

to
Lesson 8: Building the Structure of a Database

In st

ru c

PL

IC

AT
143

di tio n

Lesson Time 1 hour(s)

LESSON 8
Introduction
Once youve designed a database, you need to create the related tables that will store the data. This lesson will introduce you to the basics of building tables and the relationships between them that will enable robust queries and reports.

TOPIC A

Create a New Database

Knowing how to create a new database of your very own design frees you from having to nd an appropriate template or having to spend a lot of time modifying someone elses design.

rE
NO T

Having planned a new database, you are now ready to create it. You have several options: create 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.

to
DO

Procedure Reference: Create a New Database Based on a Database Template To create a new database based on a database template:

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.

In st

ru c
1. 2. 3. 4. 5. 6. 7. 8. 9.

If necessary, start Access.

If necessary, choose FileNew to display the New File task pane. In the New File task pane, under the Templates heading, click On My Computer. In the Templates dialog box, select the Databases tab. Click the template you wish to use. Click OK. In the File New Database dialog box, navigate to the folder in which you wish to store the database le. In the File Name text box, enter the name for the le. Click Create. After reading the initial description of this template, click Next. For each table that the template provides, select any optional elds that you wish to include and deselect any elds 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.

DU

144

PL

Microsoft Ofce Access 2003 Level 1

IC

AT

How to Create a New Database

di tio n

A database design is like an architects 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 exibility. But to create a solid structure, you should use your design as a strict guide when creating your tables and the relationships between them.

LESSON 8
12. If you want the title of the database to be different from the le name, enter that

title. Click Next.


13. If you do not want the database to be opened after the wizard builds it, uncheck

Yes, Start The Database. If you want help on using a database, check Display Help On Using A Database. Click Finish. Templates Access provides several templates on which you can base a new database. The template provides a database designed to hold a certain type of data (such as Order Entry or Resource Scheduling). A basic set of templates is installed on your computer when you install Access and additional templates are available on the Microsoft Web site through a link provided on the New File task pane.

ACTIVITY 8-1

Creating a New Database Based on a Template

rE
NO T

to
Figure 8-1: Your current database design.

In st

Lesson 8: Building the Structure of a Database

DO

ru c

DU

PL

IC

AT
145

Scenario: Youve 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.

di tio n

LESSON 8
What You Do 1. Create a new database based on the Asset Tracking template.
You might have a shortcut to Access on your desktop and can double-click that to run Access.

How You Do It a. Launch Access. b. Choose FileNew to display the New File task pane.

rE to ru c In st
146

NO

T
i.

DO

DU

f.

Click OK.

g. If necessary, in the Places bar, select My Documents.

h. In the File Name text box, type MyComputersTemp Click Create.

PL
Microsoft Ofce Access 2003 Level 1

IC

AT

di tio n

c. In the New File task pane, under the Templates heading, click On My Computer.
If On My Computer is not available, click More to see the On My Computer link.

d. In the Templates dialog box, select the Databases tab. e. Select the Asset Tracking template.

LESSON 8
2. The initial description of this template looks promising. Which of your planned database tables seem to match to the information listed? a) Employees b) Departments c) Manufacturers e) Notes

rE to ru c In st
Lesson 8: Building the Structure of a Database

DO

NO

DU

PL

IC

AT
147

di tio n

d) Computers

LESSON 8
3. Review the fields that will be included for each table and accept the default selections. a. Click Next. b. With the Asset Information table selected in the left pane, scroll through the right pane to view the list of fields.

rE to ru c In st
148

DO

NO

T
Microsoft Ofce Access 2003 Level 1

DU

PL

IC

e. Click Next.

AT

di tio n

c. Select Department Information in the left pane to see its three fields. d. Do the same for the Information About Employees, Vendor Information, and any other tables that interest you.

LESSON 8
4. Preview the form styles, and then select the Standard style and continue with the wizard. a. Select the Blends style to preview it.

b. If desired, preview any other form styles that interest you. c. Select the Standard style. d. Click Next. 5. Preview the various styles before selecting the default Corporate style and continuing with the wizard.

rE
NO T

to In st
d. Click Next.

c. Select the Corporate style.

Lesson 8: Building the Structure of a Database

DO

ru c

b. If desired, preview any other report styles that interest you.

DU

PL

IC

AT
149

a. If necessary, select Bold to preview the bold report style.

di tio n

LESSON 8
6. Assign a title of Computer Inventory and continue with the wizard. a. In the text box, type Computer Inventory

rE to ru c In st
150

DO

NO

T
Microsoft Ofce Access 2003 Level 1

DU

PL

IC

AT

di tio n
b. Click Next.

LESSON 8
7. The final screen asks if you want to open the database after the wizard builds it. Build the database. Review its structure and then close it.
On slower computers, it may take Access several minutes to build your database from the template.

a. Click Finish. A switchboard is displayed with buttons for entering information and performing other actions.

b. Close the switchboard.

rE
NO T

c. Restore Up the minimized database window from the bottom left of your screen.

to ru c
f.

e. Click the Queries button. No queries were created for you. Click the Reports button and review the Reports created for you.

In st

g. Although it could be modified to meet your exact database design, you will instead create an empty database and build from scratch. Close the Computer Inventory database window by clicking the close button.

Lesson 8: Building the Structure of a Database

DO

DU

d. After reviewing the Forms created for you, click the Tables button and review the tables created for you.

PL

IC

AT
151

di tio n

LESSON 8
Procedure Reference: Create an Empty Database To create a new blank database:
1. 2. 3. 4. 5. 6.

If necessary, start Access. If necessary, display the New File task pane by clicking the New button. In the New File task pane, under the New heading, click Blank Database.

If necessary, navigate to the location in which you wish to store the database le. Assign a name to the database le. Click Create.

ACTIVITY 8-2

Creating a New Blank Database

rE
NO T

Scenario: Youve decided that you want a database that is precisely tailored to what you need to accomplish, so you want to start it from scratch. You will create and save a new Access MDB le, so you can then go on to create your own Access objects.
What You Do 1. How You Do It

Choose to create a Blank Database.

to
DO

a. If necessary, choose FileNew to display the New File task pane.

ru c

In st

DU

2.

Name the new database MyComputerInventory.mdb and save it in the My Documents folder.

a. In the File Name text box, type MyComputerInventory

b. If necessary, in the Save In drop-down list, select My Documents. c. Click Create.

152

PL

b. In the New File task pane, under the New heading, click the Blank Database link.

Microsoft Ofce Access 2003 Level 1

IC

AT

di tio n

LESSON 8
d. Examine the database window. The name of the new database is displayed in the title bar. The title bar also indicates that the database is in Access 2000 file format.

rE
NO T

to
DO

How to Create a Table Using a Wizard


Procedure Reference: Create a New Table Using the Wizard

Lesson 8: Building the Structure of a Database

In st

To create a new table using the wizard:

1. 2. 3. 4. 5.

If necessary, in the database window, select Tables in the Objects bar. Double-click Create Table By Using Wizard. Select the appropriate sample table. From the sample table, add the sample elds you want to the new table. If you wish, rename any elds by selecting the eld and clicking Rename Field. Enter the new name and click OK. Click Next.

ru c

DU

Just because you arent using a template for your database, that doesnt mean you cant save time creating your tables. Wizards can simplify complex tasks for beginning users and can save work for all users. Its helpful to see what wizards are available for creating tables and how they work so youll know when they might be useful to you.

PL

A new blank database is just thatblank. 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.

IC

Create a Table Using a Wizard

AT

TOPIC B

di tio n

You may wish to tell students that the default le format can be changed by choosing ToolsOptions. The Default File Format can be set on the Advanced tab. By setting this value to Access 2002, some new and advanced features will be enabled. However, you may lose some backwards compatibility of the database with earlier versions of Access.

153

LESSON 8
6. 7.

Assign a name to your table and select whether you want the wizard to set the primary key or whether you wish to select it yourself. Click Next. If you choose to set the primary key yourself: a. Select the eld that contains a unique value for each record. b. c. Indicate the type of data you want the primary key eld to contain. Click Next.

8.

If there are already other tables in your database: a. b. c. d.

Indicate whether the new table is related to any of them.

If the new table is related to an existing table, select that table, click Relationships, and select the type of relationship. Click OK. 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 use to enter data. Click Finish.

rE
NO T

to
DO

In st

ru c

DU

When are Numbers not Numbers? Even though a eld, such as an EmployeeID eld, 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 the number data type only for elds that you will perform mathematical operations on.

154

PL

Microsoft Ofce Access 2003 Level 1

IC

AT

Let Access Set the Primary Key If you choose to let the wizard set the primary key for you, one of two things will happen. If you included an AutoNumber eld (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 eld as you enter records. If there is not an AutoNumber eld 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 eld.

di tio n

ACTIVITY 8-3
Create the Employees Table with a Wizard
Setup: The MyComputerInventory database is open and the tables are displayed.

LESSON 8

Scenario: Youre creating your new database and want to start building the tables you need as quickly as possible, so youve 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. Youve decided to create the table for information on employees rst. Assume that the employees have IDs assigned by the company.

rE
NO T DU

Figure 8-2: Diagram for the MyComputerInventory database.


What You Do 1. Start the wizard and review the Business and Personal sample tables that are available. How You Do It

to
DO

In st

Lesson 8: Building the Structure of a Database

ru c

b. With Business selected, scroll the Sample Tables list to see what tables are available.

c. Select Personal. d. Scroll the Sample Tables list.

PL

IC

a. Double-click Create Table By Using Wizard.

AT
155

di tio n

LESSON 8
2. Using the Business sample tables, create an Employees table including the EmployeeID, FirstName, and LastName fields. a. Select Business. b. In the list of Sample tables, select Employees. c. In the Sample Fields list, select EmployeeID. d. Click the right arrow button

di tio n
f. b. Click Rename Field . d. Click OK. e. Click Next.

e. In the Sample Fields list, select FirstName and click the right arrow. In the Sample Fields list, select LastName and click the right arrow.

3.

Based on the DepartmentName field, add a field named DeptCode.

a. In the Sample Fields list, select DepartmentName and click the right arrow.

rE to
NO DO

ru c

5.

In st

Specify that you want the data to be numbers and/or letters that youll be entering.

6.

Choose to enter data directly in the table and complete the wizard.

DU

4.

Name the table and choose to set the primary key yourself.

a. Name this table tblEmployees. b. Select No, Ill Set The Primary Key. c. Click Next. a. Verify that the default field for unique data entry will be EmployeeID. b. For the Primary Key datatype, select Numbers And/Or Letters I Enter When I Add New Records.

c. Click Next. a. Verify that Enter Data Directly Into The Table is selected.

156

PL

Microsoft Ofce Access 2003 Level 1

IC

AT

c. In the Rename Field text box, type DeptCode

LESSON 8
b. Click Finish. The table is created and shown in Worksheet view.

c. Close the table.

TOPIC C

to
DO

To create a new table in Design view:


1. 2. 3.

In the database window, in the Objects bar, select Tables. Double-click Create Table In Design View.

ru c

For each eld you wish to include in the table: a. In the Field Name column, enter the name of the eld. b. c. Click in the Data Type column for the eld, display the drop-down list, and select the data type. Make any changes you want to the Field Properties displayed in the lower pane.

Lesson 8: Building the Structure of a Database

In st

4.

Select the eld(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 eld and choosing Primary Key.

5.

Click Save.

NO

DU

Procedure Reference: Create a New Table in Design View

PL

How to Create Tables in Design View

IC

Wizards can be great time-saving devices. But for many tables there wont 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.

AT

E
157

Youve created a table with the Table Wizard. Now youll create additional tables using the more manual approach by working in Design View.

rE

Create Tables in Design View

di tio n

LESSON 8
6.

Enter a name for the table. Click OK.

An AutoNumber Field as a Foreign Key When you have an AutoNumber eld as the primary key in one table and wish to use that same eld as a foreign key in another table, in that second table, you must set the elds data type to Number and the Field Size property to Long Integer.

ACTIVITY 8-4

Creating the Manufacturers Table in Design View

rE
NO T

Setup: The MyComputerInventory database is open and the tables are shown.

to
DO

What You Do 1.

How You Do It

ru c
a) Byte b) Long Integer c) Decimal d) Currency

In st

2.

What is the default Field Size for the AutoNumber data type?

DU

Open a table Design window and add an AutoNumber field named ManufacturerID.

a. Double-click Create Table In Design View. b. In the first field in the Field Name column, type ManufacturerID c. Click in the Data Type field for the ManufacturerID record. d. Click the down arrow and select AutoNumber.

158

PL

Microsoft Ofce Access 2003 Level 1

IC

AT

Scenario: Youre continuing to implement the design of your computer inventory database. See Figure 8-2. Since there arent appropriate sample tables available for all the tables you need, youre going to create the rest in Design view, starting with the Manufacturers table.

di tio n

Field Size Property The Field Size property is available for Text, Number, and AutoNumber elds. Your database will perform more efficiently and will occupy less storage space if you set the Field Size property to conform with the actual length of the data you will store in the eld. Look in Access Help for the topic on the FieldSize Property for details on the various settings.

LESSON 8
3. Create a field named Manufacturer that allows 30 characters of text. a. Click in the second field in the Field Name column. b. Type Manufacturer c. Press Tab. The Text data type is the default.

d. In the Field Properties pane, select the value in the Field Size property box. e. Type 30 4. Set the ManufacturerID field as the primary key.

a. Select the ManufacturerID record by clicking the record selector at its far left.

b. On the toolbar, click the Primary Key button. 5. Save the table with the name tblManufacturers and close the Design window.
If you notice in the database window that you misspelled the name of the table, you can change it. Right-click the table name and choose Rename. Enter the correct name and press Enter.

a. Click Save.

rE
NO T

c. Click OK.

to
DO

d. Click Close.

Lesson 8: Building the Structure of a Database

In st

ru c

DU

PL

IC

AT
159

b. In the Table Name text box, type tblManufacturers

di tio n

LESSON 8

ACTIVITY 8-5
Create the Computers Table

Scenario: Now that youve successfully created your rst table in Design view, youre ready to create the one to hold information on computers. The elds you need are listed in your database diagram. See Figure 8-2.
What You Do 1. In a new table design window, create an AssetTag text field that allows four characters. How You Do It

rE to
DO
2.

e. Type 4

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?

ru c
b) Number and Byte

c) AutoNumber and Long Integer

NO

3.

Create a ManufacturerID field with a data type of Number and a Field Size property of Long Integer.

In st

T
a. In the next Field Name field, type ManufacturerID b. Open the Data Type drop-down list and select Number. c. Click the Field Size property to verify that it is set to Long Integer.

d) Number and Long Integer

DU
Microsoft Ofce Access 2003 Level 1

a) AutoNumber and Byte

160

PL

IC

AT

d. Select the value in the Field Size property box.

di tio n
c. Press Tab.

Setup: The MyComputerInventory database is open.

a. Double-click Create Table In Design View. b. In the first Field Name field, type AssetTag

LESSON 8
4. Create a DateTime field named DateReceived that displays the ShortDate. a. In the next Field Name field, type DateReceived b. Open the Data Type drop-down list and select Date/Time. c. Click in the Format property box.

d. Open the Format drop-down list and select Short Date. 5. Create a number field named PurchasePrice. a. In the next Field Name field, type PurchasePrice

b. Open the Data Type drop-down list and select Number. 6. Because PurchasePrice is a field with financial data, what datatype would likely be better than number? b) Currency c) Yes/No d) Memo 7. Change the datatype to Currency.

rE
NO T

a) Text

to
DO

9.

Create an EmployeeID field as a Text data type.

In st

Lesson 8: Building the Structure of a Database

ru c

b. Open the Data Type drop-down list and select Yes/No. a. In the next Field Name field, type EmployeeID

b. Open the Data Type drop-down list and select Text. c. Select the value in the Field Size property box. EmployeeID is a foreign key to the Employees table and the primary key of that table has a field size of 4. Type 4

DU

8.

Create a Warranty field as a Yes/No data type.

a. In the next Field Name field, type Warranty

PL

b. Open the Decimal Places property dropdown list and select 0.

IC

a. For the DataType of the PurchasePrice field, select Currency.

AT
161

di tio n

LESSON 8
10. Set the primary key to AssetTag. a. Select the AssetTag field. b. Click Primary Key. 11. Save the table as tblComputers and close the table Design window. a. Click Save.

PRACTICE ACTIVITY 8-6


Activity Time: 10 minutes

Completing the Tables for the Database

rE
NO T

to
DO

2.

In st

Create and save the tblNotes table with these specifications: An AssetTag field with a data type of Text and a field size of 4. A Note field with a data type of Memo. The AssetTag field as the primary key.

ru c

DU

1.

Create and save the tblDepartments table with these specifications: A DeptCode field with a data type of Text and a field size of 3. A Department field with a data type of Text and a field size of 50. The DeptCode field as the primary key.

162

PL

Microsoft Ofce Access 2003 Level 1

IC

Scenario: You need just two more tables to nish the implementation of your database design. You have your database diagram, your notes about data types, and the previous activities as resources.

AT

di tio n
b. In the Table Name text box, type tblComputers c. Click OK. d. Click Close.

TOPIC D
Create Relationships between Tables
Once youve 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 cant harness the full power of a relational database management system like Access without 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 likely want to use to retrieve, display, and print your data.

LESSON 8

One-to-One Relationship

Denition: A one-to-one relationship is a relationship between two tables where both the primary key and the foreign key are unique. For each record in the rst table there will be one and only one record in the second table. Example:

rE to ru c
DO NO T DU

Lesson 8: Building the Structure of a Database

In st

Figure 8-3: A one-to-one relationship between two employee data tables, using the EmployeeID field as the key.
Information about employees might be separated into two tables for security access reasons.

PL

IC

AT
163

di tio n

LESSON 8
One-to-Many Relationship
Denition: A one-to-many relationship is a relationship between two tables where the primary key is unique but the foreign key allows duplicate values. For each record in the primarykey table there can be multiple records in the foreign-key table.
Depending on which of the two tables youre looking at, you can also express this as a many-to-one relationship.

Example:

rE to
DO

In st

Many-to-Many Relationship In examining the relationships between data in tables, you may nd 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 employees and another for projects, you might nd a many-to-many relationship if each employee could work on many projects and each project could involve many employees. This relationship cannot be implemented directly in Access and would have to be resolved by the creation of an intersection table containing, for example, just EmployeeID and ProjectNumber elds. This table would have a many-to-one relationship with both of the other tables.

ru c

Enforce Referential Integrity


Enforcing referential integrity for a relationship can avoid the loss or inadvertent updating of data. Guidelines: You can set referential integrity between two tables if the following are true:

NO

DU

Figure 8-4: A one-to-many relationship between a Customers table and an Orders table, using the CustomerID field as the key.

164

PL

Microsoft Ofce Access 2003 Level 1

IC

AT

di tio n

LESSON 8
Both tables are in the same Access database. The matching eld is a primary key in one table or has a unique index. The related elds have the same data type (the exception is that an AutoNumber eld can be related to a Number data type with a eld size of Long Integer).

You cant delete a record from the primary table (the table in which the primary key is the related eld) if a matching record exists in the related table. You cant 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. Additional concepts included orphaned records and cascading updates and deletes.

to
DO

How to Create Relationships between Tables


Procedure Reference: Create a Relationship and Enforce Referential Integrity To create a relationship between two tables and enforce referential integrity between them:
1. 2.

ru c

Choose ToolsRelationships to open the Relationships window. In the Show Table dialog box, select the tables you want to work with and click Add.
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.

Lesson 8: Building the Structure of a Database

In st

3. 4. 5. 6. 7.

Close the Show Table dialog box.

Select the key eld in the primary table that you want to relate to the second table. Drag the key to the related foreign key in the second table. In the Edit Relationships dialog box, check Enforce Referential Integrity. Click Create.

NO

DU

PL

IC

Example: A CustomerID autonumber eld in the Customers table is a unique primary key and can be related to a number eld in the Orders table in a one-to-many relationship. You dont want to allow the user to enter any order data for a customer that doesnt have a record in the Customers table. Nor do you want the user to alter the CustomerID eld 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.

rE

AT

E
165

di tio n

The Effects on Data Modication When referential integrity is enforced (without enabling the cascading options), certain rules apply to the data. This list gives you some examples. You cant enter a value in the foreign key eld of one table if there is not a matching value in the primary key of the related table.

Stress to students that there are more options available to using referential integrity than simply using it or not.

LESSON 8
8.

Close the Relationships window, saving changes to its layout.

ACTIVITY 8-7
Setup: The MyComputerInventory database is open and the Employees, Manufacturers, Computers, Departments, and Notes tables have been created.
If students had any difculty creating the tables, you can have them open the StagedMyComputerInventory database in the Solutions folder for this activity.

Scenario: 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 youve decided to enforce referential integrity in all relationships. You do this by working in the Relationships window. See Figure 8-5.

rE
NO T

to
DO

1.

ru c

In st

2.

Adjust the size of the tblComputers table so you can view the entire list of fields.

DU

Display all five tables in the Relationships window.

a. Choose ToolsRelationships. b. With tblComputers selected on the Tables tab of the Show Table dialog box, press Shift, and select tblNotes in the list of tables.

c. Click Add. d. Click Close. a. Place the mouse pointer over the bottom edge of the tblComputers table until the mouse pointer becomes a vertical double-headed arrow. b. Drag the bottom border down until you can view all fields and the vertical scroll bar is no longer displayed.

166

PL

What You Do

How You Do It

Microsoft Ofce Access 2003 Level 1

IC

Figure 8-5: The relationships in the MyComputerInventory database.

AT

di tio n

Creating One-to-Many and One-to-One Relationships

LESSON 8
3. 4. The tables in the Relationships window are arranged inalphabeticalorder by default. Rearrange the tables for optimal relationship mapping. a. Click and drag the tblManufacturer table under the tblNotes table. 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 and why? a) There is a one-to-one relationship because for every department record there will be one employee record. 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. 6. Create the relationship between the tblDepartments and tblEmployees tables. a. In the Departments table, select the DeptCode field.

In doing so you are dragging from the one-side to the many-side of the relationship.

to ru c In st
a) One-to-One b) One-to-Many c) Many-to-One d) Many-to-Many

7.

In the Edit Relationships window, what kind of relationship is given as the Relationship type?

Lesson 8: Building the Structure of a Database

DO

NO

DU

PL

IC

AT

E
167

b. Drag the DeptCode field of the tblDepartments table to the DeptCode field in the tblEmployees table.

rE

di tio n

LESSON 8
8. Enforce referential integrity in this relationship. a. In the Edit Relationships dialog box, check Enforce Referential Integrity. b. Click Create. 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 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. c) There is a one-to-many relationship because for each note record there could be many computer records. 10. Create the relationship between the tblComputers and tblNotes tables but do not enforce referential integrity in the relationship. a. Drag the AssetTag field from the tblComputers table to the AssetTag field of the tblNotes table. b. Verify that the Relationship Type is OneTo-One. Click Create.
Given that the data was fully normalized so that the Notes information is in a separate table, you would not want to enforce referential integrity 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 case and was the reason for normalizing this data (there were blank elds). This is an example where denormalizing the Notes data is an option.

rE to In st
DO NO
You might take this opportunity to review the issue or normalization and denormalization with students, using the tblNotes table as an example (see student note).

ru c

11. Create the relationship between the tblEmployees and tblComputers tables and enforce referential integrity in the relationship.

DU

a. Drag the EmployeeID field from the tblEmployees table to the EmployeeID field of the tblComputers table. b. Verify that the Relationship Type is OneTo-Many and then check Enforce Referential Integrity. c. Click Create.

168

PL

Microsoft Ofce Access 2003 Level 1

IC

AT

di tio n

LESSON 8
12. Create the relationship between the tblManufacturers and tblComputers tables and enforce referential integrity in the relationship. a. Drag the ManufacturerID field from the tblManufacturers table to the ManufacturerID field of the tblComputers table. b. Verify that the Relationship Type is OneTo-Many and then check Enforce Referential Integrity. c. Click Create. 13. Preview and print the Relationships window object, and then save your work.

a. Choose FilePrint Relationships to preview the printing of the Relationships window. b. Click Print.

If you do not have a printer available you will not be able to actually print this page and may get an error message.

to ru c In st
Lesson 8 Follow-up
1.

d. Close the Relationships window. e. Close the MyComputerInventory database.

In this lesson, you implemented your database design plan. You saw that creating a blank database 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 aggravation. You also learned that no database is complete without the right relationships between your tables to help maintain the accuracy of your data.
In what circumstances would you prefer to create a database using a template over creating one from scratch? Answers will vary, but may include: When development time is short or when there is a template that very closely fits your needs.

Lesson 8: Building the Structure of a Database

DO

NO

DU

PL

IC

Be sure to save the changes you have made to the relationships or the same graphical representation of the relationships will not be displayed the next time you open the window.

AT

E
169

c. Close the Report window that was opened and save the changes when asked.

rE

di tio n

LESSON 8
2. Do you think the Table Wizard will offer most of the table-building functions you require, or will you often build tables in Design view? Answers will vary.

rE to ru c In st
170

DO

NO

T
Microsoft Ofce Access 2003 Level 1

DU

PL

IC

AT

di tio n

LESSON 9

LESSON 9

Controlling Data Entry

In this lesson, you will control data entry by modifying the design of a table to streamline data entry and maintain data integrity.

to ru c In st
Lesson 9: Controlling Data Entry

DO

NO

DU

PL

IC

AT
171

Add a lookup eld to a table and modify a lookup list used in a lookup eld.

Create an input mask to limit the type of information that can be entered.

rE

You will: Restrict data entry with eld properties that set a default value, require data entry, and validate data.

di tio n

Lesson Time 40 minutes

LESSON 9
Introduction
You have a simple database and you want to control how data will be entered. There are numerous enhancements you can make to tables to enable this. In this lesson you will consider some that will help you to better control data entry.

TOPIC A

Restrict Data Entry with Field Properties

to
Description

Field Properties

ru c

To enhance a tables design and to facilitate data entry in the datasheet and its related forms, you can set eld properties. Each eld in your table has a set of eld properties that you can change and modify to affect how the eld looks and works. When you set these properties, you can increase the ease, speed, and accuracy of entering data. (See Table 9-1.)

Property
Format

In st

Default Value

A value that will be automatically entered for the eld when you create a new record. It only affects new records and does not alter the values of existing data. Establishing default values can save you a lot of typing, especially when one value will be consistently entered in a eld. 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 eld is dragged from the eld list.

Caption

DO

Determines the way data is displayed. For example, if you use the greater than (>) symbol, it forces all characters to uppercase so Access automatically capitalizes the data entered. Use the Format eld property when you need to display data in a consistent format.

NO

Table 9-1: Essential Field Properties that Affect How a Field Appears and Behaves

DU

172

PL

Microsoft Ofce Access 2003 Level 1

IC

Having the right kind of data in a eld can often be critical. Consider the case where a calculation on a number eld demands that no null (empty) elds be present. To avoid the possibility that a user forgets to enter a value, you can set eld 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 eld properties you can restrict the data so that a value of 6, for instance, would not be permitted. Simple eld properties can help to restrict data entry and eliminate errors in your tables and queries.

rE

The rst thing youll do to get started in controlling data entry is to work with properties of the elds in your tables. These properties can help make data entry more accurate.

AT

di tio n

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 eld. Or consider a required name eld: you can ensure consistency and reduce errors by requiring that each record have a name value.

LESSON 9
Property
Required

Description
If set to Yes, a value is required for that eld. If set to No, the value can be left blank. Access displays an error message if you attempt to save a record that has a null value in a required eld.

Validation Rule

Validation Text

A message that is displayed when the validation rule is violated. You can customize the error message thats displayed when a validation rule is violated or a required eld is left blank.

How to Restrict Data Entry with Field Properties


Procedure Reference: Set Field Properties To set eld properties:
1. 2. 3.

In the upper pane, click the name of the eld to display the properties for that eld.

rE
NO T

Display the table in Design view.

to
DO

Lesson 9: Controlling Data Entry

In st

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 tables design contains the validation rules, so each new record you enter must meet these validation rules.
You cant 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 eld.

ru c

Modied Field Properties Each time you change the properties in a tables design, you must save the table before 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 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 whether the records do or do not meet the new criteria. (There is no notication on an individual record basis. You would have to use queries to nd the data that does not meet the validation rules.)

DU

PL

4.

Save your changes to the table.

IC

To obtain help specic to this property, press F1.

AT

In the lower pane, click the text box for the desired property and add or update its value.

E
173

di tio n

Establishes a rule to set boundaries for data entry in a eld. For example, this property can be used with currency and number elds to check for minimum or maximum allowed values, or it can be used with date elds to ensure that the data isnt entered before or after a specied date.

LESSON 9

ACTIVITY 9-1
Setting a Default Value, Requiring Data Entry, and Validating Data
Data Files: Control.mdb

Scenario: You have a personnel database with employee information such as name, address, start date, 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 elds. Also, most employees work 40 hours a week and none get paid more than $30 per hour.
What You Do 1. In the Control database, open tblPayroll in Design view. How You Do It

rE
NO T

c. Open tblPayroll in Design view.

ru c In st
3.

DO

Set the default for the Hours field to 40.

DU

c. In the Field Name column, click in the ParkingLotCode cell. d. In the Format field property, enter > e. In the Caption property, enter Parking Lot a. Display the properties for the Hours field. b. The Default Value field property is set to 0. Select the Default Value property and change it to 40 c. Press Enter.

174

PL

Format the ParkingLotCode and Dept fields so that the values will be displayed in uppercase.

to

b. In the Field Properties pane, in the Format property text box, enter > to force uppercase.

Microsoft Ofce Access 2003 Level 1

IC

2.

a. Display the properties for the Dept field.

AT

di tio n
a. Open Control.mdb.

b. Maximize the Control database window.

LESSON 9
4. Require that values for the PayRate field be less than $30.00. a. Display the PayRate field properties. b. Select the Validation Rule property and change it to <30 5. Display a message when invalid data is entered and require that a value for this field be given. a. Press Tab to move the insertion point to the Validation Text property box.

b. In the Validation Text property box, type Must enter a value under $30. c. Press Tab to move to the Required property box.

d. From the Required drop-down list, select Yes. 6. Save this table as tblMyPayroll. a. Choose FileSave As to save the table with a new name. b. Save this table as tblMyPayroll

7. 8.

A default value of40is displayed in the Hours field. In the EmployeeID field, enter en160.

to
DO

a. In the EmployeeID field, type en1-60 b. Press Enter.

9.

b. Press Enter.

In st

c. Click OK.

Lesson 9: Controlling Data Entry

NO

In the PayRate field, test the validation properties and then enter 22.50.

ru c

a. In the PayRate field, type 32.50

DU

c. In the Hours field, press Enter.

PL

IC

AT
175

c. Switch to Datasheet view.

rE

di tio n

LESSON 9
d. Delete the value you typed, and then with the field empty press Enter.

10. Complete the record by entering tw in the Dept field, bl in the ParkingLotCode field, and a check mark in the Health field.

rE
NO T

11. Save the record and close the table.

to In st
DO

ru c
176

DU

b. Close the table.

PL

a. The pencil icon is still displayed at the left end of the record, indicating that the record isnt saved yet. Press Enter to save the record and remove the pencil icon.

Microsoft Ofce Access 2003 Level 1

IC

AT

di tio n
e. Click OK. f. Enter 22.50 g. Press Enter. a. In the Dept field, enter tw

b. In the ParkingLotCode field, enter bl c. In the Health field, press Spacebar to enter a check mark.
You can also click in the check box to check (or uncheck) it.

TOPIC B
Create an Input Mask
You have just used some of the properties of your elds to improve the accuracy of the data in your tables. In this topic you will use another eld property to limit the format that users can enter data in. Suppose you have a phone number eld. 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 remember the pattern and other times you forget. If you could force data input to match a specic pattern, this problem would be solved, thereby eliminating inconsistency in this eld in 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 dont have to enter them yourself.

LESSON 9

Input Masks

rE
NO T

to
DO

The third section represents the character that is displayed for blanks in the input mask. By default, it is an underscore, but you can use any of a variety of characters. To display a space (or empty string), use two quotation marks ( ).

Lesson 9: Controlling Data Entry

In st

ru c

DU

PL

The second section determines whether the literal display characters are stored. If you leave this section blank or enter a 1, only the characters the user enters are stored; if you enter a 0, the display characters (along with the characters the user enters) are stored. By not storing the literal display characters, you can reduce the size of your database.

IC

Input Mask Sections An input mask denition can contain up to three sections, separated by semicolons: The rst section is the input mask itself.

AT
177

Denition: An Input Mask is a eld property that establishes a pattern that dictates how users can enter data into the eld. An input mask contains literal characters (for example, spaces, dashes, or parentheses) that separate blanks the user lls in. The blanks are represented by characters that control the type of data the user can type in.

di tio n

LESSON 9
Example: Telephone Number Input Mask

Figure 9-1: The input mask for a standard telephone number including area code. Example: Zip Code Input Mask

rE to
DO

Figure 9-2: The input mask for a Zip Code with an optional four-digit extension. Input Mask Wizard Most often, input masks are created using the Input Mask Wizard. This wizard provides several common, predened 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 can use. Be sure to check your data rst to be aware of any conicts that might arise from a modied input mask.

ru c
1. 2. 3. 4. 5.

How to Create an Input Mask

In st

Procedure Reference: Add an Input Mask Using the Wizard To add an input mask using the wizard: In the Table Design view window, click the eld that the input mask will belong to. In the Field Properties pane, click in the Input Mask property box. Click the Build button at the end of the line to start the Input Mask Wizard. Choose an input mask type. Click Next. Choose the desired placeholder. Click Next.
Microsoft Ofce Access 2003 Level 1

178

NO

DU

PL

IC

AT

di tio n

LESSON 9
6. 7.

Choose whether the symbols will display to the user. Click Next. If you want to modify an input mask, click Edit List. You can change the placeholder character and choose to store constant characters like dashes and slashes with the eld value. Click Finish when you are done with the wizard.
The Input Mask Wizard is available for Text and Date/Time elds. If you want to create an input mask for a Number or Currency eld, you must create it manually instead of using the wizard.

8.

Procedure Reference: Manually Add an Input Mask to a Field To manually add an input mask to a eld:
1. 2. 3.

In the Table Design view window, click the eld that the input mask will belong to. In the Field Properties pane, click in the Input Mask property box. Enter the input mask desired for this eld.

to
DO

Data Files: Control.mdb

ru c

What You Do 1.

In st

How You Do It

Display the properties for the Phone field in the tblPersonal table.

a. To review the phone and Zip code data, open tblPersonal. b. Switch to Design view. c. Display the field properties for the Phone field.

Lesson 9: Controlling Data Entry

NO

Scenario: In order to improve data entry for the tblPersonal table, you decide to add input masks to the Phone, ZipCode, and EmployeeID eld properties to ensure that data entry is uniform.

DU

Setup: The Control database window is open. The additional wizards were installed as part of the class setup.

PL

IC

Adding Pre-dened and Custom Input Masks

AT
179

ACTIVITY 9-2

rE

Placeholders are replaced as you enter data into the eld. The default placeholder is the underscore.

di tio n

LESSON 9
2. Start the Input Mask Wizard to add an input mask for all phone numbers. a. Click in the Input Mask property box. b. Click the Build button .

3.

rE to ru c In st
180
f.

NO

DO

DU

For more information about the symbols used in Input Masks, press F1 to consult the Help specic to this property.

g. Save the modified table design.

PL

Click Finish. Press Enter. The input mask is entered in the property box for the Phone field.

Microsoft Ofce Access 2003 Level 1

IC

AT

di tio n
d. Click Next.

Use the wizard to create the input mask. Save the modified table design.

a. In the Input Mask list box, verify that Phone Number is selected. Click Next.

b. To see the available placeholders, display and scroll through the Placeholder character drop-down list. There are several options available.

c. Select the underscore character so its displayed in the Placeholder Character box.

e. Verify that the default option, Without The Symbols In The Mask, Like This, is selected. Click Next.

LESSON 9
4. Add an input mask for the ZipCode field that reflects the zip code + 4 convention. a. Display the field properties for the ZipCode field. b. Click in the Input Mask property box. c. Click the Build button. d. Select Zip Code. e. Click Next. f.

Click Next to accept the defaults.

g. Verify that the default option, Without The Symbols In The Mask, Like This, is selected. Click Next.

h. Click Finish. The input mask is entered in the property box for the ZipCode field. i. 5. Create an input mask that reflects the pattern for the EmpID field.

rE
NO T

Save the modified table design.

to ru c In st
f.

d. To create from scratch, rather than edit an existing mask, click the New Record button .

e. In the Description text box, type Employee ID and press Tab. Type !LL0-00 and press Tab.

g. Type _ (the underscore character), and then press Tab.

Lesson 9: Controlling Data Entry

DO

DU

PL

c. You can customize or create an input mask list right in the wizard. Click Edit List.

IC

b. Start the Input Mask wizard.

AT
181

a. Display the field properties for the EmpID field.

di tio n

LESSON 9
h. Type EN1-80 and press Tab.

rE
l.

to ru c
6.

NO

Save the modified table design. Prepare to enter a new record.

DU

m. Click Finish. a. Save the modified table design. b. Change to Datasheet view. c. Click the New Record button .

In st

DO

182

PL
Microsoft Ofce Access 2003 Level 1

IC

This time, select the With The Symbols In The Mask, Like This option. Click Next.

AT

di tio n
i. Click Close. j.

You need to enter a value in the Sample Data box now; its later displayed in the list of input masks.

Select the Employee ID input mask from the list.

k. Click Next twice to advance in the wizard.

LESSON 9
7. Enter a new record in the table to test your input mask. a. Type en160 and press Tab. b. Type Thacher and press Tab. c. Type Jeremy and press Tab. d. Type 33 Strong Rd and press Tab. e. Type Dresden and press Tab. f. Type ny and press Tab.

g. Type 145278788 and press Tab.

h. Type 2155558288 and press Tab. i. j.

Type 08/20/2001 and press Enter.

rE
NO T DU

Close tblPersonal.

to
DO

Create a Lookup Field

Lookup List Fields

Denition: A lookup list is a list of values that you can choose from when entering data in a eld. 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 eld. Column headings can be optionally displayed, and column widths can be adjusted as needed.

Lesson 9: Controlling Data Entry

In st

When someone should choose only from a specic set of options, its much easier to have them select from that set of options, rather than leaving it wide open to ll in what they please, in the way they please. A set of choices is particularly useful if you repeatedly enter the same data in a eld and you want to limit typing and reduce errors. As an added bonus, entering data in a consistent manner enables you to derive solid summary information for the eld, because you can more easily build queries using that eld as a criteria.

ru c

Youve looked at eld properties and input masks as a means for controlling data entry in your tables. Another way to control data entry is to limit the exact values that can be entered in a eld. In this topic, youll create a drop-down list of items to choose from when entering data in a eld.

PL

IC

TOPIC C

AT
183

di tio n

LESSON 9
A lookup list can be created by using the Lookup Wizard or can be created manually by using various eld properties on the Lookup tab in Design View. The resulting list that the user will see can be either a List Box or a Combo Box. By creating a lookup eld with the wizard, in the Row Source property, the wizard automatically generates a SQL statement that selects the elds you choose from the table or query.

Example: Single-column Lookup List

to ru c In st
184

Figure 9-4: A lookup list that displays multiple columns to ease the selection of a products CategoryID.

DO

NO

T
Microsoft Ofce Access 2003 Level 1

DU

PL

IC

AT

Example: Multi-column Lookup List

Figure 9-3: A lookup list with custom values for personal title abbreviations.

rE

di tio n

LESSON 9
Lookup List Relationships Relationships will automatically be created when you create a lookup list eld. To see these relationships, you can choose the Show All option in the Relationships Window.

How to Create a Lookup Field


Procedure Reference: Create a Lookup Column Based on a Table To create a lookup column based on a table (or query):
1. 2. 3. 4. 5. 6. 7. 8. 9.

In table Design view, select the eld in which you want to include a drop-down list of values. In the Data Type column, select Lookup Wizard.

Choose to base the list on the values in a table (or query). Click Next. Choose the desired table (or query). Click Next.

Select elds to appear in the lookup list. Click Next.

Choose any desired sort criteria for the displayed columns in the lookup column. Click Next. If desired, uncheck Hide Key Column.

10. Type a label for this eld. Click Finish. 11. Save your table.

to
DO NO

Adding a Lookup Field to a Table Using the Lookup Wizard


Data Files: Control.mdb

ru c

Scenario: The Dept eld in tblPayroll stores department codes for each department. To ensure a valid department code in a new record and to simplify data entry, you will create a lookup list that displays both the department codes and the names, with column headings. You will restrict data entry to only the department codes in the tblDeptNames table. (See Figure 9-5 .)

Lesson 9: Controlling Data Entry

In st

Setup: The Control database window is open. The additional wizards were installed as part of the class setup.

DU

PL

ACTIVITY 9-3

IC

AT
185

Choose a column whose value will be stored for this eld. Click Next.

If necessary, double-click column borders to resize them for the best t. Click Next.

rE

di tio n

LESSON 9

Figure 9-5: A lookup list that displays department codes and names.
What You Do 1. In tblPayroll, start the Lookup Wizard for the Dept field. How You Do It

rE to
NO DO
2.

ru c

In st

T
b. Verify that tblDeptNames is selected from the list of tables and click Next. c. From the Available Fields list box, move both fields to the Selected Fields list box, by pressing the >> button, and then click Next.

DU

Specify the source data for the lookup column. Display both columns from tblDeptNames in the lookup column.

a. Verify that the I Want The Lookup Column To Look Up The Values In A Table Or Query option is selected. Click Next.

186

PL

Microsoft Ofce Access 2003 Level 1

IC

AT

di tio n
a. Open tblPayroll in Design view.

b. Display the DataType drop-down list for the Dept field. c. To start the wizard, select Lookup Wizard.

LESSON 9
3. Sort and adjust the width of the fields in the Lookup Column. a. Display the drop-down list for the first sort criteria.

b. Select DeptCode. Click Next. c. Uncheck Hide Key Column.

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.

d. For best fit, double-click the DeptName right column border.

rE to
4. Use DeptCode as the field that uniquely identifies the row in the lookup column and finish the wizard.

ru c

e. Click Next.

b. For the lookup column label, type DeptCode

In st

d. Click Yes to save the table before Access can create relationships.

Lesson 9: Controlling Data Entry

DO

c. Click Finish.

NO

a. In the Available Fields list box, verify that DeptCode is selected. Click Next.

DU

PL

This will only resize the column to t the values that are shown.

IC

AT
187

di tio n

LESSON 9
5. Test the behavior of the lookup list by assigning the first employee to a new department. a. Switch to Datasheet view. b. In the first record, select the DeptCode field. A drop-down arrow indicates the presence of the list.

6.

Display the properties established by the wizard for the lookup list.

rE
NO T

c. In the Field Properties pane, select the Lookup tab. a. On the Lookup tab, change the Column Heads field property to Yes.

to
DO

7.

b. Save the modified table design.

ru c In st
188

DU

c. Switch to Datasheet view. d. In the DeptCode field, display the Lookup list for the first record to see the column headings.

e. Close the lookup list.

PL

Include the column headings in the lookup list and display the lookup list.

Microsoft Ofce Access 2003 Level 1

IC

AT

di tio n
d. Select AC for the Accounting department. a. Switch to Design view.

c. Click the drop-down arrow to display the lookup list.

b. If necessary, select the DeptCode field.

LESSON 9
8. Restrict entries in the field only to items on the list. a. Switch to Design view and change the Limit To List field property to Yes. b. Save the modified table design. 9. Test to see how this affects the lookup list interaction and then close the table. a. Switch to Datasheet view.

b. In the DeptCode field for the first record, select the value, type PO, and press Enter. c. Only the department names listed are acceptable. Click OK. Click Undo. d. Close tblPayroll.

e. If asked, save your changes. f.

Close the Control database window.

rE
NO T

Lesson 9 Follow-up
1.

to
DO

Where do you expect to use Input Masks to control data entry in your databases?

2.

Where do you expect to use Lookup Fields to control data entry in your databases? Answers will vary.

Lesson 9: Controlling Data Entry

In st

ru c

DU

Answers will vary, but might include phone, Zip Code, Social Security, or custom ID or partnumber fields.

PL

In this lesson, you controlled data entry by modifying the design of a table. By modifying various eld properties, and by using input masks and lookup elds, you have increased the consistency of your data and reduced data entry errors.

IC

AT
189

di tio n

NOTES

rE to ru c In st
190

DO

NO

T
Microsoft Ofce Access 2003 Level 1

DU

PL

IC

AT

di tio n

LESSON 10

LESSON 10

Finding and Joining Data


You will: Apply a lter to view records that match criteria you specify. Create query joins to retrieve the desired data. Relate data within a single table to itself.

In this lesson, you will nd and retrieve desired data by using lters and joins between tables and within a single table.

to ru c In st
Lesson 10: Finding and Joining Data

DO

NO

DU

PL

IC

AT
191

Join two unrelated tables by including additional tables in a query.

rE

di tio n

Lesson Time 1 hour(s)

LESSON 10
Introduction
Youve worked with simple queries that returned a specic record or a subset of records from a table. In this lesson, you will further this knowledge by using lters, building queries that retrieve data from multiple tables, and relating data within a single table to retrieve the desired 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 nd the available employees who know Java from both your Seattle and Baltimore offices. Joining those results together into one set of records would efficiently create the ideal project team.

TOPIC A

Find Data with Filters

to
DO

Types of Filters

Filtering data can help you review and analyze information in your database. You can use one of several techniques to lter data. (See Table 10-1.) Table 10-1: Filter Techniques Filter Technique Results
Filter By Selection Filter Excluding Selection Filter By Form

ru c

Looks for values other than what you select. Shows you a blank record where you can enter either the value you want to nd or choose it from a drop-down list. Lets you freely combine conditions and elds for a lter. You can also use this to sort a ltered view or set up multi-eld sorts.

In st

Advanced Filter/ Sort

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 lter 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 lter settings: right-click in the top pane and choose Clear Grid.
Microsoft Ofce Access 2003 Level 1

192

NO

Lets you select a value in a datasheet or form and click a button to view any matching records.

DU

PL

IC

AT

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 eld. Instead of leaving the table and creating a query to return these records, you can save time by simply applying a lter to the table. Such a lter is like a magic wand for quickly getting to the data you want.

rE

There are many ways to nd the data you need. In this topic you will learn the simplest approach by using table lters. Youll use several different methods for nding and displaying the desired records.

di tio n

LESSON 10
How to Find Data with Filters
Procedure Reference: Use the Filter By Selection Technique To use the Filter By Selection technique, perform the following steps:

2. 3.

Select one instance of the value that you want included in the view. Click the Filter By Selection button.

You can continue ltering until you get the results you want.

Procedure Reference: Use the Filter By Form Technique

To use the Filter By Form technique, perform the following steps:


1. 2. 3. 4.

Open a table in datasheet view. Open the Filter By Form window. Specify the criteria on the Look For and Or tabs. Apply the lter.

Procedure Reference: Create an Advanced Filter or Sort

rE
NO T
Example
=11/29/1961

To create an advanced lter or sort, perform the following steps:


1. 2. 3. 4.

Open the Datasheet or Form view you want to lter.

to
DO

Open the Advanced Filter/Sort dialog box. In the lter window, clear the grid.


5.

From the list in the top of the window, click and drag a eld name. From the drop-down list for the Field row, choose a eld name.

Enter a value in the Criteria row for the eld. For an And lter, enter criteria for two elds.

For an Or lter, enter an additional condition in the Or row for whatever eld it applies to.

Using Criteria to Filter Records Criteria are conditions that identify the records you want to nd.

In st

6. 7.

If necessary, sort records. Apply the lter.

Criteria
=

Lesson 10: Finding and Joining Data

ru c
Finds Values

with the exact match

DU

In the Field row, type a eld name.

PL

Enter a eld name in the grid. You can use any of the following techniques: On the list in the top of the window, double-click a eld name.

IC

AT
193

di tio n

1.

Open a table or query in datasheet view.

LESSON 10
Criteria
< <= > >= <> Is Null Between And

Finds Values
less than less than or equal to greater than greater than or equal to not equal to that are empty within a range

Example
<K <=2500 >K >=2500 <>Michigan

Removing a Filter Click Remove Filter if you need to remove a lter 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 lter view.

Data Files: Join.mdb

to
DO

ru c

What You Do 1.

NO

In st

In Join.mdb, apply a filter to tblBookProject to include only those projects managed by Sarah Rubenstein.

DU

Scenario: You have a couple of burning questions on your mind related to project management and sales territories. You decide to use lters on your various database tables to get answers. First, in tblBookProjects, you want to show the projects managed by Sarah Rubenstein (EN1-15). Next, in tblCustomer, you want to show only those customers for salesperson Lauren MacKenzie (EN1-20). Finally, youre considering redistricting the sales territories and want to see whether or not adding the Canadian customers to Laurens sales territory would be too much.
How You Do It

a. Open Join.mdb. b. Open tblBookProject in datasheet view. c. In the ProjectManager field, place the insertion point on the first record that has a value of EN1-15. d. Click the Filter By Selection button.

194

PL

Microsoft Ofce Access 2003 Level 1

IC

AT

Finding Data with Filters

rE

ACTIVITY 10-1

di tio n

Between 5/1/2001 And 8/31/ 2001

LESSON 10
2. How many records matched the filter? a) 13 b) 14 c) 15 d) 20 3. Remove the filter and close the table.

a. Click the Remove Filter button.

b. Close the table, without saving the changes. 4. Apply a filter to tblCustomer to include only those customers assigned to salesperson Lauren Mackenzie. a. Open tblCustomer.

b. To specify criteria for the datasheet, click the Filter By Form button .
At the bottom of the window, notice the two tabs, Look For and Or. The Look For tab is selected.

to ru c
5. How many records matched this filter? a) 3 b) 5 c) 6 d) 7

d. Select en1-20.

e. Click the Apply Filter button.

In st

6.

Apply a filter which includes those customers assigned to Lauren Mackenzie or those customers in Canada. Then remove the filter completely and close the table.

a. Click the Filter By Form button. b. Select the Or tab.

Lesson 10: Finding and Joining Data

DO

NO

DU

PL

IC

AT
195

c. Place the insertion point in the Salesperson field and display the drop-down list.

rE

di tio n

LESSON 10
c. Display the Country drop-down list and select Canada.

7.

How many records match either salesperson en1-20 or have a country of Canada? a) 6 b) 8 c) 10 d) 12

8.

Remove the filter and close the table.

rE
NO T

to
DO

Finding Data with Advanced Filters


Data Files: Join.mdb

In st

Setup: The Join.mdb database is open in Access.

Scenario: As President of the Book Source business, development costs are always an area of concern for you. You decide to gather some historical data by combining criteria about costs and dates. You are working with tblBookProject and you want to nd any projects whose development costs were greater than $12,000 and whose product ship date was after January 1, 1999.

ru c

DU
Microsoft Ofce Access 2003 Level 1

ACTIVITY 10-2

196

PL

IC

AT

b. Close the table, without saving the changes.

di tio n
d. Click the Apply Filter button.

The Remove Filter and Apply Filter buttons function as one toggle button.

a. Click the Remove Filter button to view all 14 records again.

LESSON 10
What You Do 1. In tblBookProject, use the Advanced Filter dialog box to set the criteria for the development costs to greater than $12,000. How You Do It a. Open tblBookProject. b. Choose RecordsFilterAdvanced Filter/Sort. c. Drag the DevelopmentCost field from the tblBookProject field list to the first Field cell in the filter grid. d. In the Criteria cell for the DevelopmentCost field, type >12000 2. Set the criteria for the ShipDate field to after Jan 1, 1999. Apply your filter.

a. Drag the ShipDate field from the field list to the next Field cell in the filter grid.

b. In the Criteria cell for the ShipDate field, type >1/1/1999 c. Click the Apply Filter button. 3. How many records match both criteria? a) 2 b) 3 c) 4 d) 5 4. Remove all filters and close the table.

rE
NO T

to
DO

a. Click the Remove filter button. b. Close tblBookProject without saving the changes.

Lesson 10: Finding and Joining Data

In st

ru c

DU

PL

IC

AT
197

di tio n

LESSON 10

TOPIC B
Create Query Joins
You have worked with lters to eliminate from view the records that dont 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, youll use query joins to accomplish this goal. When you run a query to nd 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 the different types of query joins, you can control the records that will be displayed as output. This enables you to again nd exactly the data you wantnot more and not less.

Query Joins

A join is a temporary relationship you create between two tables in a query that do not already have an established relationship or a common eld with the same name and datatype. Tables joined in a query are related only within that query and nowhere else. The type of join indicates which records the query selects or performs an action on.
Creating a query join will not establish a permanent relationship between the tables. Permanent relationships can be created only in the Relationships window. Self joins will be considered in further detail later in this lesson.

rE
NO T

Inner Join

to
DO

In st

ru c
198

The inner join is alternately known as an equi-join.

The inner join is the default join type in Access.

DU
Microsoft Ofce Access 2003 Level 1

PL

Denition: An inner join is a join that selects only those records from both tables that have matching values. Records with values in the joined eld that do not appear in both tables will be excluded. One or more elds can serve as the join elds.

IC

AT

di tio n

LESSON 10
Example:

Figure 10-1: Conceptual diagram of an inner join between Projects data and Employees data.

Outer Join

to
DO

ru c

Lesson 10: Finding and Joining Data

In st

NO

DU

Denition: An outer join selects all the records from one table and only those records in the second table that have matching values in the joined eld. In a left outer join, the selected records will include all records of the rst table. In a right outer join, the selected records will include all records of the second table. One or more elds can serve as the join elds.

PL

IC

AT
199

Analogy: Consider a business that employs both managers and engineersand 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.

rE

di tio n

LESSON 10
Example: Left Outer Join

Figure 10-2: Conceptual diagram of a left outer join between Projects data and Employees data.

rE
NO T

Example: Right Outer Join

to In st
DO

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.

ru c
200

Figure 10-3: Conceptual diagram of a right outer join between Projects data and Employees data.

DU
Microsoft Ofce Access 2003 Level 1

PL

IC

AT

Analogy: 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.

di tio n

LESSON 10
How to Create Query Joins
Procedure Reference: Create a Join Line Between Tables in a Query Design View To create a join line between the tables in the query Design view:
1. 2.

Display the query in Design view.

Drag a eld from one table to the matching eld in the other table.

Procedure Reference: Change the Join Type To change the join type of a query:
1. 2. 3. 4.

Display the query in Design View.

Click the Join Type button to display the Join Properties dialog box.

Click 2 or 3, depending on which table you want to show all the records for. Click OK.

rE
NO T

Removing Joins in Queries If you need to delete the join between tables in a query, right-click the join line between them. From the shortcut menu, choose Delete (or, from the main menu, choose EditDelete); 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.

In st

The broken join is effective only for the query in which you broke the join.

Lesson 10: Finding and Joining Data

DO

ru c

DU

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. Option 1 in the dialog box is the inner join. Options 2 and 3 represent outer joins. 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 one or primary table is usually drawn to the left of the many or secondary 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.

to

PL

IC

AT

E
201

Cross-product Query 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.

di tio n

LESSON 10

ACTIVITY 10-3
Creating an Inner Join and an Outer Join
Join.mdb

Setup: The Join database window is maximized.

Scenario: Suppose youve 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 those that lack any sales records.
What You Do 1. Run the existing query. How You Do It

rE
NO T

to
DO

In st

ru c
False

DU
Microsoft Ofce Access 2003 Level 1

True

202

PL

3.

True or False? The reason this many records appear is because no join between the tables has been established, so each record from tblBookProject is combined with each record from tblBookSales.

IC

2.

2900records are in the query results.

AT

b. Run the query.

di tio n

Data Files:

a. Open qselBooks in design view and observe its current structure.

LESSON 10
4. What fields should you use to join these tables? a) Part# and OrderID b) Part# and PartNumber c) BookTitle and OrderID d) BookTitle and PartNumber

rE to
DO
5. Join the tables and then run the query again.

ru c In st
Lesson 10: Finding and Joining Data

You must drag in this direction to create the correct join.

b. Run the query.

NO

DU

PL

a. If necessary, change to Design view and drag Part# from the tblBookProject field list to PartNumber in the tblBookSales field list.

IC

AT
203

di tio n

LESSON 10
6. Only books with sales are displayed. How many records for such books are in the result? a) 29 b) 90 c) 100

7.

Change the join type to an outer join so that the query will list all the records from tblBookProject and only the matching records from the joined table, tblBookSales.

rE to ru c In st
8. a) 29 b) 100 c) 108 d) 2900

c. Verify that the arrowhead points to the table contributing only the matching records. This is a left outer join.

NO

All the records from tblBookProject are displayed. Only the matching records from tblBookSales are displayed. How many results are displayed?

DO

T
d. Run the query.

DU
Microsoft Ofce Access 2003 Level 1

204

PL

IC

AT

di tio n
b. Select option 2. Click OK.

d) 2900

a. Change to Design view and double-click the line that joins the two tables.

LESSON 10
9. Save and close the query. a. Save the query as qselMyOuterJoin b. Close the query.

TOPIC C
Join Unrelated Tables

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. Consider the case where you have two tables with the data you need, but the tables are not directly related to each other by a common eld. To join such unrelated tables, you can often include an additional table as a middle-man to create the link relationship. Doing so will enable you to retrieve exactly the data that you desire from multiple, unrelated tables.

Procedure Reference: Join Unrelated Tables by Adding a Table to a Query Design

2. 3. 4. 5.

Click the Show Table button.

If necessary, join the tables.

Complete your query design by adding the elds you want to display to the grid.

ru c

In st

Lesson 10: Finding and Joining Data

DO

NO

You can create more than one join between a pair of tables.

DU

Select the table and click Add.

PL

1.

Open a query in Design View.

IC

To join unrelated tables, you can add a table to the query design:

to

AT
205

How to Join Unrelated Tables

rE

di tio n

LESSON 10

ACTIVITY 10-4
Joining Two Unrelated Tables
Join.mdb

Setup: The Join database window is maximized.

Scenario: You need a query that shows each book title listed with each customer that has ordered it. The eld Part# is in tblBookProject and the eld CustomerName is in tblCustomer. However, the tables tblBookProject and tblCustomer do not have any elds in common.
What You Do 1. View the current design of qselCustomerNames and add tblBookSales to the query design grid. How You Do It

rE
NO T

to In st
DO

ru c

DU

d. The tables are already related. Verify that the tables are automatically joined together.

206

PL

c. Select tblBookSales. Click Add. Click Close.

Microsoft Ofce Access 2003 Level 1

IC

b. Click the Show Table button

AT

Just as a bridge connects two places, the Book Sales table is like a bridge between the tables whose data you want to use.

You must open the query in Design view; otherwise, you will get an error message.

di tio n

Data Files:

a. In Design view, display the query qselCustomerNames. The two tables do not share a common field.

LESSON 10
2. Create the query by including BookTitle and CustomerName in the design grid. a. From tblBookProject, drag BookTitle to the first Field cell. b. From tblCustomer, drag CustomerName to the next Field cell. 3. Run qselCustomerNames. a. Run the query.

4.

True or False? Books that lack sales will not appear because this is an equi-join and not a left-outer join.

to ru c
DO NO

False

Lesson 10: Finding and Joining Data

In st

DU

PL

IC

True

AT

E
207

c. Close the query.

rE

b. Verify that 100 records are displayed. Save the updated query.

di tio n

LESSON 10

TOPIC D
Relate Data Within a Table
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. Consider the case where all the data you need is in a single table, but you need to be able to relate columns in that table to each other to extract the desired records. For example, perhaps an employee table has both an ID eld for each record and also a eld showing the ID of that employees 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.

Self Joins

rE
NO T

Example:

to In st
DO

ru c
208

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 different records.

DU
Microsoft Ofce Access 2003 Level 1

PL

IC

AT

Denition: A self join is a join that relates data in a table to itself. A table is joined to itself based on a eld or combination of elds that have duplicate data in different records. The datatype of the inter-related columns must be the same.

di tio n

LESSON 10
How to Relate Data Within a Table
Procedure Reference: Create a Self Join To create a self-join:

2. 3. 4. 5.

Click the Show Table button.

Add the table to your query so that it appears twice. Join the related elds.

Complete your query design by adding the elds you want to display to the grid.

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 underlying table.

Creating a Self Join


Data Files: Join.mdb

rE to
DO NO T DU

ACTIVITY 10-5

Lesson 10: Finding and Joining Data

In st

ru c

Scenario: You need to design a query to display supervisor names for each employee. The tblSupervisors table contains information about employees and their supervisors. The supervisor is identied according to his or her Employee ID number.

PL

Setup: The Join database window is maximized.

IC

AT
209

di tio n

1.

Open a query in Design View.

LESSON 10
What You Do 1. How You Do It

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 c) Dept and SupervisorId d) LastName and SupervisorId 2. Add tblSupervisors to the query design grid a second time.

rE
NO T

to ru c
3. Assign an alias of Managers to the second table.

d. Close the Show Table dialog box.

In st

DO

DU

a. Right-click the tblSupervisors_1 field list to display the object menu. Choose Properties.

210

PL

c. Select tblSupervisors. Click Add.

You may want to make this second table list wider in order to see its full title.

Microsoft Ofce Access 2003 Level 1

IC

b. Click the Show Table button.

AT

You must open the query in Design view; otherwise, you will get an error message.

di tio n

a. In Design view, display qselSupervisors.

LESSON 10
b. In the Alias property box, type Managers and press Enter.

c. Close the Field List Properties dialog box. 4. Create the self-join based on the SupervisorId field in the table and the Id field in its copy. a. Locate the SupervisorId field in the tblSupervisors field list.

rE
NO T

b. Drag the SupervisorId field from the tblSupervisors field list to the Id field of the Managers table.

to In st
Lesson 10: Finding and Joining Data

DO

ru c

DU

PL

IC

AT
211

di tio n

LESSON 10
5. Add the FirstName and LastName fields from the tblSupervisors field list and the LastName field from the Managers field list. a. From the tblSupervisors field list, add the field FirstName to the first Field cell of the query design grid. b. From the tblSupervisors field list, add the field LastName to the second Field cell of the query design grid.

rE
NO T

6.

Change the caption property for the LastName field in the Managers and tblSupervisors tables.

a. In the design grid, right-click the LastName field from the Managers table. Choose Properties. b. Click in the Caption property box. c. Type ManagerName

to In st
DO

ru c
212

DU
d. Close the Field Properties dialog box. e. Set the caption property for the LastName field from tblSupervisors to be LastName.

PL

Microsoft Ofce Access 2003 Level 1

IC

AT

di tio n

c. From the Managers field list, add LastName to the third Field cell of the query design grid.

LESSON 10
f. Run the query.

b. Close the query.

to
Lesson 10 Follow-up

c. Close the Join database.

Answers will vary.

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? Answers will vary.

Lesson 10: Finding and Joining Data

DO

1.

In st

You can use filters and query joins whenever you find yourself thinking, I need to know, or when youre 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?

NO

In this lesson, you focused on nding and displaying data using lters and queries. Being able to lter data means that you can locate and work with the specic information that youre interested in at a particular time. By using query joins, you can obtain data from multiple related tables or from related data in a single table. Doing so greatly expands the kind of data reports you can create.

ru c

DU

PL

IC

AT
213

Save and close the query and the Join database.

7.

a. Save the query as qselMySelfJoin

rE

You might need to expand the column width to view the complete caption.

di tio n

NOTES

rE to ru c In st
214

DO

NO

T
Microsoft Ofce Access 2003 Level 1

DU

PL

IC

AT

di tio n

LESSON 11

LESSON 11

Creating Flexible Queries

In this lesson, you will create exible queries to display specied records; allow for userdetermined query criteria; and add, update, and delete data with queries.

to ru c In st
Lesson 11: Creating Flexible Queries

DO

NO

DU

PL

IC

AT

Create action queries that update, add, and delete multiple records in an underlying table.

E
215

Create queries that accept criteria from the user on the y.

rE

You will: Set select query properties to show top and bottom values and show records that contain unique values in selected elds.

di tio n

Lesson Time 1 hour(s)

LESSON 11
Introduction
Youve worked with simple queries, and youve retrieved related data from multiple tables using query joins. Flexible queries can do even more than this, however, and in this lesson you will see how to use queries to automatically return subsets of data, accept criteria from the user at runtime, and modify the data in a table. As a member of the Human Resources department, you have been asked to nd the people in your resume database that have networking or HTML skills. Instead of using two separate queries, you can use the same exible query twice by allowing for dynamic criteria. Once a decision is made on who will be hired, an additional query could be used to automatically update their records to reect this change in status.

TOPIC A

Set Select Query Properties

to
Description

Access provides properties you can set for a select query to restrict what records will be shown.

ru c

Property

Top Values

In st

A query property that enables the user to specify how many values to display in the datasheet. You can set its value as either a discrete number of records to show (for example, 15) or as a percentage of the records returned by the query (for example, 20%). To show top values or bottom values, set values of either Ascending or Descending for the Sort cell of the query design grid for that eld. A query property that when set to Yes will restrict the records returned to those that have unique values in the elds in the query design grid. A query property that when set to Yes will restrict the records returned to those that have unique values in all elds in the underlying tables or queries. That is, the records in those tables are themselves unique.

Unique Values

Unique Records

DO

NO

Table 11-1: Select Query Properties

T
Microsoft Ofce Access 2003 Level 1

216

DU

Select Query Properties

PL

There are some types of select queries that youll nd yourself creating again and again. For example, showing the top ten salespeople on your staff or the bottom ve products in your inventory. Or consider a case where you need to show the records that have a unique value for a particular eld, such as the books that have an author who hasnt written any other titles. At other times youll want to nd records with non-unique values in a eld, perhaps to help 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 Access provides.

rE

At this point, you are familiar with the most common type of query, the select query. In this topic, youll use select query properties to display only the top or bottom values, select records with unique values, and suppress records that contain duplicate information.

IC

AT

di tio n

LESSON 11
How to Set Select Query Properties
Procedure Reference: Show Top or Bottom Values You can show top or bottom values in a query as follows:

2.

Provide a value for the Top Values property box on the toolbar: Select an option value.

Enter a number or a percent value. (The default value is All.)

Procedure Reference: Show Records that Contain Unique Values To show records that contain unique values in selected elds:
1. 2. 3.

Open a query in Design view. Display the Query Properties dialog box. Set the Unique Values property to Yes.

Procedure Reference: Show Unique Records Only To suppress records that contain duplicate information:
1. 2. 3.

Open a query in Design view.

rE
NO T DU

Display the Query Properties dialog box. Set the Unique Records property to Yes.

to
DO
How You Do It

Showing Top Values


Data Files: Flex.mdb

Setup: Access is open and maximized.

What You Do 1.

In st

Scenario: For an upcoming presentation you need a query that will display the top ve book customers from your database, sorted by total sales.

Set the qselBookSales query to display the customer name and the total number of books sold to each customer.

Lesson 11: Creating Flexible Queries

ru c

a. Open Flex.mdb.

PL

ACTIVITY 11-1

IC

AT
217

di tio n

1.

Open a query in Design view.

LESSON 11
b. Open qselBookSales in Design view.

rE to ru c In st
2.

DO

NO

14records are included in the query results.

DU
f.

e. Click the Totals button to add the Total row to the design grid. From the Total drop-down list in the QuantitySold column, select Sum to add these values in the datasheet.

g. Run the query.

218

PL

Microsoft Ofce Access 2003 Level 1

IC

AT

di tio n

There are four eld lists, so this query can display information from four different tables.

c. From the tblBookSales field list, drag the QuantitySold field to the first Field cell in the design grid.

d. From the tblCustomer field list, drag the CustomerName field to the second Field cell in the design grid.

LESSON 11
3. Display the records for only the top five customers. a. Switch to Design view and click the Top Values drop-down arrow.

b. Select 5.

Make sure you select 5, not 5%.

c. Run the query. 4. What order are the top five records displayed in? a) By total sales, ascending b) By total sales, descending c) Alphabetical d) No particular order 5. Sort the values by the sum of the quantity sold so that the top five in quantity sold are displayed.

rE
NO T

a. Return to Design view.

to
DO

In st

Lesson 11: Creating Flexible Queries

ru c

c. Save the query as qselMyTop5Values d. Close the query.

DU

PL

b. In the QuantitySold field column, choose Descending as the sort value, and then run the query.

IC

AT
219

di tio n

LESSON 11

ACTIVITY 11-2
Showing Records with Unique Values
Flex.mdb

Setup: The Flex database is open and the query objects are shown.

Scenario: 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 arent important; you only want to see one record for each customer and title combination.
What You Do 1. Open qselCustomerNamesAndBooks. How You Do It

rE
NO T

to
2. 3.

There are100total records returned by this query. There are3records with a customer of Allendale Books and a book title of Improving Your Tennis Game.

In st

DO

4.

In the design of the query, remove the TransactionDate field.

ru c

DU
a. Switch to Design view. b. Place the insertion point in the TransactionDate column. c. Choose EditDelete Columns.

220

PL
Microsoft Ofce Access 2003 Level 1

IC

AT

di tio n

Data Files:

a. Open qselCustomerNamesAndBooks. b. Examine the results and look for duplicate combinations of customer and book title.

LESSON 11
5. Set the query to display only unique values. a. Right-click the upper pane of the query design. b. Choose Properties. c. Change the setting for the Unique Values property to Yes.

You can type yes, select Yes from the propertys drop-down list, or select No and type y.

d. Close the Query Properties dialog box.

rE
NO T

6. 7.

There are now81total records displayed by the query.

to
DO

8.

Save and close the query.

Lesson 11: Creating Flexible Queries

In st

ru c

b. Close the query.

DU

a. Save the query as qselMyCustomerNames

PL

There is now1record with a customer of Allendale Books and a book title of Improving Your Tennis Game.

IC

AT
221

e. Run the query.

di tio n

LESSON 11

TOPIC B
Create Parameter Queries
In the queries youve used so far, youve 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. You may nd, in some cases, that it would be valuable if you could select a group of records you choose on the y, by supplying a criteria value for a eld at runtime. For example, say 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 fty states, but a far better approach would be to create one 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

rE
NO T

Example: Single Parameter Query

to In st
DO

ru c
222

Figure 11-1: A parameter query that generates a prompt for the user to enter a State criterion.

DU
Microsoft Ofce Access 2003 Level 1

PL

IC

AT

Denition: A parameter query is a exible query that prompts the user for additional criteria. A message or command is placed in the criteria row beneath the applicable eld, 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 than one criterion, with a separate dialog box displayed for each criterion.

di tio n

LESSON 11
Example: Multiple Parameter Query

The Like Operator and Wildcards

to
DO

Table 11-2: Common Wildcards Character


*

[] [! ] [-]

In st

Matches any single alphabetic character and can appear in the middle of a string.

Like B?nd would match Band, Bind, and Bend, amongst others. Like B[ai]nd would match Band and Bind, but not Bend. Like B[!a]nd would match Bend and Bind, but not Band. LikeB[a-d]nd would match Band, Bbnd, Bcnd, and Bdnd only.

Matches any single character provided in the brackets. Matches any character not provided in brackets.

Matches any single character from within the range provided in brackets.

Lesson 11: Creating Flexible Queries

NO

Matches any number of characters but can only appear at the beginning or the end of the string.

Like S* would match Stone, Smith, and Sullivan.

Description

ru c

Example of Use

DU

You can use wildcard characters in the Criteria cell for select queries or in response to parameter query prompts.

PL

You can use the Like operator with one or more wildcards to display query results from inexact criteria. The Like operator will search for records with a value in a eld that follow the pattern set by the wildcards used. (See Table 11-2.)

IC

AT
223

Figure 11-2: A parameter query that generates prompts for the user to enter City and State criteria.

rE

di tio n

LESSON 11
Character
#

Description
Matches any single numeric character and can appear in the middle of a number.

Example of Use
Like 9#7 would match 907, 917, 927, and so on.

Ampersand and Asterisk You can use the ampersand (&) character along with the asterisk wildcard to link more data to criteria specied by the user as part of a parameter query. For instance, to prompt the user for an area code and to nd 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. 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 prompts (for example, Between [Start Date] and [End Date]).

Procedure Reference: Create and Run a Parameter Query To create and run a parameter query:
1. 2.

rE
NO T

How to Create Parameter Queries

Open a query in design view.

to
DO

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 eld name, although it can include the eld name.

In st

The Prompt Message When you specify a prompt message, it should be brief but meaningful. Access can display up to 50 or so characters in the prompt message. Do not type periods, commas, exclamation points, or square brackets within the outer square brackets. The message cannot be the same as the eld name. The Zoom Box The Zoom dialog box enables you to type and view the entire expression. Use the 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.

ru c
4.

When you are prompted to enter a parameter value, enter the value of the data you want to view and click OK.

DU

3.

Run the parameter query.

224

PL

Microsoft Ofce Access 2003 Level 1

IC

Click in the Criteria cell for the appropriate eld(s), and type the desired expression within square brackets ([ ]).

AT

di tio n

ACTIVITY 11-3
Creating a Single-parameter Query
Flex.mdb Data Files:

LESSON 11

Setup: The Flex database is open in Access and the query objects are displayed.

Scenario: You often use the same query, qselCustomerOrder, but change it so that it is based on a specic customer name. This query uses the Flex database, which contains multiple tables to display the elds CustomerName, BookTitle, and TransactionDate, and sorts the records by customer name and transaction date. Rather than needing multiple queries, a better approach would be to create a parameter query that prompts the user to specify which customer name to use as a criterion.
What You Do 1. Run the existing qselCustomerOrder query and open it in Design view. How You Do It

b. Switch to design view.

to
DO

2.

ru c
Lesson 11: Creating Flexible Queries

b. Run the query.

In st

NO

DU

PL

Modify this query to have it prompt for a customer name each time it runs. Run the query using Book World as the customer name.

a. In the Criteria cell for the CustomerName field, type [Enter a Customer Name]

IC

AT
225

a. Open qselCustomerOrder to see its results.

rE

di tio n

LESSON 11
c. In the Enter Parameter Value dialog box, type Book World

3.

to ru c In st
226

NO

DO

T
d. Save the query as qselMyCustomerOrder e. Close the query.

DU
Microsoft Ofce Access 2003 Level 1

PL

IC

c. Click OK to view the results.

AT

b. In the Enter Parameter Value dialog box, type Jamison Books

Run the query again; this time providing Jamison Books as the customer name.

rE

di tio n
d. Click OK. a. Press Shift+F9 to run the query again.

ACTIVITY 11-4
Creating a Multiple Parameter Query
Flex.mdb Data Files:

LESSON 11

Setup: The Flex database is open with the query objects displayed.

Scenario: While the parameter query you created is an improvement, you decide to add even more exibility. You want a query that will prompt for the rst letter of the customer name and prompt for the date of transaction (between two dates).
What You Do 1. Set the query to prompt the user for the first letter of the customer name. How You Do It

to ru c In st
Lesson 11: Creating Flexible Queries

c. To display the Zoom dialog box, rightclick and choose Zoom.

e. Click OK.

DO

NO

DU

PL

d. Change the parameter criteria to read Like [Enter the first letter of a Customer Name]&*

IC

AT
227

b. Place the insertion point in the Criteria cell of the CustomerName field.

rE

a. Open qselMyCustomerOrder in Design view.

di tio n

LESSON 11
2. Set the query to prompt the user for two transaction dates that the resulting records must be between. a. Click in the Criteria cell of the TransactionDate field. b. Display the Zoom dialog box. c. Type Between [Enter a Start Date] and [Enter an End Date] d. Click OK.

3.

Run the query and display records for customers whose names begin with the letter b who had transactions dated between 4/1/2001 and 6/30/2001.

rE to ru c In st
228

c. To enter a start date, type 4/1/2001 and click OK.

NO

DO

T
d. To enter an end date, type 6/30/2001 and click OK.

DU
Microsoft Ofce Access 2003 Level 1

PL

IC

AT

Because the wildcard characters are added to the parameter expression, you need to enter only the rst letter of the desired customer name.

di tio n
a. Run the query. b. Type b and click OK.

LESSON 11
4. How many records satisfy the three criteria you set with parameters? a) 10 b) 12 c) 15 d) 20 5. Save the query as qselMyParameters and close the query.

a. Save the query as qselMyParameters b. Close the query.

TOPIC C
Create Action Queries

to
DO

Lesson 11: Creating Flexible Queries

In st

Example: Update Query An Update query changes specied values in a table for all the records or for those records that match specied criteria.
It is generally a good idea to make a backup of your data before using update and delete action queries.

NO

Denition: An Action query is a query that modies data in the underlying table or tables. It performs a data operation, instead of selecting data. An action query can be an efficient tool for making data modication in bulk.

ru c

DU

Action Queries

PL

Consider the case where a set of records in your products table needs to be altered to reect 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. 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 time by writing a query that locates the desired records and automatically deletes them.

IC

AT

E
229

So far youve 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, youll see how to use queries to update data, delete records, or add records from one table to another.

rE

di tio n

LESSON 11

to ru c In st
230

Figure 11-4: An Append query that copies matching records from tblProductsExternal to tblProducts.
You can use an append query even if some of the elds in the rst table are not contained in the second table, because Access appends values where the elds match and ignores the other elds.

DO

NO

T
Microsoft Ofce Access 2003 Level 1

DU

PL

IC

AT

Example: Append Query An Append query copies data from specic elds or complete records from one table to another.

rE

Figure 11-3: An Update query that increases prices by five percent.

di tio n

LESSON 11
Example: Delete Query A Delete query removes records from a table that match selected criteria.

rE
NO T

to
DO

How to Create Action Queries

Lesson 11: Creating Flexible Queries

In st

Procedure Reference: Create an Action Query to Update Records To create an action query that will update selected records: Run a select query to determine that it will affect the desired records. In Design view, click the drop-down arrow next to the Query Type button and select Update Query. If necessary, modify the query so that the proper elds will be updated with the desired new data. Click the Run button to run the query.

1. 2. 3. 4.

ru c

Action Query Icons Each action query has a different icon to alert you that they will modify data. Simply opening an action query causes the query to be run, modifying the table data. Be careful when working with action queries, always opening them in Design view to see what they will do rst!

DU

PL

Make Table Query A fourth kind of action query is quite different from the others. Instead of modifying the data in an existing table, a Make Table query creates a new table from the results of the query.

IC

AT
231

Figure 11-5: A Delete query that deletes matching records in a table.

di tio n

LESSON 11
To run an action query, use the Run button rather than the View button. Use View to see a list of all records that will be updated, but not their new values. Using Run will update the values.

5. 6.

When a dialog box appears indicating the number of records that will be affected, click Yes. If desired, save this query.

Add All Fields to the Query To add all of the elds from a table to the query design grid, drag the asterisk from the eld list to the eld row of the query design grid. This procedure ensures that if you add or delete elds from a table, the query using that table still includes all of the elds. When you use the asterisk to add all the elds to the query design grid, and you want to sort values or specify criteria, you must rst add the individual elds to the eld row; and then you can dene specications for those elds. To prevent the elds from appearing twice in the query results, uncheck the Show check box for each.

Updating Records with a Query


Data Files: Flex.mdb

rE
NO T DU
How You Do It

ACTIVITY 11-5

to
DO

What You Do 1.

ru c

Scenario: Youve just gotten word that all projects beginning with 31 or 34 will have a price increase of ve percent. Youve 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.

In st

As a precaution, create a copy of tblBookProject before the data is modified.

a. In the database window, display the table objects. b. Select the table tblBookProject. c. Click the Copy button d. Click the Paste button . .

232

PL

Setup: The Flex database is open and the query objects are displayed.

Microsoft Ofce Access 2003 Level 1

IC

AT

di tio n

LESSON 11
e. In the Table Name text box, type tblMyBackupBookProject

f.

Click OK. The copied table has been added to the database.

g. Open your original table, tblBookProject.

True False 3. View the design of the provided select query called qselRetailPrice. Run the query to see its results.
Action queries are very fast and their results are permanent, so youll want to test an action query rst, as a select query, to see how your data will change before you actually make the change.

rE
NO T

2.

True or False? For books with part numbers that begin with 31 or 34, the prices range from $25.95 to $45.95.

a. Close tblBookProject.

to
DO

b. In the database window, display the query objects. c. Display qselRetailPrice in Design view.

In st

4.

There are12records that have a part number that begins with either 31 or 34.

Lesson 11: Creating Flexible Queries

ru c

d. Verify that the criteria for PartNumber is Like 31* Or Like 34* and that there is a calculated field named NewBookPrice, which is defined to calculate a five percent increase in the book price. Run the query.

DU

PL

IC

AT
233

di tio n

LESSON 11
5. Running the select query does not change the prices in the table. Convert this select query to an update query that will change the data. a. Change to Design view and click the drop-down arrow next to the Query Type button . b. Select Update Query.

rE
NO T

6.

to ru c In st
7. a) $25.95 to $45.95 c) $30 to $50 b) $27.25 to $48.25

DO

What is the new range of prices for books with part numbers beginning with 31 or 34?

DU

c. Save the query as qupdMyPriceIncrease


The object prex qupd indicates that it is now an update query.

d. Close the query. e. Open tblBookProject.

234

PL
Microsoft Ofce Access 2003 Level 1

IC

b. A dialog box indicates the number of records that will be changed. Click Yes.

AT

Run the update query, save the query, and view the results.

a. Click the Run button

di tio n
.

c. Verify that the title of the query has changed to Update Query and that an Update To row was added to the grid. d. In the BookPrice column, in the Update To cell, type [BookPrice]*1.05 and press Enter.

LESSON 11
8. What would happen to the values in the BookPrice field if you ran the query again? a) Nothing, they would remain the same because they have already been increased by 5 percent. b) The values in the BookPrice field in the underlying table would again be increased by 5 percent.

d) An error would result. 9. Verify the icon used to denote an update query.

a. Close tblBookProject.

b. In the Flex database window, verify that the icon for qupdMyPriceIncrease is different than that used for select queries by displaying the query objects.

To create an action query that will append records:


1. 2. 3. 4. 5. 6. 7.

to
DO

When a dialog box appears indicating the number of records that will be appended, click Yes.

Lesson 11: Creating Flexible Queries

In st

NO

If desired, save this query.

ru c

DU

Click the Run button to run the query.

PL

If necessary, modify the query further so that the proper elds will be appended with the desired new data.

IC

In the Append dialog box, select the table you are appending records to. Click OK.

AT
235

In Design view, click the drop-down arrow next to the Query Type button and select Append Query.

If desired, run a select query to determine the records that will be appended.

rE

Procedure Reference: Create an Action Query to Append Records

di tio n

c) The previous prices would be reinstated: the 5 percent increase in price would be revoked.

LESSON 11

ACTIVITY 11-6
Appending Records to a Table with a Query
Flex.mdb

Setup: The Flex database is open and the database window displays the query objects.

Scenario: The tblNewProjects table contains information regarding new book projects. The table structure is identical to tblBookProject. In both tables, the rst 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 projects are now complete, and you need to add those records from tblNewProjects to tblBookProject.
What You Do 1. Review the contents of tblNewProjects.

rE
NO DO T

to

ru c In st
236

DU

b. Select Query. c. Verify that Design View is selected. Click OK. d. From the tblNewProjects field list, drag the asterisk to the first Field cell in the query design grid.

PL

2.

Create a select query that shows all fields for all records from tblNewProjects.

a. With tblNewProjects selected in the database window, display the New Object drop-down list .

Microsoft Ofce Access 2003 Level 1

IC

b. Verify that the table has seven records, four with a part number beginning with 41 and three with a part number beginning with 43. Close the table.

AT

di tio n
How You Do It a. Open tblNewProjects.

Data Files:

LESSON 11
3. Use criterion for the PartNumber field to find records with part numbers that begin with 41. Avoid displaying the PartNumber field twice in the query datasheet. a. In the second Field cell, display the dropdown list and select PartNumber. b. In the Criteria cell for the PartNumber field, type 41* and press Enter.
The Like operator and quotation marks are added automatically.

c. The PartNumber field is set to be displayed as part of the entire table (based on the first Field cell). Above the criteria for the PartNumber column, uncheck the Show check box.

rE
NO T DU

d. Run the query. 4. 5. 4records are displayed by this query. Change the select query to an append query that will add this data to tblBookProject.

to
DO

a. Change to Design view and display the Query Type drop-down list. b. Select Append Query.

In st

Lesson 11: Creating Flexible Queries

ru c

c. In the Append dialog box, from the Table Name drop-down list, select tblBookProject. Click OK.

d. Verify that the query design window title is now Append Query and that the grid now includes an Append To row.

PL

IC

AT
237

di tio n

LESSON 11
e. In the Append To cell for the PartNumber field, delete PartNumber, but do not delete the Like 41* criterion below it.

6.

Run the append query, save it, and view the results.
Access does not automatically refresh the view of the table that has records added to it.

rE
NO T

to ru c In st
7. a) 26 b) 29 d) 33 c) 30

DO

The tblBookProject table had 26 records before the append query was run. How many records does it have now?

DU

c. The object prefix qapp is used to indicate an append query. Save the query as qappMyAppend
Append queries are often not used again; in that case, once you have conrmed the results, you can delete the query.

d. Open tblBookProject.

238

PL

Microsoft Ofce Access 2003 Level 1

IC

AT

di tio n
a. Click the Run button.

The PartNumber eld was included in the second Field cell of the query design grid to supply a criterion for the query. It was also included when the asterisk was dragged to the rst Field cell.

b. The warning dialog box indicates the number of records that will be appended. Click Yes.

LESSON 11
8. Verify that the contents of tblNewProjects are unchanged. a. Close tblBookProject. b. Open tblNewProjects. c. Verify that running the append query did not delete any records. Close tblNewProjects.

Procedure Reference: Create an Action Query to Delete Records To create an action query that will delete records:
1. 2. 3. 4. 5. 6.

If desired, run a select query to determine the records that will be deleted.

In Design view, click the drop-down arrow next to the Query Type button and select Delete Query. If necessary, modify the query further so that the proper elds will be deleted with the desired new data.

When a dialog box appears indicating the number of records that will be deleted, click Yes.

rE
NO T

Click the Run button to run the query.

to
DO

Deleting Records with a Query


Flex.mdb

Setup: The query qappMyAppend is open in Design view.

Lesson 11: Creating Flexible Queries

In st

Scenario: Projects in category 41 are no longer considered new. They are complete and have been added to tblBookProject. You now want to remove these records from tblNewProjects.

ru c

DU

Data Files:

PL

IC

ACTIVITY 11-7

AT
239

If desired, save this query.

di tio n

LESSON 11
What You Do 1. Change qappMyAppend to a delete query and preview the records that will be deleted. How You Do It a. Display the Query Type drop-down list. b. Select Delete Query.

rE
T NO

2.

to
DO

ru c In st
240

DU
The deletion is permanent; you cannot retrieve deleted records by using the Undo feature.

b. Click Yes to delete the records.

PL
Microsoft Ofce Access 2003 Level 1

IC

Run the query and delete the four records.

a. Change to Design view and click the Run button.

AT

di tio n

The Delete Query choice is on the extended menu.

c. In the design grid, verify that the Delete row indicates that only records with a PartNumber value that starts with 41 will be deleted from tblNewProjects.

d. To verify that only the four records where part number begins with 41 will be deleted, click the View button.

LESSON 11
3. Save the query and verify that the records were deleted. a. An object prefix of qdel is used to indicate a delete query. Save the query as qdelMyNewProjects b. Close the query. c. To verify that the deletion occurred and that three records remain, open tblNewProjects. d. Close tblNewProjects.

e. Close the Flex database.

Lesson 11 Follow-up

to
DO

1.

Considering your current or planned Access projects, can you foresee needing to create parameter queries? In what contexts and why? Answers will vary.

2.

Answers will vary.

ru c

Lesson 11: Creating Flexible Queries

In st

NO

DU

Considering your current or planned Access projects, can you foresee needing to create action queries that add, update, or delete data? In what contexts and why?

PL

IC

AT

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 exible parameter query you can allow for the dynamic entry of one or multiple criteria. By using another type of advanced 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 exible and powerful ways.

rE

E
241

di tio n

NOTES

rE to ru c In st
242

DO

NO

T
Microsoft Ofce Access 2003 Level 1

DU

PL

IC

AT

di tio n

LESSON 12

LESSON 12

Improving Your Forms

In this lesson, you will enhance the appearance, data entry, and data access capabilities of your forms.

Restrict data entry in forms by adding Combo Box and Option Group controls. Add a subform to a form.

to ru c In st
Lesson 12: Improving Your Forms

DO

NO

DU

PL

IC

AT
243

Add a command button to a form.

rE

You will: Add text and graphic elements including lines, rectangles, and pictures to a form.

di tio n

Lesson Time 40 minutes

LESSON 12
Introduction
If youre lucky, you might never need to customize a form. The forms you create with AutoForm or the Form Wizard might work perfectly for you, but chances are youll end up in the Form Design view window to improve your forms at some point. This lesson will provide 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 to more efficiently add and update records.

TOPIC A

Enhance the Appearance of a Form

to ru c In st
244

Figure 12-1: A form with a heading, graphic, and shaded rectangle grouping box.

DO

NO

T
Microsoft Ofce Access 2003 Level 1

DU

PL

IC

AT

Although unnecessary distraction should be avoided, an entirely plain form might not be the 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.

rE

Youve 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 Design view already, but in this topic, you will add text and graphics to really improve their appearance.

di tio n

LESSON 12
Form Design View
The Form Design view window (see Figure 12-2) is the design environment for making changes to a forms design. It provides numerous tools to help you improve the design of your forms and increase the efficiency of data entry.
There are additional toolbars and features of Form Design view not discussed in this course. These are the most commonly used.

Tool
Form Design toolbar

Description

Provides buttons for common tasks like View, Save, and Print. It also has special buttons to open Design tools like the Toolbox and Field list. Has buttons for typical formatting jobs, like changing font sizes and colors. Has buttons for placing labels, elds, combo boxes, command buttons, and other special-purpose objects in a form. This is where you typically go to nd controls to add to your form.

Formatting toolbar Toolbox

Control Wizards toggle button

to
DO

ru c
Lesson 12: Improving Your Forms

In st

NO

DU

PL

IC

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.

AT
245

Properties dialog box

Each object in a Form Design view window has its own properties dialog box with tabs that list the properties you can change for the object.

rE

Field list

A handy way to reference elds in the Design view window. Shows elds from the table or query that is the source of data for the form you are working on.

di tio n

LESSON 12

to
Name

Table 12-1: Buttons on the Formatting Toolbar that Display a Palette Button Description

ru c In st

246

Fill/Back Color Font/Fore Color

Line/Border Color Line/Border Width Special Effect

NO

T
Changes the color of a controls border. Changes the thickness of a controls border. Controls whether a control or section appears at, raised, sunken, etched, shadowed, or chiseled.

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 dont need to use the drop-down palette to select the same color.
Microsoft Ofce Access 2003 Level 1

DO

DU

Changes the background color of a control or section. Changes the color of text in a control.

PL

IC

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.

AT

Figure 12-2: The Form Design view window.

rE

di tio n

LESSON 12
To avoid clicking the Palette toolbar button each time you need to display a given palette, you can drag that palette away from the button to keep it displayed while you design the form or report.

Section Selector 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 specic section of the form or report, use the section selectora 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.
You can also display the properties for that section automatically by double-clicking its section selector box.

to
DO

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.

How to Enhance the Appearance of a Form


Procedure Reference: Work with Lines, Boxes, and Labels To work with lines, boxes, and labels, as you design forms with a variety of features:
1. 2. 3. 4.

ru c

From the toolbox, select the tool you would like to work with. Click in the Design view window where you want the object (line, box, and so on) to start. Depending on the object, drag to the end or the other opposite corner and release the mouse button. If desired, apply special effects to the control.

Procedure Reference: Add an Image To add an image to a form in Design view:


1.

Lesson 12: Improving Your Forms

In st

From the toolbox, choose the Image tool.

NO

DU

PL

IC

Grouped Controls 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 individual control as youre arranging controls or assigning properties. You can group text boxes and other controls on a form or report by using the Group command on the Format 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.

rE

AT

E
247

di tio n

Unbound Controls An unbound control is not bound or connected to a eld 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 le, separate from any tables.

LESSON 12
2. 3. 4. 5. 6.

Click in the form where you want the image displayed. Browse to the desired les location, select it, and click OK. Double-click the image to display its properties. Alter any properties as needed and then close the properties dialog box. If necessary, resize and relocate the image on the form.

ACTIVITY 12-1
Data Files: Improve.mdb

Adding Text and Graphic Elements

Setup: Access is open.

to
DO

Add a label, Book Source Sales, and an image to the top of the form.
How You Do It

What You Do 1.

ru c

In st

NO

In the Improve database, open frmSalesAndProfit in Design view. This form is based on a multipletable query.

DU

a. Open the Improve database. Maximize the database. b. Open frmSalesAndProfit, and then switch to Design view.

248

PL
Microsoft Ofce Access 2003 Level 1

IC

Surround several of the remaining controls with a rectangle to enhance the visual design of a form.

AT

Scenario: Youve started a form, frmSalesAndProt, that could be used for order entry at the Book Source. Youve identied some basic improvements you could make to polish up the form. You will: Group together four controls so that they are easier to work with.

rE

di tio n

LESSON 12
2. Create a group of the first set of three controls. Change the font of the entire group of controls. Then ungroup the controls. a. Hold down the Shift key and select the OrderID, CustomerID, and TransactionDate label controls.

b. Choose FormatGroup.

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.

d. Click the OrderID label control to select the group.

rE to ru c
f.

In st

h. Click Undo. i. With the group still selected, select a red font color .
If the Formatting toolbar is not displayed, choose ViewToolbarsFormatting (Form/ Report).

Lesson 12: Improving Your Forms

DO

g. Place the mouse pointer on the group boundary. When the mouse pointer changes to a hand, drag to the right. This moves the group of controls as a single unit.

NO

Click Undo

DU
.

e. You can still work with each control individually. Click the OrderID label control again. Press Delete. The group still exists without this deleted control.

PL

IC

Any of the controls could be clicked to select the group.

AT
249

di tio n

LESSON 12
j. Choose FormatUngroup. When you ungroup controls, the group rectangle is deleted. 3. Draw a rectangle around the QuantitySold, Retail Cost, and Wholesale Cost labels and text boxes. a. Make sure you can see the QuantitySold, Retail Cost, and Wholesale Cost controls. If necessary, resize the form window. b. From the Toolbox, choose the Rectangle . tool

ru c
5.

NO

In st

DO

Make room to add a label and picture control to the Form Header section.

DU

You might want to have students examine the properties for the rectangle. The Special Effect property is Shadowed. The Border Color property is a number that corresponds to the color you selected from the palette.

to

b. Select Special Effect: Shadowed. The rectangle control changes its appearance and remains selected. c. On the Formatting toolbar, next to the Line/Border Color button , click the drop-down arrow. d. From the palette, select a red color.
You may choose a different color if you wish.

a. The Form Header is currently hidden. To view it, choose ViewForm Header/ Footer.

250

PL
Microsoft Ofce Access 2003 Level 1

IC

AT

4.

Format the rectangle with color and a shadowed effect.

rE

di tio n

c. Click above and to the left of the QuantitySold label. Drag the mouse pointer to surround the three controls that display calculated data and release.

a. On the Formatting toolbar, next to the Special Effect button, click the dropdown arrow to display the special effects options for the rectangle control.

LESSON 12
b. Double-click the Form Header section selector to display the properties for the Form Header section.

c. If necessary, select the Format tab.

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.

d. Change the Height setting to 2

6.

to ru c In st
7. Insert the Book file image and size it so that it is smaller.

c. Type Book Source Sales and press Enter.

d. From the Font Size drop-down list, select 20.

a. Choose the Image tool

DO

e. Choose FormatSizeTo Fit. .

Lesson 12: Improving Your Forms

NO

DU

PL

IC

AT

b. Click the mouse pointer in the upperleft corner of the Form Header section.

E
251

In the upper-left corner of the Form Header section, create a label that reads Book Source Sales.

a. Choose the Label tool

rE

e. Close the properties dialog box. .

di tio n

LESSON 12
b. In the Form Header section, click near the 3 horizontal mark at the top of the section.

If students encounter problems, make sure all le types are displayed.

rE
f.

If necessary, select the Format tab.

to ru c In st
252

NO

T
j. Drag the top border of the Detail section up under the graphic.

DO

DU

i.

Place the mouse pointer on the lowerright corner of the image until it turns into a double-ended arrow and drag up and to the left to make the graphic smaller.

PL

h. Close the properties dialog box.

Microsoft Ofce Access 2003 Level 1

IC

g. Set the Size Mode property to Stretch.

AT

di tio n
d. Click OK.

c. The contents of the My Documents folder are displayed. From the list of files, select Books.

You can change the objects position by dragging it or by using Ctrl+arrow keys.

e. Double-click the image to display its properties.

LESSON 12
8. Hide the Form Footer section. a. Double-click the Form Footer section selector to display the properties for the Form Footer section. b. Change the Visible property to No. c. Close the properties dialog box. 9. Save the modified form as frmMySalesAndProfit.

a. Save the form as frmMySalesAndProfit b. Switch to Form view.

rE to ru c
DO NO
Lesson 12: Improving Your Forms

In some cases, users of a form need the freedom to enter any value they desire in a text box (for example, a name eld). 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 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.

In st

Youve seen how to improve the appearance of your forms by adding text and graphic elements. But even more important than appearance is how well your forms can produce accurate data in your tables. In this topic, you will use special kinds of controls to restrict data entry.

Restrict Data Entry in Forms

DU

TOPIC B

PL

IC

AT
253

di tio n

LESSON 12
Control Wizards
When adding certain types of controls to a form, you can use a wizard to create the control. Collectively, this group of wizards is referred to as Control Wizards. To toggle Control Wizards on and off, click the Control Wizards button in the Toolbox.
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.

Combo Box Control

Denition: 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 eld. A combo box is typically accompanied by a label control.

rE to
DO NO T DU

Example:

In st

List Box Control

Denition: 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.

ru c
254

Figure 12-3: A combo box that can be used to assign a product category for each product record.

PL
Microsoft Ofce Access 2003 Level 1

IC

AT

di tio n

LESSON 12
Example:

Option Group Control

to
DO

Lesson 12: Improving Your Forms

In st

NO

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.

ru c

DU

Denition: An option box group is a type of form control that consists of a group frame containing 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 possible within the group. To simplify data entry, one option can be set as the default. A label for the option group is typically provided.

PL

IC

AT
255

Figure 12-4: A list box that can be used to assign a product category for each product record.

rE

di tio n

LESSON 12
Example:

Figure 12-5: An option group can be used to restrict the possible values for the Reason field in a table for employee time off.

How to Restrict Data Entry in Forms

to
DO

2. 3. 4. 5. 6. 7. 8. 9.

In the toolbox, click the Combo Box (or List Box) button. Click in the form to place the control in the desired location.

ru c In st
click Next. click Finish.
256

Choose the table or query that will provide the values. Click Next.

If desired, uncheck Hide Key Column. If necessary, double-click column borders for best t. Click Next. that will be stored in the table. Click Next.

10. Choose a eld to uniquely identify the row in the control and to provide the value 11. Choose whether or not to store the values in the eld and specify a eld, and then 12. Accept the suggested label name or enter a name for the Combo Box and then

NO

Set any desired sort criteria for the items in the control. Click Next.

Choose the eld(s) to display in the control. Click Next.

DU

Select the I Want The Combo Box To Look Up The Values In A Table Or Query option. Click Next.

PL

Microsoft Ofce Access 2003 Level 1

IC

1.

If necessary, activate the Control Wizards button.

AT

To add a Combo Box or List Box control based on a table or query to a form in Design view:

Procedure Reference: Add a Combo Box or List Box Control

rE

di tio n

ACTIVITY 12-2
Adding a Combo Box Control
Improve.mdb Data Files:

LESSON 12

Setup: The frmMySalesAndProt form is open in Form view.

Scenario: You continue to work with frmMySalesAndProt and decide to add some choices to simplify data entry. To begin, youll add a Combo Box that displays the part numbers and book titles for each record, and records the part number eld.
What You Do 1. Delete the existing PartNumber text box and label controls. How You Do It

to
DO

ru c
Lesson 12: Improving Your Forms

b. Choose the Combo Box tool

DU

PL

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. .

In st

NO

c. On the form, click below the TransactionDate controls to start the Combo Box Wizard.

IC

AT
257

b. Delete the PartNumber text box and label controls.

rE

a. Switch to Design view.

di tio n

LESSON 12
3. Using the wizard, select two fields in tblBookProject that will be displayed as columns in the combo box: PartNumber and BookTitle. a. Verify that the I Want The Combo Box To Look Up The Values In A Table Or Query option is selected. Click Next.

rE to ru c In st
258

DO

NO

T
Microsoft Ofce Access 2003 Level 1

DU

PL

e. Move the BookTitle field from the Available Fields list box to the Selected Fields list box. Click Next.

IC

AT

d. With PartNumber selected in the Available Fields list box, click the right arrow button .

di tio n

b. In the lower part of the dialog box, verify that the selected View option is Tables.

c. In the upper part of the dialog box, from the list of tables select tblBookProject. Click Next.

LESSON 12
4. Sort the items in the Combo Box by part number. a. In the first drop-down menu, choose PartNumber. b. Verify that the corresponding button is set to Ascending. Click Next.

rE to ru c In st
Lesson 12: Improving Your Forms

DO

NO

DU

PL

IC

AT
259

di tio n

LESSON 12
5. Ensure that both columns will display in the combo box and adjust the column widths. a. Uncheck Hide Key Column.
Although the wizard recommends that you hide the key column, for this example, you want to display it in the combo box with the book title.

rE to ru c
6. Specify that Access should store the combo box value in the PartNumber field and complete the wizard.

In st

DO

NO

DU

a. Select Store That Value In This Field. b. From the drop-down list, select PartNumber.

c. Click Next.

260

PL

This eld uniquely identies the row in the combo box, and it contains the value you want to store or use in the database.

Microsoft Ofce Access 2003 Level 1

IC

d. In the Available Fields list box, verify that PartNumber is selected. Click Next.

AT

c. Double-click the right edge of the PartNumber column. Click Next.

di tio n

b. To make the best fit for the column, double-click the right edge of the BookTitle column.

LESSON 12
d. Accept the suggested label and Click Finish.

7.

Display and scroll through the values listed in the new combo box.

a. Change to Form view.

b. Click the combo box drop-down arrow.

rE
NO T

c. Close the combo box list.

to In st
Lesson 12: Improving Your Forms

DO

ru c

DU

PL

IC

d. Save the modified form.

AT
261

di tio n

You might want to have students display the properties for the Combo Box control. Of particular interest might be the Control Source, Row Source Type, and Row Source properties. The Row Source Type property shows that the rows contain values from the PartNumber and BookTitle elds in tblBookProject.

LESSON 12
8. To see the difference, temporarily convert the combo box to a list box. a. In Design view, right-click the Combo Box control. b. Choose Change ToList Box. c. In Form view, scroll through the list box.

rE to
DO
Procedure Reference: Create an Option Group

If you are asked to save changes again, click No.

ru c
1. 2. 3. 4.

If necessary, activate the Control Wizards button. In the Toolbox, click the Option Group button.

Enter the labels for the options you want to show on the form and click Next.
A label is the text that describes the purpose of each option.

In st

5.

From the drop-down list, select a default value for the eld and click Next.
A default choice is not required for option buttons, but Windows users have come to expect that with this type of control, a default option will already be selected.

6. 7.

Accept the default values that will be used for each option or change them to suit your needs and click Next. Specify whether the value is saved for later use or stored in a selected eld and click Next.

NO

Click in the form where you want the option group created.

DU

To add an option group to a form in Design view:

262

PL
Microsoft Ofce Access 2003 Level 1

IC

AT

di tio n
e. Close frmMySalesAndProfit.

d. Change to Design view and click Undo.


To use this List Box control effectively, additional design changes would be needed so that it does not overlap the Text Box controls below it.

LESSON 12
8.

Choose a control type and select a style and click Next.


Option Buttons is the default control type. Etched is the default style.

9.

Enter a caption to be displayed above the option group and click Finish.

ACTIVITY 12-3
Data Files: Improve.mdb

Adding an Option Box Group to a Form

Setup: You must have installed the Additional Wizard set when setting up this course. Otherwise, you will be prompted at this point for a CD.

rE
NO T

What You Do 1. Add an option group to frmNewCustomer by starting the wizard.

How You Do It

to
DO

Lesson 12: Improving Your Forms

In st

ru c

c. Verify that the Control Wizards tool is selected. d. In the Toolbox, choose the Option Group tool .

DU

PL

b. If necessary, enlarge the Design view window so that all the fields can be seen.

IC

a. Open frmNewCustomer in Design view.

AT
263

Scenario: In addition to an Order Entry form, you also have a New Customer Information form. On this form, youll also include the payment method. You decide to add an option group as an interface for adding the payment method number.

di tio n

LESSON 12
e. Below the Phone and Fax labels, click the form to start the Option Group Wizard.

2.

Create the four options that will be displayed as choices: Cash, C.O.D., Company Charge, and Credit Card as the default choice.

rE to ru c In st
3. Store the value in the Payment field, use the Sunken style with option buttons, and add a label.

DO

NO

DU

c. Click Next. d. Verify that the Yes, The Default Choice Is option is selected. Display the dropdown list of labels, and select Credit Card. Click Next.

e. To accept the default values, click Next. a. Select the option Store The Value In This Field.

264

PL
Microsoft Ofce Access 2003 Level 1

IC

AT

di tio n

a. In the first Label Names text box, enter Cash To move to the next label, press Tab.

b. In the next three text boxes, enter C.O. D., Company Charge, and Credit Card

LESSON 12
b. From the drop-down list, select Payment. Click Next.

c. Select Sunken as the style. Click Next.

You can select each of the styles and control types and view the examples.

d. Type Payment Method

e. Click the Finish button. The option group is created on the form design.

rE
NO T

to
DO

Lesson 12: Improving Your Forms

In st

ru c

c. Click the New Record button. d. Verify that the default value for the option group is Credit Card.

DU

b. Page through the records. Different option buttons are selected for each record, depending on which payment method the customer has chosen.

PL

4.

Page through the records to see the effect of the option group.

a. Change to Form view.

IC

f.

Save the form as frmMyNewCustomer

AT
265

di tio n

LESSON 12

TOPIC C
Add Command Buttons
At this point, your forms look good and produce accurate data. Now youll 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 others who use your form commonly dolike 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 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.

Command Buttons

rE
NO T

Denition: A Command button is a control that carries out a pre-dened function. The appearance 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 form operations such as closing the form or printing the form, record operations such as deleting a record, and many more. Example:

to In st
1.

Figure 12-6: Three common command buttons: Close Form, Print Form, and Delete Record.

How to Add Command Buttons


Procedure Reference: Create Command Buttons Using the Wizard To use the Command Button Wizard to create command buttons: In Design view, open the form you want to add buttons to.

DO

ru c
266

DU
Microsoft Ofce Access 2003 Level 1

PL

IC

AT

di tio n

LESSON 12
2. 3. 4. 5. 6. 7. 8. 9.

If necessary, make room for the buttons on the form. If necessary, open the Toolbox and activate the Control Wizards button. In the toolbox, choose the Command Button tool. In the Form Design view window, click where you want the command button to appear. Click one of the categories. Select an action. Click Next.

The remaining steps of the wizard depend on the type of action you chose. Click Next. Enter a name for the button and click Finish.

ACTIVITY 12-4
Adding a Command Button to a Form
Data Files: Improve.mdb

rE
NO T

to
DO

Lesson 12: Improving Your Forms

In st

ru c

DU

PL

Scenario: Once an order is taken, the form can be closed. This is a fairly common routine: open the form to record a transaction, and then close the form. Youve decided that it would be nice to have a button to do that, so you will add a command button to close the form.

IC

AT
267

Setup: The frmMyNewCustomer form is open in Form view.

di tio n

LESSON 12
What You Do 1. Add a command button to the bottom of the form that will close the form. How You Do It a. Change to Design view and choose the Command Button tool from the Toolbox.

rE to ru c In st
2. Test the Close Form button.

NO

T
f.

DO

DU
e. Select Text. Click Next. Type Close Form and click Finish. a. Save the form. b. To close the form, switch to Form view and click the Close Form command button .
If you are asked to save the form again, click Yes.

268

PL
Microsoft Ofce Access 2003 Level 1

IC

AT

di tio n

b. To start the Command Button Wizard, click the mouse button in the lower-left corner of the form.

c. The Command Button Wizard displays. From the Categories list box, select Form Operations. d. From the Actions list box, select Close Form. Click Next.

TOPIC D
Create a Subform
Youve 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 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 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.

LESSON 12

Subforms

rE
NO T

Although the subform is displayed as part of another form, it is a separate form, and its design is independent of the main form.

to
DO

Example:

Lesson 12: Improving Your Forms

In st

Figure 12-7: A main form with Orders data that contains a subform with related Order Details data.

ru c

DU

PL

IC

AT

E
269

Denition: A subform is a form that is displayed as an object within another form called a main 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 represent 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 elds in the main form and the rows in the subform.

di tio n

LESSON 12
How to Create a Subform
Procedure Reference: Create a Subform Using the Wizard The Subform/Subreport Wizard can guide you through the steps of creating a subform when a main form exists. To create a subform by using the Subform/Subreport Wizard:
1. 2. 3.

From the Toolbox, choose the Subform/Subreport tool.

Click in the desired location on the form on which you would like to place the subform. Select your data source for the subform.

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 contains the elds you would like to use and add them to the Selected Fields list box.
You can select elds from more than one table or query.

5. 6.

Select one of the links that Access suggests, or create one of your own. Click Next.

to
DO

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.

In st

NO

Using a Form that has a Subform In Form view, you can switch between a main form and a subform by using the Tab key or the mouse. When you use a form that has a subform to enter new records, 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 also saved automatically as you add it to the subform.

ru c

DU

270

PL

Microsoft Ofce Access 2003 Level 1

IC

Name your form and click Finish.

AT

If you select the forms option, select the form that you want from the list box.

rE

di tio n

ACTIVITY 12-5
Adding a Subform Control to an Access Form
Improve.mdb Data Files:

LESSON 12

Setup: The Improve database is open in Access.

Scenario: 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.
What You Do 1. Start the Subform/Subreport Wizard to add a subform to frmCustomersMain. How You Do It

a. Open frmCustomersMain.

rE
NO T

to In st
Lesson 12: Improving Your Forms

DO

ru c

b. Switch to Design view and verify that the Control Wizards button is selected. c. Choose the Subform/Subreport tool . d. Click in the form below the existing controls to launch the wizard.

DU

PL

IC

AT
271

di tio n

LESSON 12
2. Complete the wizard such that the data source is tblBookSales and all the fields except the CustomerID field are included. a. The Subform Wizard is displayed. Verify that Use Existing Tables And Queries is selected. Click Next. b. To add fields from tblBookSales, display the Tables/Queries drop-down list and select Table: tblBookSales.

rE
f.

In the Subform text box, type fsubMyBookSales

to ru c In st
3.

g. Click Finish.

DO

NO

T
You may need to resize the form window to see the entire Subform control as shown.

With the Subform control selected, change the Width property to 4. Save your work.

DU
a. If necessary, using the Object drop-down menu on the Formatting toolbar, select fsubMyBookSales.

272

PL
Microsoft Ofce Access 2003 Level 1

IC

AT

di tio n
d. Click Next.

c. Add all the fields to the Selected Fields list box except CustomerID.

e. To accept the wizards suggestion regarding the linking of the forms, click Next.

LESSON 12
b. On the Form Design toolbar, click the Properties button .

c. In the Width property box, enter 4

to ru c In st
Lesson 12: Improving Your Forms

DO

NO

DU

PL

IC

AT
273

e. Save the main form as frmMyCustomersMain

rE

d. Close the properties dialog box.

di tio n

LESSON 12
4. View the form that now includes a subform in Form view. a. Switch to Form view. b. To alter the width of the first column, double-click the field border between OrderID and TransactionDate.

rE
NO T

to
DO

ru c

In st

Lesson 12 Follow-up

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 make users more efficient, and these gains can be very largeas 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? Answers will vary.

DU

6.

Close the form and the database window.

a. Close the frmCustomersMain form. b. Close the Improve database window.

274

PL

At this point, you may want to have students add a record by using a form that has a subform. Students should verify that the transaction they post in the subform is automatically saved to the underlying table.

5.

True False

Microsoft Ofce Access 2003 Level 1

IC

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.

AT

di tio n

c. To extend the widths of the other three columns, do the same on the field borders between TransactionDate and PartNumber, PartNumber and QuantitySold, and at the right edge of QuantitySold.

LESSON 12
2. Do you expect to make more aesthetic improvements to your forms or more improvements to enhance data entry efficiency? Or both? Answers will vary.

rE to ru c In st
Lesson 12: Improving Your Forms

DO

NO

DU

PL

IC

AT
275

di tio n

NOTES

rE to ru c In st
276

DO

NO

T
Microsoft Ofce Access 2003 Level 1

DU

PL

IC

AT

di tio n

LESSON 13

LESSON 13

Customizing Your Reports


You will: Sort and group report records.

In this lesson, you will customize reports to better organize the displayed information and produce specic print layouts such as mailing labels.

Set report control properties that enhance the display of data.

Add a subreport to a report footer. Create a mailing label report.

to
DO NO

ru c

Lesson 13: Customizing Your Reports

In st

DU

PL

IC

AT
277

Include data that is printed at the beginning or end of each group of data on your report.

Control whitespace between records and manual page breaks.

rE

di tio n

Lesson Time 1 hour(s)

LESSON 13
Introduction
The reports you create with AutoReport or the Report Wizard might work perfectly for you, but chances are youll end up in the Report Design view window to improve your reports at some point. This lesson will provide an opportunity to try your hand at many report design tasks. You have been assigned to produce invoices from a product orders database. Using basic report features, you could create one report for the customers information and a second report for the products they have just ordered. But, by customizing a report, you can create a single, far more effective invoice.

TOPIC A

Organize Report Information

to
Description

Report Design Enhancements

Text display Whitespace

Change the alignment of text within a control to provide greater balance. Reduce or increase the amount of whitespace between records in the Detail section. Add lines, rectangles, borders, or dashes to your report. Add pictures and logos to your report for visual appeal. Control whether to keep the data in a group together on a page or force a page break before or after a section. Create a custom page, such as one with a subreport.

In st

Graphic elements Pictures Page breaks

Custom pages

DO

NO

Enhancement

T
Microsoft Ofce Access 2003 Level 1

Table 13-1: Report Design Enhancements

278

ru c

DU

Regardless of the method you chose to initially create a report, you can always modify the report design to improve it. There are many report design features that you can use to accomplish this. (See Table 13-1.)

PL

IC

By determining the order in which the data is displayed in the report and by grouping relevant 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 alphabetical 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.

rE

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 any summary information. In this topic, you take the rst step in customizing your reports by sorting and grouping report records to show summary information.

AT

di tio n

LESSON 13
Report Design View
The Report Design view window (see Figure 13-1) is the design environment for making changes to a reports design. It provides numerous tools to help you improve the design of reports generated by the Report Wizard or those previously created manually.
Many of the tools available to help you with your design work in Report Design view are the same as those available in Form Design view.

Tool
Report Design toolbar

Description

Provides buttons for common tasks like View, Save, and Print. It also includes the useful Sorting and Grouping button.

Formatting toolbar Toolbox

Has buttons for typical formatting jobs, like changing font sizes and colors. Has buttons for placing labels, elds, images, and other special-purpose objects in a report. This is where you typically go to nd controls to add to your report. Shows elds from the table or query that is the source of data for the report you are working on. Each object in a Report Design view window has its own properties dialog box with tabs that list the properties you can change for the object.

Field List Properties dialog box

rE
NO T

Control Wizards toggle button

to In st
Lesson 13: Customizing Your Reports

DO

ru c

DU

PL

IC

Often when you click a button in the Toolbox to place an object on the report design, you get some help from one of the Access wizards.

AT

E
279

di tio n

LESSON 13

Figure 13-1: The Report Design view window.

rE
NO T

to
DO

1. 2. 3. 4. 5. 6. 7. 8. 9.

Open a query in Design view.

In st

ru c
280

In the New Report dialog box, select Report Wizard and click OK. Select the desired elds and click Next.

Choose the desired eld to group records by and click Next. If desired, choose additional grouping levels. Click Next. If desired, choose a eld to sort records by and choose a sort order (Ascending or Descending). If desired, specify any calculated elds by clicking Summary Options and making a selection. Click OK, and then click Next. Choose a layout for your report and click Next.

10. Choose a style for your report and click Next. 11. Name your report and click Finish.

DU

From the New Object buttons drop-down list, select Report.

PL

To build grouping and sorting features into a report based on a query by using the Report Wizard:

Microsoft Ofce Access 2003 Level 1

IC

Procedure Reference: Add Report Grouping using the Wizard

AT

How to Organize Report Information

di tio n

LESSON 13
Procedure Reference: Add a Report Grouping Section Manually If, after using the Report Wizard, you decide to add record grouping and sorting, you can still do so. To manually add a Report Grouping section to a report:
1. 2. 3. 4.

Open a report.

Open the Sorting And Grouping dialog box.

To specify a sort, click in the rst blank line under the Field/Expression section to show its drop-down arrow, and then select the eld you want from the list of elds. Under the Sort Order heading, specify Ascending or Descending. In the bottom half of the dialog box, select the group properties you would like, such as a header or a footer. As desired, move the sort eld higher in the eld list. Close the Sorting And Grouping dialog box.

5. 6. 7.

Sorting and Grouping Report Records


Data Files: Report.mdb

rE
NO T DU

ACTIVITY 13-1

to
DO

What You Do 1.

In st

Start the Report Wizard to create a report based on qselSalesAndProfit. Include the BookTitle, CustomerName, QuantitySold, TransactionDate, and OrderID fields.

Lesson 13: Customizing Your Reports

ru c

Scenario: You need to create a report with customer order information grouped by book titles. The report will be based on a query, qselSalesAndProt, that draws data from four tables and displays all kinds of information about the books transactions. Under each book title will be customer name, quantity sold, transaction date, and order ID. These detail records will be sorted by customer name. Under each title, you also want to show how many of that book youve sold.
How You Do It

a. Open Report.mdb. b. Open qselSalesAndProfit in Design view. c. From the New Object buttons drop-down list, select Report. d. In the New Report dialog box, select Report Wizard. Click OK.

PL

IC

Setup: Access is open.

AT
281

di tio n

Display the report in Design view.

LESSON 13
e. From the Available Fields list box, move the BookTitle, CustomerName, QuantitySold, TransactionDate, and OrderID fields to the Selected Fields list box. Click Next.

rE
NO T

2.

Group the data by book title. Sort the detail records by customer name in ascending order.

to ru c In st
282

DO

DU
b. You dont want other grouping levels. Click Next.

PL
Microsoft Ofce Access 2003 Level 1

IC

AT

di tio n

a. To view your data by book title, verify By TblBookProject is selected. Click Next.

LESSON 13
c. From the first sort drop-down list, select CustomerName. The default sort order is Ascending.

3.

Specify the sum of the quantity sold as the only summary value to be calculated.

a. To summarize detail records, click Summary Options . b. For the QuantitySold field, check Sum.

rE to ru c In st
Lesson 13: Customizing Your Reports

c. Click OK, and then click Next.

DO

NO

DU

PL

IC

AT
283

di tio n

LESSON 13
4. Set the layout and style of your report to be Align Left and Formal and complete the wizard.
You can preview the layout and style in the left section of the dialog box.

a. In the Layout option group, select Align Left 1. Click Next. b. From the report style list box, select Formal. Click Next.

rE to
DO
5.

What are some things you could improve about the data layout?

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 group and the sum of the quantity sold. You might want to add other group information, 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. Close the Print Preview of the report and close qselSalesAndProfit. a. To display Design view, click Close . b. Close qselSalesAndProfit.

In st

8.

NO

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 you could control where the pages break.

ru c

DU

This questioning series sets the stage for the remainder of the lesson.

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?

284

PL

Captions, widths, and alignment could be improved.

Microsoft Ofce Access 2003 Level 1

IC

AT

As you scroll through the report, you might see features you would like to change.

di tio n

c. In the report title text box, type My Book Sales and click Finish.

TOPIC B
Set Report Control Properties
Youve 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 doesnt display very well in the report. In this topic, you will use control properties to enhance the data layout. 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 specications. But to look truly outstanding, in most cases, youll need to bring a little nesse to the situation by altering some key control properties. In the end, the effort will be worthwhilea report that really stands out for both its organization and its layout design.

LESSON 13

Display Properties

Report control properties allow you to customize the look and capabilities of controls in your reports.

Control Property
Caption Width Height Can Grow

Description

Sets an objects width to specic dimensions.

Sets an objects height to specic dimensions.

to
DO

Can Shrink

Text Align

ru c

Species the alignment of text in the control. Settings are General, Left, Center, Right, or Distribute.

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.

Hide Duplicates Property If you use the Report Wizard to design a report and you select a eld for grouping, Access automatically puts that eld in a Group Header, where it is printed only once for each group. The Hide Duplicates property provides an alternative method for suppressing repeating values without choosing groups. To use the Hide Duplicates property, sort the records on a eld (either by basing the report on a query or in the report design itself), so that the repeating values in the eld appear together. In the report Design view, select the appropriate control. Set the Hide Duplicates property for the control to Yes.

Lesson 13: Customizing Your Reports

In st

NO

DU

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 is displayed.

PL

Controls the appearance of controls that are printed or previewed. When set to Yes, the control automatically resizes vertically so that all the data it contains is shown.

IC

AT

E
285

Provides an alternate label to be used in place of the default name for the control.

rE

di tio n

LESSON 13
How to Set Report Control Properties
Procedure Reference: Modify the Properties of a Control To enhance the appearance of the report by modifying the properties of its controls:

2.

Change the properties displayed in the properties dialog box as desired.

ACTIVITY 13-2
Data Files: Report.mdb

Setting Report Control Properties

to ru c In st
286

DO

NO

T
Microsoft Ofce Access 2003 Level 1

DU

PL

IC

AT

Scenario: You have decided to make some improvements to the My Book Sales report. Your rst focus is the data layout. For example, some book titles and customer names are truncated. In addition, 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.

rE

Setup: The My Book Sales report is open in Design view.

di tio n

1.

Select the control in report Design view.

LESSON 13
What You Do 1. For both the report title bar and for the report title, change the caption to Book Sales. How You Do It a. Choose ViewProperties to display the reports properties. b. Change the reports Caption property to Book Sales

You wont see this change take effect unless the report is in Print Preview.

c. In the Report Header section, select the label control. d. Change the labels Caption property to Book Sales

rE
NO T

to
DO

2.

3.

In st

Change the alignment of the QuantitySold data in the Detail section to center the values.

Lesson 13: Customizing Your Reports

ru c

b. In the Detail section, select the text box CustomerName. On the Format property page, change the Can Grow property to Yes. a. Select the QuantitySold text box. b. Scroll down the list of properties on the Format tab and change the controls Text Align property to Center.

DU

Change the width of the BookTitle text box to fit each title on a single line. Modify the CustomerName text box control so long names wrap to a second line.

a. In the BookTitle Header section, provide enough space for each title to be displayed on a single line by selecting the BookTitle text box and changing its Width property to 3.75

PL

IC

AT

You can keep the property window open and simply select each of the controls whose properties you wish to modify, as the property window will dynamically display the current controls properties.

E
287

di tio n

LESSON 13
4. Center the values of the TransactionDate and Sum Of QuantitySold text boxes. a. For the TransactionDate text box in the Detail section, change the Text Align property to Center. b. For the SumOfQuantitySold text box in the BookTitle footer, change the Text Align property to Center.

5.

Change the caption of the Sum label to Total Sold and set its width to 0.56. Change the caption of the Grand Total label to Books Grand Total, set its width to 1.35, and center it.

rE to ru c In st
288

DO

NO

T
Microsoft Ofce Access 2003 Level 1

DU

PL

IC

d. Preview the report by clicking Print Preview .

AT

di tio n
Set its Width property to 0.56 Set its Width property to 1.35

a. For the Sum label in the BookTitle Footer section, change the Caption property to Total Sold

Access might change this to 0.5597.

b. For the Grand Total label in the Report Footer section, change the Caption property to Books Grand Total

c. For the QuantitySold Grand Total Sum text box in the Report footer, change the Text Align property to Center.

LESSON 13
6. Hide repeating data in the CustomerName text box control. Save your work as rptMyOrders. a. Change to Design view. In the Detail section, select the CustomerName text box control.

b. On the Format page of the properties dialog box, change the Hide Duplicates property to Yes.

to ru c In st
Lesson 13: Customizing Your Reports

e. Change to Design view. Save the report as rptMyOrders

DO

NO

DU

PL

IC

AT

d. Preview the report. No repeated data is displayed in the CustomerName column in the report.

rE

c. Close the properties dialog box.

E
289

di tio n

LESSON 13

TOPIC C
Control Report Pagination
So far in this lesson, youve organized the desired information through grouping and sorting, and youve 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. 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 deal, having data spill over in no organized fashion can cause your audience to become distracted and lose interest, and it may prevent them from arriving at the conclusions you are trying to make. However, setting your pagination squarely and properly does not take much additional effort and can be the clincher for a great-looking report.

Keep Together Property

Keep Together Property Settings

to
DO NO

Setting
No

Description

ru c
Whole Group With First Detail

In st

Force New Page Property


The Force New Page property can be used to force each new section to print on a new page of the report. This property can guarantee that critical information is shown on a fresh page.

DU

Allows the group to print without keeping the Group Header, Detail, and Group Footer sections on the same page. Forces the Group Header, Detail, and Group Footer sections to print on the same page. Groups that are too large to t on a single page will be split across pages. Allows the Group Header to print on a page only if the rst Detail record can also be printed on that page.

290

PL

Microsoft Ofce Access 2003 Level 1

IC

AT

The Keep Together property can also be directly applied to a particular section. In this case its possible values are simply Yes and No.

rE

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 from being displayed alone at the top of a new page.

di tio n

LESSON 13
Force New Page Property Settings Setting
None Before Section After Section Before & After

Description

Forces the section to start printing at the top of a new page.

Forces the following section to start printing at the top of a new page. Forces the current and following sections to start printing at the top of a new page.

How to Control Report Pagination


Procedure Reference: Control Pagination of a Report To control report pagination:
1. 2.

If necessary, open the report in Design view.

Select the section and then change the Height property.

to
DO

The settings are conned to the section in which they are made. For example, if you increase the size of the Report Heading section, it wont affect the spacing in the Detail section of the report.

3. 4. 5.

Open the Sorting And Grouping dialog box.

Set the Keep Together and/or Force New Page properties for the group. Close the Sorting And Grouping dialog box.

ru c

Lesson 13: Customizing Your Reports

In st

Troubleshooting a Report When you print your report, you might get unwanted blank pages for one of several reasons. 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 Footers Height property and make sure its set to zero. If youre 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 dont exceed the paper size specied 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.

NO

DU

PL

IC

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.

AT

E
291

If desired, adjust line spacing in one of two ways: Drag the section header to the desired location on the vertical ruler.

rE

di tio n

Allows the section to print on the current page.

LESSON 13

ACTIVITY 13-3
Reducing the Amount of White Space Between Records and Controlling Manual Page Breaks
Data Files: Report.mdb

Setup: The rptMyOrders report is open in Design view.

Scenario: Youve 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 these layout aws.

rE to ru c In st
292

DO

NO

T
Microsoft Ofce Access 2003 Level 1

DU

PL

IC

AT

di tio n

LESSON 13
What You Do 1. The records in the report are rather spaced out. Reduce the unnecessary white space under the controls in the Detail section by decreasing its size. How You Do It a. To select all of the controls in the Detail section, click in the vertical ruler to the left of the controls in the Detail section.

b. To position the controls higher in the Detail section, press the up arrow key once.

c. Place the mouse pointer on the top border of the BookTitle Footer band. Drag the band up a small distance to nearly touch the bottoms of the four text box controls in the Detail section.

rE to
2. To prevent groups from splitting on the report, open the Sorting And Grouping dialog box and set the Keep Together property to Whole Group.

Instead of dragging the band, you could change the Height property of the Detail section to 0.225.

ru c

a. Click the Sorting And Grouping button .

In st

Lesson 13: Customizing Your Reports

DO

NO

b. With BookTitle selected, under the Group Properties heading, display the Keep Together drop-down list.

DU

PL

IC

AT
293

di tio n

LESSON 13
c. To keep category groups together on the same page, select Whole Group.

to
DO NO

As you saw earlier, you can use the Report Wizard to show summary information in a report. Now youll go through the steps of setting up summary elds by hand, and youll add other elds to the Group Footer as well.

In st

Sometimes your reports call for even more detail and organization than youve created thus far. For these more complex reports, manually using groups and summary information elds is the ticket. While this can take some extra effort, the results are denitely worthwhile, as it permits you to provide exactly the information desired in your report.

How to Summarize Information


Procedure Reference: Dene a Summary Field To dene a summary eld, perform the following steps: If necessary, open the report in Design view.
Microsoft Ofce Access 2003 Level 1

1.

294

Summarize Information

ru c

DU

TOPIC D

PL

IC

AT

Remind students of the option for viewing multiple pages of a report at once.

rE

3.

Preview the report and save your work.

di tio n

d. Verify that the Group Header and Group Footer properties for the BookTitle field are each set to Yes. Each section will display in the report. Close the Sorting And Grouping dialog box. a. Select Print Preview to preview your report. b. Customer names are closer together, so theres less white space. No groups are split across pages. Close print preview to return to Design view. Save the report.

LESSON 13
2. 3. 4. 5.

Make room in the report for the new control. Choose the Text Box tool. From the Toolbox, click the report design where you want to create a Text Box control.

Adding Fields to Sections in a Report Depending on the information you display in your report and how its grouped, you might still need to add elds to a report section. You can do this by dragging elds from the eld list to the appropriate section of your report.

Moving Report Controls To move a control youve 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.

Including Group Data and Dening a Summary Field


Data Files: Report.mdb

rE
NO T

ACTIVITY 13-4

to
DO

What You Do 1.

Make room on the report for two new controls.

Lesson 13: Customizing Your Reports

In st

ru c

How You Do It

a. Display the properties dialog box for the BookTitle Footer.

DU

Scenario: You would like to provide the readers of your Book Sales report with more information about each book title. In particular, you will show inventory and restock orders for each book title. Additionally, you would like to add those numbers to show the available count of the title.

PL

IC

Setup: The rptMyOrders report is open in Design view.

AT
295

di tio n

In the properties dialog box for the new control, in the Control Source property, enter an expression for the summary you want to perform.

LESSON 13
b. Change the Height property to 1

rE to ru c In st
296

DO

NO

T
Microsoft Ofce Access 2003 Level 1

DU

PL

IC

AT

di tio n
c. Close the property dialog box.

LESSON 13
2. Add the InStock and OnOrder fields to the BookTitle Footer and align them as necessary. a. If necessary, choose ViewField List to display the field list window. b. From the bottom of the field list, select InStock and OnOrder.

c. Drag the selected fields to the 1 horizontal position in the BookTitle Footer, below the Total Sold label and text box controls.

rE to ru c
f. Close the field list.

You can ne-tune the placement of selected controls by using Ctrl-arrow keys.

In st

b. Click in the Booktitle Footer to the right of the InStock and OnOrder controls at about the 3.5 horizontal mark. c. In the properties dialog box for the new control, click the Data page.

Lesson 13: Customizing Your Reports

DO

3.

Create a Text Box control to show the total inventory and sum of the InStock and OnOrder values. Align as necessary.

a. From the toolbox, choose the Text Box tool .

NO

e. To align all three labels, choose Format AlignLeft.

DU

d. With the InStock and OnOrder label controls selected, shift-click the Total Sold label to select it as well.

PL

IC

AT
297

di tio n

LESSON 13
d. On the Data page, in the Control Source property box, enter =([InStock]+[OnOrder])

rE
f.

to ru c In st
298

g. Set the Width property to 0.9 h. Close the properties dialog box.

T NO
j.

DO

DU
i.

With the Total Inventory label and text box controls selected, Shift-click the OnOrder text box to select it as well. To align these controls, choose Format AlignBottom.

PL

Microsoft Ofce Access 2003 Level 1

IC

AT

On the Format page of the properties dialog box, edit the caption to read Total Inventory

di tio n
e. Select the new label control.

Your property dialog box may have a title other than Text Box: Text33.

LESSON 13
4. Separate the new controls from the next group with a dashed line (2pt width) that is five inches long. a. Choose the Line tool . b. Hold down the Shift key and draw a line below the controls in the BookTitle Footer section that extends from the 0 mark to the 5 mark on the horizontal ruler. c. Display the properties for the line.

d. Change the lines Border Style property to Dashes.

e. Change the lines Border Width property to 2 pt. f. Close the properties dialog box.

rE
NO T

g. Save the updated report.

to
DO

In st

Lesson 13: Customizing Your Reports

ru c

b. Close the report preview.

DU

PL

IC

5.

Preview your report.

a. Click Print Preview.

AT
299

di tio n

LESSON 13

TOPIC E
Add a Subreport to an Existing Report
Youve 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. 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 using a subreport. Doing so will save you time and result in a single, effective report with all the data you need to convey.

Subreports

rE
NO T

Denition: A subreport is a report inserted into another report called the main report. This is often done in the main reports 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 using a link eld. A main report can also be unbound and act as a folder for unrelated subreports that you want to combine.
The use of a link eld to link a subreport to a main report is similar to the link eld used to link a subform to a main form.

to
DO

In st

ru c
300

Figure 13-2: A subreport to display product names in a bound main report displaying orders.

DU
Microsoft Ofce Access 2003 Level 1

PL

IC

Example: Subreport in a Bound Main Report

AT

di tio n

LESSON 13
How to Add a Subreport to an Existing Report
Procedure Reference: Create a Subreport To create a subreport:

2. 3. 4. 5. 6. 7.

If necessary, make room for the subreport. Click the Subform/Subreport tool.

Click in the report where you want to place the subreport.

In the SubReport Wizard, select the record source for the subreport. Click Next. Choose which elds will link the main report to the subreport, or choose None. Click Next. Name the control and click Finish.

Another way to add a subreport to a report is to vertically tile the database window and the 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.

Adding an Existing Subreport to an Existing Report

to
DO NO

Data Files: Report.mdb

Scenario: 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 customers name and ID reference. You will therefore add the second report, rsubCustomerNameAndID, as a subreport to the main report. By placing the subreport in the Report Footer section, it will be printed once at the end of the report.

ru c

Lesson 13: Customizing Your Reports

In st

DU

Setup: The rptMyOrders report is open in Design view.

PL

IC

AT
301

ACTIVITY 13-5

rE

di tio n

1.

If necessary, open the main report in Report Design view.

LESSON 13
What You Do 1. Make room for a subreport and then add rsubCustomerNameAndID to the Report Footer section. How You Do It a. To make room for the subreport, enlarge the Report Footer section by setting its Height property to 2.5

rE to ru c In st
302

NO

DO

T
d. Specify the data for the subreport. Select Use An Existing Report Or Form to specify the data for the subreport. e. Select rsubCustomerNameAndID. Click Next. f. From the list, select None. Click Next.

DU
Microsoft Ofce Access 2003 Level 1

PL

c. To start the wizard, click in the Report Footer area directly below the Books Grand Total label.

IC

AT

b. In the Toolbox, click the Subform/ Subreport tool .

di tio n
You could also accomplish this by dragging the bottom border of the Report Footer section.

LESSON 13
g. To leave the name intact, click Finish.

h. Save the modified report design.

rE to ru c In st
Lesson 13: Customizing Your Reports

DO

NO

DU

PL

IC

AT
303

di tio n

LESSON 13
2. Preview your report to verify the subreport and see what design issues remain. a. Preview the report. b. To view two pages at a time, click the Two Pages button . c. Scroll through the first several pages.

rE to ru c In st
304

DO

NO

T
Microsoft Ofce Access 2003 Level 1

DU

PL

IC

e. To see the grand total of books sold in the subreport in the report footer, view the second-to-last page.

AT

di tio n

d. Verify that when you added this subreport to the report, the reports width became greater than the printable width, so the number of pages doubled and every other page is blank.

LESSON 13
f. 3. Eliminate the blank pages. Save your work. Close Print Preview. a. Choose FilePage Setup. b. On the Page tab, change the orientation to Landscape. Click OK. c. Preview the report.

d. Verify that the blank pages in the report have been eliminated. Close the preview. e. Choose FilePage Setup. f.

On the Page tab, change the orientation to Portrait.

rE
NO T

g. On the Margins tab, change the Right Margin setting to 0.5

to In st
h. Click OK. i.

Lesson 13: Customizing Your Reports

DO

ru c

Save the modified report design.

DU

PL

IC

AT
305

di tio n

Two different approaches to solving the problem of blank pages in a report are being shown in this step.

LESSON 13
4. Preview the report. a. Preview and page through the report in the two-page layout.

rE to
DO
TOPIC F

In st

Typically, in a large enough company or organization, labels are created for mailing purposesfor addressing envelopes and packages. However, you can just as easily create product labels, tape labels, name tags, or any other type of label you want. Rather than having to create a report from scratch, or use the standard Report Wizard, you will nd that the Access Label Wizard will save you a lot of time and create exactly the kind of result you need to print labels.

NO

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 as when mailing labels are needed. Fortunately, Access provides a wizard specically for this need, and in this topic, you will use it to create a mailing labels report.

ru c

DU

Create Mailing Labels

306

PL
Microsoft Ofce Access 2003 Level 1

IC

AT

di tio n

b. Verify that the blank pages in the report have been eliminated. Close the preview and the report.
If the blank pages remain, make sure that the report design grid is not more than seven inches wide.

LESSON 13
How to Create Mailing Labels
Procedure Reference: Create a Report that Prints Mailing Labels To create a report that prints mailing labels by using the Mailing Label Report Wizard:
1. 2. 3. 4. 5. 6.

In the database window, display the report objects and click New. Double-click Label Wizard to open the rst wizard step.

Choose a table or query for the labels and then click OK.

Choose the type of mailing label youre using. Click Next. Choose the text style for the labels. Click Next.

Arrange elds in the Prototype Label box to create a label layout. (Double-click a eld to move it to the Prototype Label box. Press Spacebar, add punctuation, and press Enter as necessary to create the layout.) Click Next. Select a eld to sort your labels by. Click Next. Name the mailing label report. Click Finish.

7. 8.

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.

rE
NO T

In st

Lesson 13: Customizing Your Reports

DO

ru c

DU

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 table that holds employee names and addresses and another that holds customer names 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 reports 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 control sources in each controls properties dialog box.

to

PL

IC

AT

E
307

di tio n

LESSON 13

ACTIVITY 13-6
Creating Mailing Labels
Report.mdb

Setup: The Report database window is open.

Scenario: 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 tblCustomer.
What You Do 1. How You Do It

to ru c In st
308

c. Select Label Wizard. d. Click the drop-down list.

DO

NO

DU
f.

e. Select tblCustomer.

Click OK.

PL

Microsoft Ofce Access 2003 Level 1

IC

AT

b. Click New log box appears.

Begin to create mailing labels using the wizard. Specify that the data should come from tblCustomer.

rE

di tio n

Data Files:

a. If necessary, display the report database objects. . The New Report dia-

LESSON 13
2. Select a label size, unit of measure, label type, and manufacturer by accepting the defaults. a. Under the label size section, verify that the first option is selected.

b. Accept the other options for Unit Of Measure, Label Type, and Manufacturer by clicking Next to continue. c. To accept how the text on your label appears, click Next.

rE
NO T

to
3. Add the CustomerName, Address, City, Region, and PostalCode fields to the label.

In st

Lesson 13: Customizing Your Reports

DO

ru c

a. Double-click CustomerName. Press Enter. b. Double-click Address. Press Enter. c. Double-click City. Type a comma. Press Spacebar. Double-click Region. Press Enter.

DU

PL

IC

AT
309

di tio n

LESSON 13
d. Double-click PostalCode. Press Enter.

4.

Sort the labels by customer name and name the report rptMyLabels.

rE to
DO NO

ru c

In st

DU

5.

Close the report and the database.

a. Close the report preview. b. Close the report window. c. Close the Report database.

310

PL

Microsoft Ofce Access 2003 Level 1

IC

AT

di tio n
e. Click Next. b. Type rptMyLabels c. Click Finish.

a. Double-click CustomerName. Click Next.

LESSON 13
Lesson 13 Follow-up
In this lesson, you modied reports to make them more visually effective and rich with information. You were able to reduce white space, modify page breaks, and generally improve the look of a report. But you also improved the reports effectiveness at conveying information by including calculated elds 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 your reports?

Answers will vary, but might include dealing with whitespace, improving the page breaks, including lines or graphics, and so on. 2. What do you think will be the most challenging requirements for increasing the information that is conveyed by your reports?

Answers will vary, but might include providing sensible calculated and summary fields, adding subreports to main reports, creating mailing label or other standard reports, and so on.

rE to ru c In st
Lesson 13: Customizing Your Reports

DO

NO

DU

PL

IC

AT
311

di tio n

NOTES

rE to ru c In st
312

DO

NO

T
Microsoft Ofce Access 2003 Level 1

DU

PL

IC

AT

di tio n

LESSON 14

LESSON 14

Expanding the Reach of Your Data


You will: Publish data from Access as a Word document.

rE
NO T

In this lesson, you will use Access data in other applications, including Microsoft Word and Excel.

Export data from individual database objects to a text le.

to
DO

Lesson 14: Expanding the Reach of Your Data

In st

ru c

DU

PL

IC

Merge data from Access with an existing Word document.

AT
313

Analyze data from Access in an Excel spreadsheet.

di tio n

Lesson Time 30 minutes

LESSON 14
Introduction
The Access application is a great tool and it may be all you need to use to work with your data. But you havent yet explored ways to take your data beyond Access. In this lesson, youll export data to a text le and look at some of the methods for using your data in other programs 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 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.

TOPIC A

to
DO

Table 14-1: Office Links Options and Results Ofce Link Works With
Publish It With Microsoft Office Word

ru c

DU

The Office Links tool enables you to share Access data with Word and Excel. There are three Office Links options, each of which works with different types of Access objects and has a different result. (See Table 14-1.)

Forms, Reports, Tables, Queries

NO

In st

Analyze It With Microsoft Office Excel

Forms, Reports, Tables, Queries

Merge It With Microsoft Office Word

Queries, Tables

314

PL

Office Links

Microsoft Ofce Access 2003 Level 1

IC

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.

Results
Creates an RTF le of the Access object and opens it in Word. Saves Access data as an Excel le and opens it in Excel. Creates an Access data source for mail merge documents and launches the Mail Merge Wizard in Word.

AT

There are numerous ways you can use Access data outside of the Access program itself. The rst you will consider is how to use a table worksheet or a report in Microsoft Word.

rE

Publish Access Data as a Word Document

di tio n

LESSON 14
How to Publish Access Data as a Word Document
Procedure Reference: Publish an Access Document with Word To publish an Access document with Word:

2. 3.

Choose ToolsOffice LinksPublish It With Microsoft Office Word. Word will open, displaying the Access object as an RTF le. Save the Word document.

ACTIVITY 14-1
Data Files: Expand.mdb

Publishing Access Data as a Word Document

to
DO

What You Do 1. Publish rptMyOrders with Word.

How You Do It

ru c

a. Open Expand.mdb.

c. If necessary, select rptMyOrders.

Lesson 14: Expanding the Reach of Your Data

In st

NO

b. In the database window, display the report objects.

DU

PL

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 areas, and make other formatting changes. You decide to use Office Links to publish the Access report to Word.

IC

AT

E
315

Setup: Access is open.

rE

di tio n

1.

In the database window, select the datasheet, form, report, or query that you wish to publish.

LESSON 14
d. Choose ToolsOffice LinksPublish It With Microsoft Office Word.

2.

b. Click Save.

to
TOPIC B

ru c

In st

You have seen how Access data can be used in Word. Now youre ready to see what you can do with Access data in Excel. Excel provides data analysis options that just arent 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.

Excel Office Links


Since they arent available or easily accessible in Access, you can take advantage of Excels nancial analysis tools and charting options by using the Analyze It With Microsoft Office Excel office links option. In doing so, your data is saved as an Excel XLS le.

DO

NO

Analyze Access Data in Excel

DU
Microsoft Ofce Access 2003 Level 1

316

PL

IC

c. Close Word.

AT

Save the Word document as rptBookSales.rtf and close the document in Word.

rE

di tio n
a. In Microsoft Word, choose FileSave As and name the file rptBookSales.rtf

LESSON 14
Any formatting that you have done in Access, such as font style and color, will be transferred to Excel.

How to Analyze Access Data in Excel


Procedure Reference: Analyze Access Data in Excel To analyze Access data in Excel:
1. 2. 3.

In the database window, select the datasheet, query, form, or report that you wish to publish.

Choose ToolsOffice LinksAnalyze It With Microsoft Office Excel. Excel will open, displaying the Access data in an Excel worksheet. Save the Excel le.

to
DO
How You Do It

Expand.mdb

Setup: The Expand database is open in Access.

What You Do 1.

In st

Analyze the qtotCategories query in Excel.

a. In the database window, display the query objects. b. If necessary, select qselQuantitySold.

Lesson 14: Expanding the Reach of Your Data

NO

Scenario: Your manager has asked for sales data for each book part number. She needs only the total 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 chartan option not easily accessible in Access.

ru c

DU

PL

IC

Data Files:

AT
317

Creating an Excel Chart with Access Data

ACTIVITY 14-2

rE

di tio n

Dragging and Dropping Tables and Queries to Excel Another way to export data from Access to Excel is by dragging and dropping an 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 Excels toolset.

LESSON 14
c. Choose ToolsOffice LinksAnalyze It With Microsoft Office Excel. Excel opens and the query is displayed.

rE to ru c In st
318

DO

NO

T
Microsoft Ofce Access 2003 Level 1

DU

PL

IC

AT

di tio n

LESSON 14
2. Create a 3-D exploded pie chart with the data. a. In Excel, click the Chart Wizard button . b. In the first screen of the wizard, in the Standard Types page, under the Chart Type heading, select Pie. c. For the chart sub-type, select the middle type on the bottom row, Exploded Pie Chart With A 3-D Visual Effect. Click Next.

rE to ru c
f.

d. To accept the default worksheet data selection, click Next. e. The next screen of the wizard asks you to add a chart title. The wizard uses Total Quantity from the column heading for the sales totals. To accept the default, click Next. The final screen in the wizard asks where you wish to place the chart. Verify that As Object In qselQuantitySold is selected, and then click Finish.

In st

Lesson 14: Expanding the Reach of Your Data

DO

NO

DU

PL

IC

AT
319

di tio n

LESSON 14
3. Improve the placement of the chart and save your work as rptQuantitySold. a. Click the chart graphic and drag it to the top of your worksheet, starting at the D column.

rE to ru c In st
320

DO

NO

T
c. Choose FileSave As and name the file rptQuantitySold d. Click Save. e. Close Excel.

DU
Microsoft Ofce Access 2003 Level 1

PL

IC

AT

di tio n
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 that all of the labels in the box on the right are shown.

LESSON 14

Export Data to a Text File

Besides Word and Excel, you can also use your Access data in other applications or in another Access database. In this topic, you will export your data to a text le so that it can be used elsewhere.

Access is a great program for managing lists of data; however, it doesnt do everything. For example, you may want to export data from Access into a specic accounting application to take advantage of its advanced mathematic capabilities. By exporting data from Access to a text le, you are then in a position to import that data into other databases or programs. This is a exible approach to expanding the reach of your data, allowing Access data to be used in a wide range of applications.

to
DO

ru c
Lesson 14: Expanding the Reach of Your Data

In st

NO

DU

PL

As you consider exporting data to other sources, keep in mind that other database systems have limitations on the types of les they will accept. Some database systems will accept les in Excel format; others might only accept text le formats. All of the Access objects allow you to export their data into a variety of formats (Excel, text les, html, and so on), but the output of those formats will vary from one object to another. For example, exporting a table or query to a text le is likely to result in a le that can be utilized in another database system. Exporting a form or report to a text le is unlikely to have the same result.

IC

AT

E
321

Exporting is a means of outputting data and database objects to another database, spreadsheet, or le format, so another application can use the data. A copy of the data is created in an external source le, so the original data is still stored in your database.

rE

Exporting

di tio n

TOPIC C

LESSON 14

to
DO

Procedure Reference: Export Data to a Text File

To export data from an Access table to an external text le:

ru c
2. 3. 4. 5. 6. 7. 8. 9.

Choose FileExport.

Change the folder, if needed, and enter a name for the new le. Change Save As Type to the type of le you want to export to. Click Export.

Choose an export format. Click Next. If you chose Delimited, then choose a character delimiter. Click Next. Choose a destination for the output le. Click Finish. Click OK when the export is complete.
To export to an Access database, enter a name for the exported object in the Export dialog box. Select Denition Only if you want to export an empty table. Click OK.

In st

NO

DU

1.

Open the database window and select the object you want to export.

322

PL

Microsoft Ofce Access 2003 Level 1

IC

How to Export Data to a Text File

AT

Figure 14-1: A copy of data from a table, query, form, or report can be made in various file formats.

rE

di tio n

ACTIVITY 14-3
Exporting Database Records to Notepad
Expand.mdb Data Files:

LESSON 14

Setup: The Expand database window is open.

Scenario: 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 le. To accomplish this, you will export the data from Access to a semicolon delimited text le.

rE to ru c In st
Lesson 14: Expanding the Reach of Your Data

DO

NO

DU

PL

IC

AT
323

di tio n

LESSON 14
What You Do 1. Export tblCustomer to a text file, and save it as CustomerData.txt. How You Do It a. In the database window, display the table objects. b. If necessary, select tblCustomer.

rE to ru c In st
324

DO

NO

T
i. j.

DU
h. Select Semicolon as the delimiter. Click Next. Verify that the document will be saved in My Documents. Click Finish. k. The export is complete. Click OK.

PL
Microsoft Ofce Access 2003 Level 1

IC

AT

di tio n
c. Choose FileExport. f.

d. Type a file name of CustomerData

e. Open the Save As Type drop-down list box and choose Text Files. To start the Export Text Wizard, click Export.

g. For the export format, verify that Delimited is selected. Click Next.

2.

Open the CustomerData.txt file in Notepad to verify that the export was successful.

LESSON 14

3.

True or False? The headings for each column of data were not exported with the values. True False

4.

True False 5.

to
DO

b) Semicolon c) Space d) Ampersand 6. Close Notepad.

ru c

a. Close Notepad.

Lesson 14: Expanding the Reach of Your Data

In st

NO

DU

PL

a) Comma

IC

In order for this exported data to be optimally used by another application, which character must not appear in the data?

AT
325

True or False? When a value was empty (null) a space is placed between the two semicolons that delimit this field from the previous and next fields.

rE

di tio n

LESSON 14

TOPIC D
Thus far you have seen how to work with Access data in other applications. In each case, you worked with the data as it is found in Access, but that isnt always ideal. In this topic, you will selectively work with Access data in exactly the way needed to create a personalized letter in Word. Suppose you have a database of employee information stored in Access. The data includes 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, theres a much easier way of merging Access data with Microsoft Wordone that eliminates the unnecessary retyping of the information.

Procedure Reference: Merge an Access Table or Query with an Existing Word Document

to
DO

1.

In the database window, select the table or query.

For smoother merging, check eld names in the Access table or query to be certain that they arent longer than 20 characters and that they do not contain spaces or special characters.

ru c
2. 3. 4. 5. 6. 7. 8.

Choose ToolsOffice LinksMerge It With Microsoft Office Word.

Locate your Word document and click Open. Click Next: Write Your Letter.

In st

Add merge elds to your document, as desired. Click Next: Preview Your Letters and review the resulting merged letters. Click Next: Complete The Merge.

NO

Choose to link your data to an existing Word document, and then select the document. Click OK.

DU

326

PL

Microsoft Ofce Access 2003 Level 1

IC

To merge an Access table or query with an existing Word document:

AT

How to Merge Access Data with a Word Document

rE

di tio n

Merge Access Data with a Word Document

ACTIVITY 14-4
Merging Access Data with a Word Document
Expand.mdb CustomerLetter.doc Data Files:

LESSON 14

Setup: Access is open and the table objects are displayed.

Scenario: A colleague needs to send a special announcement to all of your customers. He has provided a Word le (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 automate the process. You will use the Office Links feature to merge this data with the letter, saving your colleague a great deal of time.
What You Do 1. Start the Office Link Wizard to merge tblCustomer with CustomerLetter.doc. How You Do It

to ru c In st
Lesson 14: Expanding the Reach of Your Data

DO

NO

DU

PL

c. Verify that Link Your Data To An Existing Microsoft Word Document is selected, and then click OK.

IC

b. Choose ToolsOffice LinksMerge It With Microsoft Office Word.

AT
327

a. If necessary, from the list of tables, select tblCustomer.

rE

di tio n

LESSON 14
d. To launch the Mail Merge Wizard in Word, select the CustomerLetter file, and then click Open.

rE to ru c In st
328

DO

NO

T
Microsoft Ofce Access 2003 Level 1

DU

PL

IC

AT

di tio n

LESSON 14
2. In the Write Your Letter step of the wizard, add mail merge fields for the customers name, address, city, region, country, and postal code. a. In the Mail Merge pane, in the Select Recipients section, verify that Use An Existing List is selected and that tblCustomer is selected as that list. Click Next: Write Your Letter.

b. To open the Insert Merge Field dialog box, 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.

rE to ru c In st
f.

d. Close the Insert Merge Field window. e. Press Enter. Click the Insert Merge Fields button again. To add the Address field to the letter, select Address and click Insert.

Lesson 14: Expanding the Reach of Your Data

DO

c. To add the CustomerName field to the letter, select CustomerName and then click Insert.

NO

Do not click the similar looking More Items button in the Mail Merge pane.

DU

PL

IC

AT
329

di tio n

LESSON 14
g. Close the Insert Merge Field window. h. Add merge fields for the City, Region, Country, and Postal Code fields. Separate the City and Region fields with a comma and a space.

ru c In st
330

DO

NO

T
Microsoft Ofce Access 2003 Level 1

DU

PL

Be sure to use the Mail Merge task pane to preview your letter. Do not use Print Preview.

to

IC

AT

3.

Use the Mail Merge task pane to preview your letters. Look at letters for both U.S. and Canadian customers.

rE

di tio n
i.

Add a merge field for the CustomerName field after the greeting and before the comma in the letter.

a. In the Mail Merge task pane, click Next: Preview Your Letters. The letter to your first customer is displayed. Verify that the merge fields have been replaced with customer information from the first record in the table.

LESSON 14
b. To find a Canadian customer, in the Mail Merge task pane, click the Find A Recipient link . The Find Entry dialog box displays.

c. In the Find text box, type Canada and click Find Next.

rE to ru c In st
Lesson 14: Expanding the Reach of Your Data

d. Verify that the first Canadian customer is shown. Click Cancel.

DO

NO

DU

PL

IC

AT
331

di tio n

LESSON 14
4. Complete the merge. Explore your printing options. Save your letters. Exit Word. a. In the Mail Merge task pane, click Next: Complete the Merge. b. Click the Print link . The Merge To Printer dialog box displays, giving you the option to print all of the letters, the current record only, or a range of letters. Click Cancel.

rE to
DO
Lesson 14 Follow-up

In st

2.

How might you take advantage of the Merge It With Microsoft Office Word Office Links option in your work? Answers will vary, but could include: Creating a personalized letter, creating envelopes, or creating merged faxes.

NO

Answers will vary, but could include: When I wish to use a chart type not easily accessible in Access; when I wish to include a chart based on Access data in a Word document; or when I wish to take advantage of Excel-based calculation options.

1.

When might you use the Analyze It With Microsoft Office Excel Office Links option?

ru c

DU

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 document, draw on data as a mail merge source, or use Excel to analyze your data, Office Links make it possible. You can expand the reach of your data further by exporting it in various formats for use in other applications.

332

PL

Microsoft Ofce Access 2003 Level 1

IC

AT

di tio n
c. Save your document as MyCustomerLetter. Close Word. d. Close Access.

Follow-up
In this course, you explored the concept of the relational database and accomplished various tasks using the basic features and components of Access 2003. In addition, you worked with tables to store, modify, and report on data; you created new queries, forms, and reports; and you modied existing queries, forms, and reports. You have also begun to prepare for the more advanced Access courses and have completed the rst step toward obtaining your Microsoft Office Specialist certication.

FOLLOW-UP

Whats Next?

The Microsoft Offce 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 Offce Access 2003 Level 2.

rE to ru c In st
DO NO T DU

PL

IC

AT
333

di tio n

NOTES

rE to ru c In st
334

DO

NO

T
Microsoft Ofce Access 2003 Level 1

DU

PL

IC

AT

di tio n

APPENDIX A

APPENDIX A

Microsoft Office Specialist Program

rE
NO T

Selected Element K courseware addresses Microsoft Office Specialist skills. The following tables indicate where Access 2003 skills are covered. For example, 1-3 indicates the lesson and activity number applicable to that skill.

Create Access Databases Creating databases using Database Wizard Creating blank databases Create and Modify Tables Creating tables using Table Wizard 2-1

to
2-2 2-3 2-4, 2-5, 2-6, 3-1 3-3 2-5 3-2 3-1 2-7

Modifying table properties or structure Creating Lookup elds Changing eld types Modify Field Properties

Dene and Modify Field Types

In st

Changing eld properties to display input masks

Modifying eld properties for tables in Design view Creating and modifying oneto-many relationships Enforce Referential Integrity

Create and Modify One-to-Many Relationships

Appendix A: Microsoft Ofce Specialist Program

DO

ru c

DU

PL

IC

AT
335

Core Skill Sets and Skills Being Measured

Access 2003: Level 1

Access 2003: Level 2

Access 2003: Level 3

Access 2003: Level 4

di tio n

APPENDIX A
Core Skill Sets and Skills Being Measured
Enforcing referential integrity in a one-to-many relationship Create and Modify Queries Creating and modifying Select queries using the Simple Query Wizard Creating and modifying Crosstab, unmatched, and duplicates queries Create Forms Creating forms using the Form Wizard Creating AutoForms Modifying form properties Modifying specic form controls (e.g., text boxes, labels, bound controls) Create Reports Creating reports Adding calculated controls to a report selection Create a Data Access Page Creating data access pages using the Page Wizard Entering records into a datasheet 5-3 5-2 5-5, 5-6, 5-7, 5-8 5-5, 5-6, 6-5 4-3

Access 2003: Level 1

Access 2003: Level 2


2-7

Access 2003: Level 3

Access 2003: Level 4

Add and Modify Form Controls and Properties

rE
6-1 7-1, 7-6 7-4

6-1, 6-2 6-4

Add and Modify Report Control Properties

to
2-2 2-1, 2-5 4-5 4-6 5-6, 5-7

PL T DU
3-4

IC
1-1

Enter, Edit, and Delete Records

Find and Move Among Records Using navigation controls to move among records Import Data to Access

ru c

In st

Create and Modify Calculated Fields and Aggregate Functions Adding calculated elds to queries in Design view Using aggregate functions in queries (e.g., AVG, COUNT) Modify Form Layout Aligning and spacing controls

DO

Importing structured data into tables

NO

336

Microsoft Ofce Access 2003 Level 1

AT

di tio n
2-1, 2-3

APPENDIX A
Core Skill Sets and Skills Being Measured
Showing and hiding headers and footers Modify Report Layout and Page Setup Changing margins and page orientation Aligning, resizing, and spacing controls Format Datasheets Formatting a table or query for display Sort Records Sorting records in tables, queries, forms, and reports Filter Records Filtering datasheets by form Filtering datasheets by selection Identify Object Dependencies Identifying object dependencies View Objects and Object Data in Other Views Previewing for print Using Datasheet, PivotChart, Web Page, and Layout view Print Database Objects and Data Printing database objects and data Export Data From Access Exporting data from Access (e.g., Excel) Back Up a Database Backing up a database 1-4 2-7 2-4 4-1 4-1 2-3 5-1, 7-1 7-5 7-3

Access 2003: Level 1

Access 2003: Level 2


6-1

Access 2003: Level 3

Access 2003: Level 4

1-4

rE
7-5 2-5 1-4

to
2-7 8-3

ru c

Compact and Repair Databases Using Compact and Repair

In st

Appendix A: Microsoft Ofce Specialist Program

DO

NO

T
7-2 7-3

DU

PL

IC

1-1, 1-3, 2-5

AT
337

di tio n

NOTES

rE to ru c In st
338

DO

NO

T
Microsoft Ofce Access 2003 Level 1

DU

PL

IC

AT

di tio n

APPENDIX B

APPENDIX B

Microsoft Office Specialist Program

rE
NO T

Selected Element K courseware addresses Microsoft Office Specialist skills. The following tables indicate where Access 2003 skills are covered. For example, 1-3 indicates the lesson and activity number applicable to that skill.

Create Access Databases Creating databases using Database Wizard Creating blank databases Create and Modify Tables Creating tables using Table Wizard 2-1

to
2-2 2-3 2-4, 2-5, 2-6, 3-1 3-3 2-5 3-2 3-1 2-7

Modifying table properties or structure Creating Lookup elds Changing eld types Modify Field Properties

Dene and Modify Field Types

In st

Changing eld properties to display input masks Modify eld properties for tables in Table Design view

Create and Modify One-to-many Relationships Creating and modifying oneto-many relationships Enforce Referential Integrity

Appendix B: Microsoft Ofce Specialist Program

DO

ru c

DU

PL

IC

AT
339

Core Skill Sets and Skills Being Measured

Access 2003: Level 1

Access 2003: Level 2

Access 2003: Level 3

Access 2003: Level 4

di tio n

APPENDIX B
Core Skill Sets and Skills Being Measured
Enforcing referential integrity in a one-to-many relationship Create and Modify Queries Creating and modifying Select queries using the Simple Query Wizard Creating and modifying Crosstab, unmatched and duplicates queries Create Forms Creating forms using the Form Wizrd Creating auto forms Modifying form properties Modifying specic form controls (e.g., text boxes, labels, bound controls) Create Reports Creating reports Adding calculated controls to a report selection Create a Data Access Page Creating data access pages using the Page Wizard Entering records into a datasheet 5-3 5-2 5-5, 5-6, 5-7, 5-8 5-5, 5-6, 6-5 4-3

Access 2003: Level 1

Access 2003: Level 2


2-7

Access 2003: Level 3

Access 2003: Level 4

Add and Modify Form Controls and Properties

rE
6-1 7-1, 7-6 7-4

6-1, 6-2 6-4

Add and Modify Report Control Properties

to
2-2 2-1, 2-5 4-5 4-6 5-6, 5-7

PL T DU
3-4

IC
1-1

Enter, Edit, and Delete Records

Find and Move Among Records Using navigation controls to move among records Import Data to Access

ru c

In st

Create and Modify Calculated Fields and Aggregate Functions Adding calculated elds to queries in Query Design View Using aggregate functions in queries (e.g., AVG, COUNT) Modify Form Layout Aligning and spacing controls

DO

Importing structured data into tables

NO

340

Microsoft Ofce Access 2003 Level 1

AT

di tio n
2-1, 2-3

APPENDIX B
Core Skill Sets and Skills Being Measured
Showing and hiding headers and footers Modify Report Layout and Page Setup Changing margins and page orientation Aligning, resizing, and spacing controls Format Datasheets Formatting a table or query for display Sort Records Sorting records in tables, queries, forms, and reports Filter Records Filtering datasheets by form Filtering datasheets by selection Identify Object Dependencies Identify object dependencies View Objects and Object Data in Other Views Previewing for print Using datasheet, PivotChart, Web page and layout view Print Database Objects and Data Printing database objects and data Export Data From Access Exporting data from Access (e.g., Excel) Back Up a Database Backing up a database 1-4 2-7 2-4 4-1 4-1 2-3 5-1, 7-1 7-5 7-3

Access 2003: Level 1

Access 2003: Level 2


6-1

Access 2003: Level 3

Access 2003: Level 4

1-4

rE
7-5 2-5 1-4

to
2-7 8-3

ru c

Compact and Repair Databases Using Compact and Repair

In st

Appendix B: Microsoft Ofce Specialist Program

DO

NO

T
7-2 7-3

DU

PL

IC

1-1, 1-3, 2-5

AT
341

di tio n

NOTES

rE to ru c In st
342

DO

NO

T
Microsoft Ofce Access 2003 Level 1

DU

PL

IC

AT

di tio n

LESSON LABS

LESSON LABS

Due to classroom setup constraints, some labs cannot be keyed in sequence immediately following 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 setup section.

rE
NO T

LESSON 1 LAB 1
Activity Time: 10 minutes Data Files: Northwind.mdb

to
DO

Scenario: The consultant that installed your Access application and developed the companys databases has suggested to your manager that you practice using the program before actually working with the companys real data. He suggested opening and touring the Microsoft Northwind.mdb database, which comes as part of the application.

2. 3.

4. 5.

Lesson Labs

In st

1.

If necessary, launch Access.

Search for and locate the Northwind.mdb database. Open the Northwind database and display the Database window. Close the task pane. At the Welcome screen, click OK. Close the Main Switchboard. Open the Customers table and examine the table in Datasheet view. Examine the table in Design view.

ru c

DU

PL

IC

AT
343

Examining the Microsoft Northwind.mdb Database

di tio n

LESSON LABS

6.

Close the table, and then close the database.

Working with Data in Tables


Activity Time: 10 minutes Data Files: UseForms.mdb

rE
NO T

Scenario: Imagine that you work as a data entry person for the GSC Corporation and you have just received a new customers information. Before the customer can place an order they need to be added to the companys database. To add the customer, you need to open the UseForms. mdb database and input the necessary data.

1.

2. 3.

Close the form.

In st

4.

Close the table and the database; do not save your changes.

DO

In the tblCustomers table, verify that the new customers data was added correctly.

ru c

In the UseForms.mdb database, use the frmGSCCustomers form to add the following new customer data to the Customers table: CustomerID: 22000 CustomerName: Maple River Cleaners Address: 2 Sharp Stone Way City: Hamlin Region: MN Country: US Postal Code: 56789 Phone: 567 898 8800 Fax: 567 898 8801

to

DU

344

PL

Microsoft Ofce Access 2003 Level 1

IC

AT

di tio n

LESSON 2 LAB 1

LESSON 3 LAB 1
Examining the Northwind.mdb Database Relationships Window
Activity Time: 10 minutes Data Files: Northwind.mdb

LESSON LABS

Scenario: To reinforce your understanding of table links and relationships, the consultant also suggested that you examine the Northwind.mdb databases Relationship window and open several tables and subdatasheets to familiarize yourself with their use in a larger database environment.

1. 2. 3.

Search for and locate the Northwind.mdb database. Display the Relationships window.

rE
NO T

Right-click in the header of the Orders table and choose Table Design to display the table in Design view.

to
DO

4. 5.

Display the table in Datasheet view.

Open several of the Customer records subdatasheets to examine the orders they have placed. Close the subdatasheets, close the table, close the Relationships window, and then close the Database window.

6.

Lesson Labs

In st

ru c

DU

PL

IC

AT

E
345

di tio n

LESSON LABS

LESSON 4 LAB 1
Creating and Modifying the Design of Select Queries
Activity Time: 15 minutes Data Files: BookBiz.mdb

Scenario: Imagine that you run a book bindery business. Your database includes tables that store information 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: Which books have sold? Which book orders have been for 250 or more books?

Which transactions did sales rep EN1-22 have on August 16, 2001?

The Solution BookBiz le is a completed le of this activity. You can compare your results to this le.

to
DO

1. 2.

Open the BookBiz database.

4.

Give your query the title of MyBookSales

In st

NO

3.

Indicate that you want to see the Detail records.

ru c

DU

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 the BookOrders table, add the SalesId, Date, and Quantity fields. From the Books table, add the BookNumber and BookPrice fields.

346

PL

Microsoft Ofce Access 2003 Level 1

IC

AT

How much did each individual book order cost?

rE

How many sales transactions were recorded by the sales rep whose ID is EN1-22?

di tio n

5. 6.

Run the query. Next, suppose you want to view only a portion of the records. First, you want to view all of the orders that were for a quantity of 250 or greater. Use criteria to select just the records you want. Record the number of records that satisfy 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: _____________. Next, you want to know how many of the sales records for sales rep EN1-22 occurred on 8/16/2001. Enter the appropriate criteria. Record the number of records that satisfy this criteria: _____________. Save your revised query as MySelectBookSales and close it.

LESSON LABS

7.

8.

9.

to
DO

10. Run the query and, before closing it, save it as MyBookCosts

ru c

Lesson Labs

In st

NO

DU

11. Close the BookBiz database.

PL

IC

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

AT

E
347

Return to the querys Design view and add the Books table to the query. From the Books table, add the Title field to the design grid.

rE

Next, youll create a query that answers the question, How much did each individual book order cost? Create a query in Design view that includes the BookOrders table and the Customers table. Add the CustomerName, Quantity, and BookNumber fields to the design grid. Sort the query records by CustomerName. Run the query and view the results.

di tio n

Four records contain a quantity of 250 or greater, 12 records contain sales rep EN122, and two records satisfy the last criteria.

LESSON LABS

LESSON 5 LAB 1
Creating and Modifying Forms
Activity Time: 15 minutes Data Files: BreadBiz.mdb

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. Youll need to include customer information, as well as order details. Use the Form Wizard to quickly create a basic form and then modify the form you created.
The Solution BreadBiz le is a completed le of this activity. You can compare your results to this le.

2.

to
DO

3. 4.

Specify that you want to view the information in the form by Customers.

6. 7.

Save the modified form design and view the form. Close the form and close the BreadBiz database.

In st

NO

5.

Customize the appearance of the form by selecting, sizing, aligning, and moving controls.

ru c

DU

Use the Datasheet layout. Choose a form style you like. Save the form as MyCustomers and save the subform as MyOrderDetails Subform

348

PL

Microsoft Ofce Access 2003 Level 1

IC

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.

AT

1.

Open the BreadBiz database.

rE

di tio n

LESSON 6 LAB 1
Creating and Modifying Reports
Activity Time: 20 minutes Data Files: PersonnelBiz.mdb

LESSON LABS

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 view to make some modications to a report that focuses on the employee payroll.
The Solution PersonnelBiz le is a completed le of this activity. You can compare your results to this le.

2.

to
DO

Select the Tabular layout and Corporate style for the report. Name the report MyPhoneList Preview the report.

ru c

3.

4.

5.

Lesson Labs

In st

Suppose you already created another report and want to complete it by enhancing its appearance. In EmployeePay reports Design view, apply the Soft Gray AutoFormat to change the look of the report. 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 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. Change the format of the text control in the Page Footer section that contains the Date function from Short Date to Long Date.

NO

Close the report.

Add the following fields: FirstName, LastName, ParkingLot, and Phone. View your data by Employees. Group the report based on the ParkingLot.

DU

Sort by the FirstName field in ascending order.

PL

IC

In the upcoming days, the company parking lots are being repaved and youll need to notify employees by calling them as necessary. Use the Report Wizard to create a printed phone list report based on the ParkingLot query.

AT

E
349

1.

Open the PersonnelBiz database.

rE

di tio n

LESSON LABS

6.

Save the revised report as MyEmployeePay

Planning a Simple Human Resources Database


Activity Time: 10 minutes

1.

to
DO

In st

4.

Designate fields to be used as primary and foreign keys for each table.

NO

3.

Using the normalization guidelines, normalize your list of tables by moving, splitting, or adding fields as necessary. Include any additional fields that will be needed to uniquely identify each record in each table and to relate the tables together.

ru c

DU

350

PL

2.

After looking at the available sources of data and discussing this project with the various users and stakeholders, youve decided you need to include the following fields: Name, Address, City, State, Zip, WorkPhone, DateHired, Hours, PayRate, Health, ParkName, ParkFee, and DeptName. Using this field list, organize the fields into logical tables.

Microsoft Ofce Access 2003 Level 1

IC

Based on the assignment you have been given, write an appropriate statement of purpose for this database.

AT

The SolutionDatabaseDesign.doc le in the LessonLabSolutions folder is a completed le of this activity. You can compare your results after each step to this le.

rE

Scenario: You are responsible for designing your companys Human Resources database to track employees and their related information, including personal data, department, pay rate and benets, and parking lot assignment. Following the database design process, you need to create an appropriate design plan that includes a statement of purpose, a list of appropriate tables, and the elds in each table with primary and foreign key assignments.

di tio n

LESSON 7 LAB 1

LESSON 8 LAB 1
Creating a Database and Adding Tables
Activity Time: 15 minutes Scenario: You have a database design for a simple Human Resources database that stores information about employees, their pay and benets, parking lots, and departments. Using this design plan you now need to create the database and its related tables.

LESSON LABS

rE
NO T

to
DO

1. 2.

Create and save a new blank Access MDB file named MyHR.

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 the DeptCode field to 4. Use Design view to create a table named tblPayAndBenefits with the following specifications: An EmployeeID field with a data type of Number (Long Integer). An Hours field with a data type of Number (Byte). A PayRate field with a data type of Currency. A Health field with a data type of Text and a field size of 100. A ParkCode field with a data type of Number (Long Integer).

3.

Lesson Labs

In st

ru c

DU

PL

IC

The SolutionMyHR.mdb le in the LessonLabSolutions folder is a completed le of this activity. You can compare your results to this le.

AT

E
351

di tio n

LESSON LABS

4.

Use Design view to create a table named tblParking with the following specifications: A ParkCode field with a data type of AutoNumber. A ParkName field with a data type of Text and a field size of 50. A ParkFee field with a data type of Currency. 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. A DeptName field with a data type of Text and a field size of 30. Establish the appropriate relationships between the tables. Enforce referential integrity between them.

5.

6.

Streamlining Data Entry and Maintaining Data Integrity


15 minutes Data Files:

rE
NO T

LESSON 9 LAB 1
Activity Time:

to
DO

In st

The SolutionPersonnelOfce.mdb le, located in the LessonLabsSolutions folder, is a completed le of this activity. You can compare your results to the tblPayAndBenets table in this le.

1.

In the PersonnelOffice database, open tblPayAndBenefits and view the fields and records. Change the design of the table so that data entry is required in these three fields: EmpID, Dept, and Hours.

2.

ru c

Scenario: You have been asked to improve the PersonnelOffice database. You decided to start by modifying the design of the tblPayAndBenets table to streamline data entry and maintain data integrity. First, youll assign eld properties to several elds in the table. Then, using the Input Mask Wizard, youll add a new eld to this table to store social security numbers. To further facilitate data entry, youll also change the ParkingLotCode eld to a Lookup list by using the Lookup Wizard.

DU

352

PL

PersonnelOffice.mdb

Microsoft Ofce Access 2003 Level 1

IC

AT

di tio n

3.

Change the design of the table so that an entry in the Hours field is valid only if it is over 15. If a value of 15 or less is entered, display a text message that reads: Number of hours worked must be greater than 15. Change the design of the table so that the PayRate field has a default value of 11. In this same table, add a new Text field for SocialSecurityNumber. Use the standard input mask for social security numbers.

LESSON LABS

4.

5.

6.

Create a Lookup column for the ParkingLotCode field. Specify that the Lookup 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 ParkingLotCode field.

7.

In Datasheet View, enter values in a new record. Experiment by leaving some values null where they are required. Attempt to move to the next record and respond to the error messages, as necessary.

Finding Data with Filters and Joins


Activity Time: 15 minutes Data Files: GourmetShop.mdb

to ru c
DO NO

The SolutionGourmetShop.mdb le, located in the LessonLabsSolutions folder, is a completed le of this activity. It includes the nished queries for this activity

1.

Lesson Labs

In st

Scenario: 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 lters to display only the 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 from multiple tables so you will use query joins to display the products ordered with the 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.

Open the GourmetShop database. Open the tblProducts table.

DU

PL

IC

AT
353

LESSON 10 LAB 1

rE

di tio n

LESSON LABS

2.

Use a Filter By Selection to display only those products that are Salad Dressings. Remove the filter. Your results should include six records. 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. 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. Open tblOrders. Use an Advanced Filter to display orders by customer number 245 after 8/31/2001. Then remove all filters. Your results should include 13 records. Create a query named qselRepProducts that for each Order displays the Rep number, the Order Number, the Quantity, and the Product name. Create a query named qselGSCustomers that displays the OrderID, Quantity, and Customer names for each order that included a Grilling Sauce product. Your results should include 143 records.

3.

4.

5.

6.

7.

rE
NO T DU

to
DO

Creating Flexible Queries


Activity Time: 15 minutes

Data Files:

MusicShop.mdb

In st

Scenario: 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 the MusicShop database. You have decided to improve your queries by making them exible. First, you want to know how many students are registered for each course; and, beyond that, you want to see the top ve 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.
The SolutionMusicShop.mdb le, located in the LessonLabsSolutions folder, is a completed le of this activity. It includes the nished queries for this activity.

ru c

354

PL
Microsoft Ofce Access 2003 Level 1

IC

AT

LESSON 11 LAB 1

di tio n

1.

Open the MusicShop database. Review the tables to become familiar with the data they contain. Open qselCourseRegistration, which shows students who are registered for each course. In the query results, show the count of students registered for each course. Sort the datasheet so that the highest count is displayed first.

LESSON LABS

2.

3. 4. 5. 6. 7.

Display the records for only the top five courses according to the count value. Save the revised query as qselMyTop5Courses.

Open qselStudentRegistration which lists student information along with courses they are registered for. Change this into a parameter query that prompts for student ID. Save the revised query as qselMyStudentRegistration.

8. 9.

to
DO

Activity Time: 15 minutes Data Files: TrainingCenter.mdb

ru c

Scenario: 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, 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 nd a record.
The SolutionTrainingCenter.mdb le, located in the LessonLabsSolutions folder, provides examples of possible solutions for the main form and subform for this activity.

Lesson Labs

In st

NO

DU

Creating a Form that Combines Data from Two Tables

PL

LESSON 12 LAB 1

IC

AT
355

10. Test the query with sample student IDs (for example, 1640 or 4944).

rE

di tio n

LESSON LABS

1.

In the TrainingCenter database, use the Form Wizard to create a form with a subform. To create the main form use the Form Wizard. Select tblCourseSchedule as the data source and choose fields for the main form including CourseCode, StartDate, Instructor, and other relevant course data. Save the form as frmMyCourseSchedule. With your new form open in design view, create the subForm using the Subform/ Subreport Wizard. Select qselStudentAttendance as the data source and choose fields for the subform including LastName, FirstName, Address, HomePhone, and others as desired. Use the CourseScheduleID field as the link field. Save the subform as fsubMyStudentSubform. Enhance the appearance of the form by adding a title and using the line and rectangle tools to set off and group controls. Add a command button to search for a record and name it Find Record.

2.

3.

4.

5.

to
DO

20 minutes Data Files:

ClothesShop.mdb

In st

Scenario: You work for a small clothes manufacturing business and you use the ClothesShop database to 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 elds from the query and group the customers by state. Under each state, youll also want to show totals for quantity and order totals for that state. For convenience, youve been asked to show the quantity sold totals for each date at the end of this report.
The SolutionClothesShop.mdb le, located in the LessonLabsSolutions folder, provides an example of a possible solution for this activity.

ru c

NO

DU
Microsoft Ofce Access 2003 Level 1

356

PL

Activity Time:

IC

Customizing Your Reports

AT

LESSON 13 LAB 1

rE

di tio n

1.

Open the ClothesShop database. Use the Report Wizard to create a new report based on qselCustomerOrders query. Include all of the fields in this report. Rather than grouping by ProductID, group customers by State. Within each grouping, sort the customers by the OrderDate. Include summary values to total Quantity and OrderTotals.

LESSON LABS

2.

3. 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. Identify some of the things that you can improve about your data layout, depending on which report style you chose.

5.

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 whitespace and page breaks, as necessary, to improve the layout.

7.

rE
NO T

Using the Subform/Subreport Wizard, add a subreport to the Report footer that 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.

to
DO

Using Access Data in Other Office Programs


Activity Time: 15 minutes Data Files: ClothesShop.mdb

The SolutionMyTotals.xls, SolutionMyTotals.doc, and SolutionMyTotals.txt les, located in the LessonLabsSolutions folder, are completed solutions for this activity.

Lesson Labs

In st

Scenario: 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.

ru c

DU

PL

LESSON 14 LAB 1

IC

AT
357

di tio n

LESSON LABS

1.

Open the ClothesShop database and review the qselTotProdOrd query and rptTotProdOrd reports. Publish rptTotProdOrd with Word. Save the Word document as MyTotals.doc. Analyze the qselTotProdOrd query in Excel.

2. 3. 4. 5. 6.

Create a 3-D exploded pie chart as a new sheet. Save the Excel spreadsheet as MyTotals.xls.

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. Export the data in qselTotProdOrd to a text file. Delimit the data with a semicolon.

7.

rE to ru c In st
358

DO

NO

T
Microsoft Ofce Access 2003 Level 1

DU

PL

IC

AT

di tio n

GLOSSARY

action query A query that modies data in the underlying table or tables. Action queries perform an operation, rather than select data. append query A query that copies data from specic elds or complete records from one table to another. Combo Box control A form control that provides a combination of a text box and a list box. The list box is displayed only when the combo box opens. Command button A control that carries out a pre-dened function. Command buttons work like the buttons in many Windows dialog boxes and programs.

delete query An action query that removes records from a table that match selected criteria.

denormalization The act of combining data into one table that the normalization process indicated should be in two tables.

rE
NO T

to
DO

Control Wizards A group of wizards in Report and Form Design view used to create a list box, combo box, option group, command button, chart, subreport, and subform. cross-product query The results produced when two or more tables in a query have not been joined. Each record in table A is joined with every record in table B.

In st

data types The allowable values that can be stored in elds. database A collection of related information or data.

Glossary

ru c

eld properties Settings that you can modify to affect how a eld appears and behaves. Filter A feature of a table or form that temporarily limits the records displayed according to properties set by the user. Filter techniques include Filter By Selection, Filter Excluding Selection, Filter By Form, and Advanced Filter/Sort. foreign key A eld in one table that links to a primary key in another table. foreign key eld A eld used to connect related data in separate tables.

DU

control An object that is used to display data, allow user input, or perform an action.

PL

eld A category of information that pertains to all records.

IC

expression A combination of identiers, operators, and values that produces a result.

AT
359

exporting A means of outputting data and database objects to another database, spreadsheet, or le format, so another application can use the data.

di tio n

GLOSSARY

GLOSSARY
form An Access object used to manage data in a table. Form Design view window The design environment for making changes to a forms design. Group Footer section The report section printed at the end of each group. Group Header section The report section printed once at the start of each group. grouped controls 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 individual control as youre arranging controls or assigning properties. icon A button with a representative picture on it. main report A report that contains a subreport. normalization The act of separating data into multiple tables to help ensure maximum query and reporting exibility and as few data maintenance problems as possible. Office Links A tool available in Access that lets you publish Access objects in Word, analyze data in Excel, or merge a query or table with a Word document. option box group A type of form control that consists of a group frame containing option buttons, check boxes, or toggle buttons. outer join A join that selects all the records from one table and only those records from the second table where the values in the join eld match.

rE
NO T

to
DO

join A temporary relationship you create between two tables to construct a query.

ru c

In st

List Box control A form control that displays a list of values to choose from. Similar to a combo box, but it can display multiple rows. lookup list A list of values that you can choose from when entering data in a eld. main form A form that contains a subform. The main form represents the one side of the relationship, and the subform represents the many side.

DU

input mask A eld property that establishes a pattern that dictates how users can enter data into the eld.

primary key A eld or combination of elds containing a value that uniquely identies a record. query An Access object that displays data from one or more tables in an ordered manner. record A set of data about one person or thing. record grouping Arranging data in related groups. record sorting Arranging data in some meaningful order, such as alphabetical or numeric. relational database A database that stores information in multiple tables, and that can extract, reorganize, or display that information.

360

PL

Microsoft Ofce Access 2003 Level 1

IC

inner join A type of join that selects only those records from both tables that have matching values in the join eld. Also known as an equi-join.

prex A notation preceding an object name that indicates the object type.

AT

parameter query A query that prompts the user for additional criteria.

di tio n

GLOSSARY
Report Design view window The design environment for making changes to a reports design. Report Footer section The section printed once at the end of a report. section selector A box in the left of the section bar in Form or Report Design view. Select query A query that retrieves data from one or more tables and enables you to ask questions about the data. self-join A type of join that relates data in a single table to itself. A table is joined to itself based on a eld or combination of elds that have duplicate data in different records. subform A form contained within a main form. The main form represents the one side of the relationship, and the subform represents the many side. subreport A report inserted into another report. table A group of records stored in rows and columns. unique records A query property that when set to Yes will restrict the records returned to those that have unique values in all elds in the underlying tables or queries.

update query An action query that changes specied values in a table for all the records or for those records that match specied criteria. value A single piece of data.

rE
NO T

wildcard A symbol that enables the user to substitute a different character in order to provide criteria for pattern matching.

to
DO

templates Provide a database designed to hold a certain type of data on which you can base a new database.

unbound control Objects on a form or report that contain descriptive information such as the label of each eld of the report title, a rectangle, a line, a command button, or a picture. Unbound controls arent bound to a eld or expression.
Glossary 361

In st

top values A query property that enables the user to specify how many values to display in the datasheet. Only the designated number or percentage of the top values are included in the datasheet.

ru c

DU

PL

IC

AT

di tio n

unique values A query property that when set to Yes will restrict the records returned to those that have unique values in the elds in the query design grid.

NOTES

rE to ru c In st
362

DO

NO

T
Microsoft Ofce Access 2003 Level 1

DU

PL

IC

AT

di tio n

INDEX

A
Access environment, 5 Access objects, 8 action queries adding, 232, 236, 239 append queries, 230 creating, 231, 232, 235, 236, 239 dening, 229 delete queries, 231 identifying types, 231 update queries, 229 Additional Wizard, 263 adjusting line spacing, 291, 292 Advanced Filter/Sort technique, 192, 193, 196 aliases, 209 append queries, 230, 235, 236 arithmetic calculation, 63 arithmetic operator, 61 order of operation, 61 AutoForm, 72, 73 creating an, 75 AutoFormat, 113 AutoNumber eld, 158 AutoReport, 96 creating an, 96

In st

Between... And operator, 224, 227 blank databases creating, 152 blank values, 134 Boolean See: conditional operator business rules, 131

Caption control property, 285, 286 columnar form, 73 combo boxes, 254, 256 Command Button Wizard, 266, 267 command buttons, 266 adding, 267 creating, 266 comparison operator, 56 conditional operator, 56 adding to a query, 57 control, 82 aligning, 88, 91 modifying properties of a, 110 moving a, 89 selecting a, 82, 91 sizing a, 85, 91 spacing, 88, 91 control properties, 285, 286 control source, 307 Control Wizards, 245, 254, 256, 257, 262, 263, 279 controls adding a combo box, 256, 257 adding a list box, 256 adding an option box, 262, 263 combo box, 254 list box, 254 option box group, 255 creating, 152 criteria, 193, 194, 196, 225, 227 entering, 223, 224, 225, 227 using, 223, 224, 225, 227 cross-product queries, 201 Current Record Indicator, 12

rE
NO T

to
DO
D

calculated eld, 63, 108 Can Grow control property, 285, 286 Can Shrink control property, 285

Index

ru c

data creating an Excel chart, 317 exporting, 317, 321, 322, 323

DU

PL

IC

AT
363

di tio n

INDEX

INDEX
merging Access data with Word, 326 publishing Access data as Word document, 315 data relationships many-to-many, 164 one-to-many, 164 one-to-one, 163 data types, 13 database, 2, 152 creating, 152 opening, 9 relational, 2 viewing, 9 databases creating, 144, 145 determining its purpose, 122 eliminating potential problems, 133 existing data, 124 datasheet form, 73 Datasheet view, 12 Default Value eld property, 172, 174 delete queries, 231, 239 denormalization, 134 design enhancements, 278 Design view, 13 removing, 194 using criteria, 193, 194, 196 Force New Page property, 290 foreign key, 41, 42 foreign key elds, 140 form, 8, 18 columnar, 73 creating, 78 creating a, 72, 73, 75 datasheet, 73 Design view, 74 Detail section, 74 Footer section, 74 Header section, 74 justied, 73 modifying a, 91 navigating in, 19 tabular, 73 form control, 82 aligning, 88, 91 moving a, 89 selecting a, 82, 91 sizing a, 85, 91 spacing, 88, 91 Form Design toolbar, 245 Form Design view window, 245 Form Wizard, 73 creating a form, 78 layouts, 73 Format eld property, 172, 174 formatting palettes, 246, 248 Formatting toolbar, 245, 246, 248, 279 forms adding a command button, 267 designing, 246, 247, 248

rE
NO T
G H I

E
existing data reviewing, 124 exporting, 317, 321, 322, 323 expression, 61 Expression Builder, 62

to
DO

eld, 2, 12 Field list, 245, 279 eld name, 13 eld names, 132 eld properties, 13, 172, 174 modifying, 173, 174, 217, 220 setting, 173, 174, 217, 220 Field Size property, 158 lter removing a, 28 Filter By Form technique, 192, 193, 194 Filter By Selection technique, 192, 193, 194 Filter Excluding Selection technique, 192 lters creating an advanced lter/sort, 193 nding data, 193, 194, 196

ru c

In st

DU

Group Footer section, 291 Group Header section, 291 grouped controls, 247

Height control property, 285, 286 Hide Duplicates control property, 285

icon, 5 inner joins, 198, 202 Input Mask eld property, 177 Input Mask Wizard, 178, 179

364

PL

Microsoft Ofce Access 2003 Level 1

IC

AT

di tio n

INDEX
input masks adding, 179 creating, 179 dening, 177 office links sharing data, 314 one-to-many relationship, 164 one-to-one relationship, 163 option boxes, 255 option groups, 255, 262, 263 order of operation, 61 outer joins, 199, 202

J
join lines, 198, 206 creating, 201, 202, 209 joins, 198, 199, 205, 206, 208 changing the type, 201 creating, 201, 202, 209 dening, 198 removing, 201 query joins justied form, 73

K
Keep Together property, 290

L
Like operator, 223, 225, 227 list boxes, 254, 256 logical operator See: conditional operator lookup lists creating, 185 dening, 183 using, 185 Lookup Wizard, 185

to
R

M
Mailing Label Report Wizard, 307, 308 mailing labels creating, 307, 308 main forms, 269 main reports, 300 many-to-many relationship, 164 margin settings, 115 menu bar, 5 multiple parameter queries creating, 227 dening, 222

ru c

naming conventions, 9 navigation bar, 12 normalization, 133, 134

objects, 8

record, 2, 12 adding a, 22 calculation on groups of, 67 deleting a, 22 sorting, 25 updating a, 30 record grouping, 280, 281 record selector, 12 record sorting, 280, 281 record source, 307 records appending, 235, 236 deleting, 239 ltering, 193, 194, 196 grouping, 280, 281 sorting, 280, 281 updating, 231, 232 recordset

In st

Index

DO

NO

DU

PL

query, 8, 27 adding a calculated eld, 63 Select query, 50 Query Design toolbar, 51 query joins, 198, 199, 205, 206, 208 changing the type, 201 creating, 201, 202, 209 dening, 198

rE

parameter queries creating, 224, 225, 227 dening, 222 running, 224, 225, 227 prex, 28 primary key, 41, 42 primary keys, 139 setting, 154 prompt messages, 224 Properties dialog box, 245, 279

IC

AT
365

di tio n

INDEX
displaying a, 28 referential integrity, 165, 166 relational database, 2, 3 relational databases designing, 120 determining elds, 128 eliminating potential problems, 133 relationships between tables, 38 Relationships window, 38, 166 Remove Filter button, 194 removing, 201 report, 8 adding a calculated eld, 108 adjusting the margins of a, 115 AutoFormat a, 113 components, 104 creating a, 96, 98, 99 Design view, 104 modifying controls on a, 110 running a, 33 Report Design toolbar, 279 Report Design view window, 279 Report Footer section, 300 report pagination, 291, 292 Report Wizard, 98, 281 creating a report, 99 reports, 291, 292 adding elds, 295 moving controls, 295 summarizing data, 294, 295 troubleshooting, 291 using enhancements, 278, 285, 286 Required eld property, 172, 174 expanding a, 44 nding data in a, 44 Subform/Subreport Wizard, 270, 271, 301 subforms, 269, 270 adding, 271 creating, 270 subreports, 300 adding, 301 creating, 301 summary elds, 294, 295

rE
NO T
U V

to
DO

section selectors, 247 Select query, 50 creating a, 53 select query properties top values, 216 unique records, 216 unique values, 216 selection conditions adding, 57 self join, 209 self joins, 208, 209 statement of purpose, 122 subdatasheet, 43 collapsing a, 44

ru c

In st

DU

unbound controls, 247 unique records, 216 Unique Records eld property, 217 unique values, 216 Unique Values eld property, 217, 220 update queries, 229, 231, 232

Validation Rule eld property, 172, 174 Validation Text eld property, 172, 174 value, 2

366

PL

Microsoft Ofce Access 2003 Level 1

IC

AT

di tio n
T

tab order, 91 table, 2, 8 relationships, 38 table names, 132 Table Wizard, 155 tables creating, 153, 155, 157, 158, 160 creating relationships, 165, 166 designating a primary key, 139 enforcing referential integrity, 164, 165, 166 grouping elds, 130, 131 joining, 205, 206, 209 saving, 158 using an alias, 209 tabular form, 73 task pane, 5 templates, 145 creating a database, 144, 145 Text Align control property, 285, 286 toolbar, 5 toolbox, 107, 245, 279 top values, 216, 217 Top Values eld property, 217 troubleshooting, 291

INDEX
W
Width control property, 285, 286 wildcards, 223, 225, 227, 232 wizards, 153, 155 Additional, 263 Command Button, 266, 267 Control, 245, 254, 256, 257, 262, 263 Input Mask, 178, 179 Lookup, 185 Mailing Label Report, 307, 308 Report, 281 setting the primary key, 154 Subform/Subreport, 270, 271

Z
Zoom dialog box, 224

rE to ru c In st
Index

DO

NO

DU

PL

IC

AT
367

di tio n

NOTES

rE to ru c In st
368

DO

NO

T
Microsoft Ofce Access 2003 Level 1

DU

PL

IC

AT

di tio n

In st ru c
NO T DU PL IC AT E

DO

to rE

di tio n

You might also like