Access Level 1

397
Microsoft ® Office Access 2003 - Level 1 Reference Material Please Do Not Copy

Transcript of Access Level 1

Page 1: Access Level 1

Microsoft® OfficeAccess 2003 - Level 1

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 2: Access Level 1

Microsoft® Office Access 2003 -Level 1Re

fere

nce

Mat

eria

l

Plea

se D

o No

t Cop

y

Page 3: Access Level 1

Microsoft® Office Access 2003 -Level 1

Course Edition: 1.1

ACKNOWLEDGMENTS

Project TeamCurriculum 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

NOTICESDISCLAIMER: 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 warrantywhatsoever, including, but not limited to, the implied warranties of merchantability or fitness for a particular purpose. The name used in the data files for this course is that of a fictitious company. Anyresemblance to current or future companies is purely coincidental. We do not believe we have used anyone’s name in creating this course, but if we have, please notify us and we will change the name inthe next revision of the course. Element K is an independent provider of integrated training solutions for individuals, businesses, educational institutions, and government agencies. Use of screenshots,photographs of another entity’s product, or another entity’s product name or service in this book is for editorial purposes only. No such use should be construed to imply sponsorship or endorsement ofthe book by, nor any affiliation of such entity with Element K. This courseware may contain links to sites on the Internet that are owned and operated by third parties (the “External Sites”). Element K isnot 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.

Microsoft®

Corporation. All other product names and services used throughout this book may be common law or registered trademarks of their respective proprietors.

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 writtenpermission of Element K, 500 Canal View Boulevard, Rochester, NY 14623, (585) 240-7500, (800) 434-3466. Element K Courseware LLC’s World Wide Web site is located atwww.elementkcourseware.com.

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 andconditions 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 withoutpermission, please call 1-800-478-7788.

Microsoft® Office Access 2003 - Level 1ii

Part Number: 1631EBEE

Access 2004 is a registered trademark of Microsoft Corporation in the U.S. and other countries; the Microsoft products and services discussed or described may be trademarks of Microsoft

Copyright © 2004 Element K Content LLC. All rights reserved. Screenshots used for illustrative purposes are the property of the software proprietor. This publication, or any part thereof, may not be

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 4: Access Level 1

This logo means that this courseware has been approved by the Microsoft® Office Specialist Program to be among the finest available for learning Microsoft Access 2003. It also means that uponcompletion of this courseware, you may be prepared to take an exam for Microsoft Offices Specialist qualification.

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

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

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

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

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

iii

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 5: Access Level 1

Microsoft® Office Access 2003 - Level 1iv

NOTES

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 6: Access Level 1

MICROSOFT® OFFICE ACCESS 2003 -

LEVEL 1

LESSON 1 - AN OVERVIEW OF ACCESS 2003

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

Database Terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

B. Examine the Access Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

C. Open the Database Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

Access Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

Naming Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

D. Examine an Access Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

Table Datasheet View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

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

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

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

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

Contents v

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 7: Access Level 1

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

LESSON 5 - DESIGNING FORMS

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

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

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

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

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

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

Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82

Selecting Form Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82

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

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

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

LESSON 6 - PRODUCING REPORTS

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

AutoReport . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96

CONTENTS

Microsoft® Office Access 2003 - Level 1vi

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 8: Access Level 1

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

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

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

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

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

LESSON 8 - BUILDING THE STRUCTURE OF A DATABASE

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

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

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

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

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

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

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

LESSON 9 - CONTROLLING DATA ENTRY

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

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

CONTENTS

Contents vii

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 9: Access Level 1

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

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

LESSON 11 - CREATING FLEXIBLE QUERIES

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

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

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

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

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

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

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

LESSON 12 - IMPROVING YOUR FORMS

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

Form Design View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245

CONTENTS

Microsoft® Office Access 2003 - Level 1viii

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 10: Access Level 1

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

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

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

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

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

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

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

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

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

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

LESSON 14 - EXPANDING THE REACH OF YOUR DATA

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

CONTENTS

Contents ix

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 11: Access Level 1

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

APPENDIX A - MICROSOFT OFFICE SPECIALIST PROGRAM

APPENDIX B - MICROSOFT OFFICE SPECIALIST PROGRAM

LESSON LABS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343

SOLUTIONS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359

INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377

CONTENTS

Microsoft® Office Access 2003 - Level 1x

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 12: Access Level 1

ABOUT THIS COURSEMost organizations maintain and manage large amounts of information. One of the most effi-cient and powerful information management computer applications is the relational database.Information can be stored, linked, and managed using a single relational database applicationand its associated tools. In this course, you will be introduced to the concept of the relationaldatabase by using the Microsoft® Office Access 2003 relational database application and itsinformation management tools.

Managing large amounts of complex information is common in today’s business environmentand, if done properly, can provide any business an edge over the competition. However, mis-managed and lost information can cause you to fall behind. An implementation of the Access2003 database application can give your business that positive edge.

Course DescriptionTarget StudentThis course is designed for students who wish to learn the basic operations of the Access 2003database program to perform their day-to-day responsibilities, and to understand the advantagesthat using a relational database program can bring to their business processes. The Level 1course is for the individual whose job responsibilities include working with tables to create andmaintain records, locate records, and produce reports based on the information in the database.It also provides the fundamental knowledge and techniques needed to advance to more techni-cal Access responsibilities, such as creating and maintaining new databases and usingprogramming techniques that enhance Access applications.

Course PrerequisitesTo ensure the successful completion of Microsoft® Offıce Access 2003 - Level 1 we recom-mend completion of one of the following New Horizons courses, or equivalent knowledgefrom another source:

• Windows 2000 - Level 1

• Windows XP - Level 1

• Windows XP Professional - Level 1

• Windows XP Professional - Level 2

INTRODUCTION

Introduction xi

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 13: Access Level 1

How to Use This Book

As a Learning GuideEach lesson covers one broad topic or set of related topics. Lessons are arranged in order ofincreasing proficiency with Access 2003; skills you acquire in one lesson are used and devel-oped in subsequent lessons. For this reason, you should work through the lessons in sequence.

We organized each lesson into results-oriented topics. Topics include all the relevant and sup-porting information you need to master Access 2003, and activities allow you to apply thisinformation to practical hands-on examples.

You get to try out each new skill on a specially prepared sample file. This saves you typingtime and allows you to concentrate on the skill at hand. Through the use of sample files,hands-on activities, illustrations that give you feedback at crucial steps, and supporting back-ground information, this book provides you with the foundation and structure to learn Access2003 quickly and easily.

As a Review ToolAny method of instruction is only as effective as the time and effort you are willing to investin it. In addition, some of the information that you learn in class may not be important to youimmediately, but it may become important later on. For this reason, we encourage you tospend some time reviewing the topics and activities after the course. For additional challengewhen reviewing activities, try the “What You Do” column before looking at the “How You DoIt” column.

As a ReferenceThe organization and layout of the book make it easy to use as a learning tool and as an after-class reference. You can use this book as a first source for definitions of terms, backgroundinformation on given topics, and summaries of procedures.

This course is one of a series of New Horizons courseware titles that addresses MicrosoftOffice Specialist (Office Specialist) skill sets. The Office Specialist program is for individualswho use Microsoft’s business desktop software and who seek recognition for their expertisewith specific Microsoft products. Certification candidates must pass one or more proficiencyexams in order to earn Office Specialist certification.

Course ObjectivesIn 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.

INTRODUCTION

Microsoft® Office Access 2003 - Level 1xii

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 14: Access Level 1

• create and modify Access reports.

• follow the steps required to properly design a simple database.

• create a new database with related tables.

• control data entry by modifying the design of a table to streamline data entry and main-tain data integrity.

• find and retrieve desired data by using filters and joins between tables and within a singletable.

• create flexible queries to display specified records; allow for user-determined query crite-ria; 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 specific printlayouts such as mailing labels.

• use Access data in other applications, including Microsoft Word and Excel.

INTRODUCTION

Introduction xiii

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 15: Access Level 1

Microsoft® Office Access 2003 - Level 1xiv

NOTES

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 16: Access Level 1

An Overview of Access2003

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

You will:

• Define the relational database concept.

• Examine the Access 2003 program environment.

• Examine an Access database’s environment.

• Examine a table in an Access database.

Lesson Time45 minutesLESSON 1

LESSON 1

Lesson 1: An Overview of Access 2003 1

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 17: Access Level 1

IntroductionIn most businesses, working with large amounts of varying types of data is a dailyrequirement. Understanding the composition of databases—and, in particular, the Access rela-tional database program—will provide you with a foundation for using Microsoft® OfficeAccess 2003 to organize your data. In this lesson, you will receive an introduction to databaseconcepts, the Access database application environment, and an actual Access relationaldatabase.

With the Access relational database application installed in your business, you can organizeand manage the data you have been tracking on paper. However, with an understanding of therelational database concept and the Access program, you will know where to begin. Identifyingthe features of a relational database, becoming familiar with the Access program, and openingand navigating through an Access database will provide you with the knowledge to begin man-aging your data.

TOPIC AUnderstand Relational DatabasesThere are different types of databases, as well as applications that are sometimes mistakenlyreferred to as database programs. Understanding what a real database is and becoming familiarwith the terms used to describe a database is the first step to becoming a competent databaseuser. In this topic, you will be introduced to the relational database and the terminology thatdefines its components.

When an application, such as Access, is installed on your computer, it is very tempting to diveright in and start using the program. Gaining an understanding of the application you are aboutto use and being versed in its terminology is a much better starting point.

Database TerminologyLike many other computer programs, database applications have their own language. A few ofthe most common terms are listed in the following table.

Term MeaningTable A group of records stored in rows and columns.

Record A set of data about one person or thing.

Field A category of information that pertains to all records.

Value A single piece of data.

LESSON 1

Microsoft® Office Access 2003 - Level 12

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 18: Access Level 1

Relational DatabasesDefinition:

Simply put, a database is a collection of information. A relational database takes thatconcept one step further. A relational database is a file that stores information in mul-tiple tables. Each table stores one specific category of information. The relationaldatabase can access these tables and extract, reorganize, and display the informationcontained within them in many different ways without altering the original tablestructures.

A relational database offers several benefits:

• Flexbility

• Simplicity

• Ease of management

• Power

Example:A travel agent maintains two client tables. The first table contains information on thetime 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 areport listing their customers’ favorite vacation spots and the time of year they preferto travel. The report can be used to send promotions to clients at appropriate times. Allof this is accomplished without altering the original tables.

Figure 1-1: The relational database.

LESSON 1

Lesson 1: An Overview of Access 2003 3

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 19: Access Level 1

ACTIVITY 1-1Identifying a Relational Database

Activity Time:

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 examplesand characteristics of databases, particularly relational databases, will help you understandthese concepts.

What You Do How You Do It

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

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

3. Which of the following is representative of a relational database?

a) Note card

b) Library file system

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

c) Redundancy

d) Ease of management

e) Power

LESSON 1

Microsoft® Office Access 2003 - Level 14

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 20: Access Level 1

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

When you launch Access, you have not yet opened a real database; you’ve only opened theinterface 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 therooms. Unless you understand how to open and close the database files that hold your informa-tion, your relationship to the database is extremely limited. An understanding of the interfacethat performs these actions is essential to managing your information.

Access Environment ComponentsThe Access 2003 environment enables you to open existing databases and create newdatabases. There are three primary components of the application environment:

• The menu bar is where commands are displayed and executed.

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

• The task pane is where you can search for files and consult the Microsoft Office onlineproduct information.

Figure 1-2: The Access 2003 application environment.

LESSON 1

Lesson 1: An Overview of Access 2003 5

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 21: Access Level 1

ACTIVITY 1-2Examining the Access Environment

Activity Time:

10 minutes

Scenario:Access is installed on your computer. It’s now time to launch the application and explore itsbasic features.

What You Do How You Do It

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

Programs→Microsoft Office→Microsoft

Office Access 2003.

In Windows 2000, choose Start→Programs→Microsoft Access.

2. Examine the menus on the menu

bar.

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

b. In the File menu, point to New. When youpoint to an active command, Access high-lights the command.

c. In the File menu, point to Close. Becausethis command is inactive, nothing happenswhen you point to it.

Inactive items appear grayed out in all of themenus.

d. On the menu bar, display the other

menus and examine the choices.

e. Click a blank area of the screen to closethe open menu.

LESSON 1

Microsoft® Office Access 2003 - Level 16

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 22: Access Level 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 dis-play the tooltip.

Inactive buttons appear grayed out, as did theinactive 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 theAccess application?

a) New

b) Open

c) Save

d) Cut

e) Microsoft Office Access Help

f) Undo

g) Code

h) File Search

5. Navigate through the available task

panes.

a. On the toolbar, click the File Search but-

ton to display the Basic File Searchtask pane in which you can search for adatabase file.

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

the Home button to return to theGetting Started task pane.

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

d. On the toolbar, click the New button

to display the New File task pane.

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

the Back button to display the Basic FileSearch task pane again.

f. Click the Forward button to displaythe New File task pane.

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

LESSON 1

Lesson 1: An Overview of Access 2003 7

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 23: Access Level 1

TOPIC COpen the Database EnvironmentYou have opened the Access application and looked at a few of its most basic features. In thistopic, you will open an Access database and identify the components that make up thedatabase.

It is, of course, important to understand the relational database concept and the interface thatappears when you launch the Access program. You must also be familiar with the database filestructure within Access. Doing so will allow you to open the files that hold your data andemploy the tools to manage it.

Access ObjectsThe Database window displays the Access objects in the left pane. Access objects are the toolsthat are used to store and work with your data.

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

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

Object DescriptionTables Storage container for the data.

Queries Question that retrieves data from tables. Queries may be saved for reuse.Queries always display either record level output (list format) or sum-mary information (a query cannot display both detail and summary).

Forms Graphical interface used for data entry and/or displaying data and otherobjects.

Reports Screen output of data arranged in an order specified by the user.

LESSON 1

Microsoft® Office Access 2003 - Level 18

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 24: Access Level 1

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

Common Applications of Naming ConventionsSome, but not all developers use naming conventions at the field level. The two mostcommon naming conventions are the Leszynski naming convention and the Reddicknaming convention. Naming conventions are optional and the type of naming conven-tion utilized is strictly up to the user. The following table illustrates examples ofcommonly used naming conventions.

Object Prefix ExampleTable tbl tblSampleTable

Select Queries qry qrySampleQuery orqryselSampleQuery

Forms frm frmSampleForm

Subforms fsub fsubSampleSubform

Reports rpt rptSampleReport

Subreports rsub rsubSampleSubReport

How to Open and View an Access DatabaseProcedure Reference: Open and View a Database

To open and view a database:

1. Start Access.

2. Locate the database files.

3. Select the database file to open.

4. Click Open.

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

LESSON 1

Lesson 1: An Overview of Access 2003 9

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 25: Access Level 1

ACTIVITY 1-3Opening and Viewing an Access Database

Activity Time:

5 minutes

Data Files:

• Computers.mdb

Setup:Access is running. No files are open.

Scenario:A consultant has created an inventory database, Computers.mdb, containing information on allof the organization’s computers, including who uses them, in which department they are used,their manufacturer, their price, whether they are under warranty, and their tracking number. Byopening the database and viewing the data it contains, you hope to gain a better understandingof the company’s computer inventory.

LESSON 1

Microsoft® Office Access 2003 - Level 110

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 26: Access Level 1

What You Do How You Do It

1. In the Computers.mdb database, inthe Objects pane, verify that the

Tables object is highlighted and

examine the table objects.

a. On the Getting Started task pane, click

the Open link.

b. From the My Documents folder, locate

and double-click Computers.mdb to openthe database and display the Databasewindow.

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.

e. In the right pane, examine the list of

objects. At the top of the list are thetools to create tables, followed by the listof existing tables in the Computers.mdbdatabase.

2. Display the queries, forms, and

reports in the Computers.mdb

database.

a. In the Objects pane, select Queries. Theright pane displays a list of query creationtools and queries stored in the Computers.mdb database.

b. In the Objects pane, select Forms. Theright pane changes to display a list ofform creation tools and the forms storedin the database.

c. In the Objects pane, select Reports. Theright pane displays report creation toolsand a report stored in the database.

LESSON 1

Lesson 1: An Overview of Access 2003 11

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 27: Access Level 1

3. In the left pane, collapse and

expand the Objects listing.

Groups is an advanced feature discussedin a future course.

a. In the left pane, click Groups to collapsethe 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 itperforms.

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

TOPIC DExamine an Access TableYou have toured the Access interface and viewed an MDB database file where your informa-tion, and the Access objects used to manage it, are stored. Now you will open an Access tableto view some of the data that populates the database.

Understanding the application interface and the structure of the database files is like knowingthe 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 thevaluables. Opening an Access table that contains your information and using the Access pro-gram’s views to work with the tables is like having the keys to the safe deposit boxes.

Table Datasheet ViewDatasheet view is the default view a user sees when opening a table or using a query. The datais 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 recordto copy or delete.

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

LESSON 1

Microsoft® Office Access 2003 - Level 112

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 28: Access Level 1

Figure 1-4: Table displayed in Datasheet view.

Table Design ViewDesign view is displayed when the user clicks the View button when a table is open inDatasheet view. In Design view, the user is looking at the components that make up the tablefrom a developer’s perspective. Field names, data types, and field properties are set, defined,and described within the Design view.

Figure 1-5: Table displayed in Design view.

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

LESSON 1

Lesson 1: An Overview of Access 2003 13

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 29: Access Level 1

ACTIVITY 1-4Comparing Datasheet and Design Views of an AccessTable

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 under-standing of the differences between those views. By viewing the tblEmployees table inDatasheet view and then in Design view, you can see the differences.

What You Do How You Do It

1. Open the tblEmployees table. a. In the Database window, with Tablesselected, double-click tblEmployees.

LESSON 1

Microsoft® Office Access 2003 - Level 114

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 30: Access Level 1

2. Using the Tab and arrow keys, themouse pointer, and the table’s navi-gation bar, move through the

tblEmployees table.

a. Press the Tab key three times to movethrough the fields in the table.

b. Hold down the Shift key and press Tab

three times to move back through thefields.

c. Press the arrow keys to move around thefields in the table.

d. Click the record selector (the gray left

column) of EmployeeID 0036 to selectAndrea Brown’s entire record.

e. In the Record Navigation bar at the bot-tom of the table, click the First Record

button to select the first record inthe table.

f. In the Record Navigation bar, click the

Next Record button to select thesecond record in the table.

g. In the Record Navigation bar, click the

Last Record button to select thelast record in the table, EdwardBernstein’s record.

3. Display the tblEmployees table in

Design view and examine the prop-

erties of the EmployeeID field.

a. On the far left of the table datasheet’stoolbar, click the View button todisplay the tblEmployees table in Designview.

b. Click the table window’s Maximize but-

ton to maximize the display.

c. Press the down arrow to move to thenext field and observe the change in theproperties in the lower panel.

d. Press the down arrow again to move tothe next fields and observe the propertiesin the lower panel.

e. Press the down arrow a final time tomove to the last field and observe theproperties in the lower panel.

f. In the upper pane, select the EmployeeID

field.

LESSON 1

Lesson 1: An Overview of Access 2003 15

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 31: Access Level 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. a. Choose File→Close to close the table.

b. Choose File→Close to close the database.

Lesson 1 Follow-upIn this lesson, you were introduced to the composition of databases and the Access relationaldatabase program. In addition, you opened and briefly examined the Access database applica-tion environment and an Access relational database.

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

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

LESSON 1

Microsoft® Office Access 2003 - Level 116

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 32: Access Level 1

Managing Data

Lesson Objectives: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 different criteria to sort the records in a table.

• Use Select queries to display recordsets.

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

• Run a report to display a table’s records in a report format.

Lesson Time45 minutesLESSON 2

LESSON 2

Lesson 2: Managing Data 17

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 33: Access Level 1

IntroductionUnderstanding the Access environment is the first step in managing the information in thedatabase. Knowing how to use the data management tools that are provided with the applica-tion is the next step. In this lesson, you will work directly within a table to manage the table’sdata, then move out of the table and use forms, queries, and reports to indirectly manage thesame data.

The most important component of a relational database is the table, where your information isstored. Knowing how to use the other components of a database will allow you to reap thebenefits of your database and ensure that you have more time to spend on your otherresponsibilities.

TOPIC AExamine an Access FormNow that you have worked in the Access environment, it is time to begin using the data man-agement objects provided by Access. In this topic, you will examine an Access form, an objectthat allows you to locate and manage individual records.

You have opened, examined, and toured a table. Now, imagine a table with thousands ofrecords and each record containing multiple fields. Moving about the table to locate andmodify a single field in an individual record could be a challenging task. The Access formobject simplifies the process by allowing you to manage data through a graphical userinterface.

FormsDefinition:

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

When using a form, keep in mind that:

• The data is never stored in the form, the form only displays the data stored in thetable.

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

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

• In addition to displaying table data, forms can include calculations, graphics, andother objects.

LESSON 2

Microsoft® Office Access 2003 - Level 118

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 34: Access Level 1

Example:

Figure 2-1: A sample form.

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

Keystroke MovementTab, Enter, right arrow, downarrow

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

Shift+Tab, left arrow, uparrow

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

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

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

Home Pressing Home will move you to the first field of the record you are cur-rently in.

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

Ctrl+Home Pressing Ctrl+Home will move you to the first field in the first record ofthe table with which you are working.

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

LESSON 2

Lesson 2: Managing Data 19

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 35: Access Level 1

ACTIVITY 2-1Navigating in Access Forms

Activity Time:

5 minutes

Data Files:

• UseForms.mdb

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

What You Do How You Do It

1. On the toolbar, click the File Search

button and, in the task pane, open

the UseForms.mdb database, then

open the frmCustomers form.

a. On the toolbar, click the File Search

button.

b. In the Basic File Search task pane’s SearchText text box, type UseForms.mdb

c. Click Go.

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

then click the My Documents\

UseForms.mdb file.

e. Close the Search Results task pane.

f. In the Objects pane, select Forms.

g. In the Database window’s right pane,double-click frmCustomers to open theform and display the first record in thetblCustomers table.

2. How many fields are displayed in the form?

3. What field is highlighted by default?

LESSON 2

Microsoft® Office Access 2003 - Level 120

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 36: Access Level 1

4. How many records are in the table?

5. Move through the record’s 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 theCustomerName field.

b. Press the Tab key until the Postal Code

field is selected.

c. Press the Tab key one more time tomove to the second record in thetblCustomer table.

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

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

6. 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 recordselected, press Home to move to theCustomerID field.

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

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.

a. With the last field of the first recordselected, press Ctrl+End to move to thelast field in the last record in the table.

b. Press Shift+Tab to move to the Fax fieldin the last record.

c. With the Fax field of the last recordselected, press Ctrl+Home to return tothe first field in the first record.

LESSON 2

Lesson 2: Managing Data 21

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 37: Access Level 1

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 navigationbar located at the bottom of the form,click the Next Record button to move tothe second record.

b. In the navigation bar, click the Last

Record button to move to Record 14, thelast record.

c. While located in the last record, click the

Previous Record button to move toRecord 13.

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

TOPIC BAdd and Delete RecordsTwo of the most commonly performed database operations are the addition and deletion ofinformation. Generally, these are ongoing operations that are performed on a regular basis. Inthis topic, you will add new records to a table and delete existing records from a table.

Having current information in your database is one of the most important qualities of adatabase. A database that is incomplete or that contains outdated records is not a reliablesource of information. By conscientiously adding new records and deleting old ones, your tablewill provide reliable, up-to-the-moment information. It will also prevent the database frombecoming outdated.

How to Add and Delete RecordsProcedure Reference: Add a Record to a Table

To add a record and enter the data:

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

2. Enter the new record data.

3. Press Enter to accept the new record.

Procedure Reference: Delete a Record from a Table

To delete a record:

1. Select the record to be deleted.

2. Either press Delete or choose Edit→Delete.

LESSON 2

Microsoft® Office Access 2003 - Level 122

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 38: Access Level 1

ACTIVITY 2-2Adding and Deleting Records in a Table

Activity Time:

10 minutes

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 todetermine the most efficient method to complete those operations. By trying several techniqueswith the tblCustomers table, you can determine the most efficient method.

What You Do How You Do It

1. Add a new customer record to the

table.

a. In the frmCustomers form’s navigationbar, click the New Record button

to clear the form in preparation forentry of a new record.

b. In the blank form, enter the following

data:

• CustomerID: 21998

• CustomerName: Brave New Shop-pers

• Phone: (456) 777-6668

• Fax: (456) 777-6669

• Address: 39 Rosey Blvd.

• City: Camptown

• Region: NY

• Country: US

• Postal Code: 13355-0000

c. Close the form.

2. Display tblCustomers and view the

new record.

a. Display tblCustomers and locate the new

record.

LESSON 2

Lesson 2: Managing Data 23

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 39: Access Level 1

3. How many records are in the table?

a) 12

b) 13

c) 14

d) 15

4. Delete the Household Helper

record.

a. In tblCustomers, verify that the right

pointing Current Record Indicator is

located in the first record, Household

Helper.

b. Choose Edit→Select Record to highlightthe Household Helper record.

c. Choose Edit→Delete.

d. When prompted to verify the record dele-tion, click Yes to complete the operation.

5. Use the navigation bar to add a new

record to the table.

a. In the tblCustomers table’s navigationbar, click the New Record button.

b. Enter the following data:

• CustomerID: 21999

• CustomerName: Super Savers

• Address: 3669 Windy Way

• City: Coalville

• Region: UT

• Country: US

• Postal Code: 13365-0000

• Phone: (454) 888-6668

• Fax: (454) 888-6667

6. Close the table and the database. a. Close tblCustomers and the UseForms

database.

LESSON 2

Microsoft® Office Access 2003 - Level 124

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 40: Access Level 1

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

Viewing and locating specific records in a large table can be difficult and time-consuming. Tosimplify the process and reduce the time you spend searching, Access provides you with sev-eral techniques to assist you in sorting and locating the desired records.

How to Sort RecordsProcedure Reference: Sort Records in a Table

To sort the records in a table:

1. In the Database window, select Tables.

2. Open the table you wish to sort.

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

4. Sort the table:

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

• Or, choose either Records→Sort→Sort Ascending or Records→Sort→SortDescending.

ACTIVITY 2-3Sorting Records in a Table

Activity Time:

10 minutes

Data Files:

• SampleTables.mdb

Scenario:Your sales manager has learned that you have an abundance of information available at yourfingertips in the database and she would like to take advantage of it. She would like to knowhow many orders in the tblCustomers table of the SampleTables.mdb database have beenplaced by Zilinski’s Home Store and how many have been placed by Household Helper. Withthe Access sorting tools, you’ll accomplish this task in no time.

LESSON 2

Lesson 2: Managing Data 25

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 41: Access Level 1

What You Do How You Do It

1. From the SampleTables.mdb data-base, open the tblCustomers table.

a. Open the SampleTables.mdb database.

b. Open tblCustomers.

2. Locate the CustomerID numbers for

Household Helper and Zilinski’s

Home Store.

a. Locate the Household Helper record andrecord the CustomerID number

_________________. (It is the lowestnumber in the table.)

b. Locate the Zilinski’s Home Store recordand record the CustomerID number

_________________. (It is the highestnumber in the database).

c. Close the table.

3. Open tblOrders. a. Open tblOrders.

4. How is the table sorted?

a) By OrderID

b) By ItemNum

c) By Quantity

LESSON 2

Microsoft® Office Access 2003 - Level 126

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 42: Access Level 1

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 Records→Sort→Sort Ascending.

Examine the results; there are threeHousehold Helper orders at the top of thelist.

6. Sort the table in descending order,

displaying Zilinski’s 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 Records→Sort→Sort Descending.

There are 10 Zilinski’s Home Store ordersat the top of the list.

7. Sort the OrderID column in ascend-

ing order.

a. Click in any field in the OrderID column.

b. Click the Sort Ascending button on the

toolbar to sort the OrderID column inascending order, restoring it to its originalstate.

TOPIC DDisplay RecordsetsSorting the records in a table in ascending or descending order, based on the values in a field,is a very useful operation. However, there are times when you need to extract groups of relatedrecords, such as records with the same department name or range of values. In this topic, youwill use the Access query object to locate and display record groupings that meet a specificcriteria.

You have been asked to locate all employees whose pay rate is between $12.50 and $15.00 perhour in a table that has several thousand records. You know that doing this in a table’sDatasheet view will take longer than you have been given and there is a good chance youwould miss some. By using a query, which searches the table for records with values in thisrange, you can accomplish the task more quickly and accurately.

QueriesDefinition:

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

LESSON 2

Lesson 2: Managing Data 27

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 43: Access Level 1

Example:A valid query is a query that is located in the Queries list in the Database window. Itsname may begin with the qry prefix, but that is not a requirement. When selected andlaunched or double-clicked, it is set into action and the results of the query aredisplayed.

How to Display Sets of RecordsProcedure Reference: Display Sets of Records

To display a recordset:

1. In the Database window, select Tables.

2. Open the table you wish to sort.

3. In the table, locate and select a single occurrence of the value you wish to find.

4. Display the recordset:

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

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

Procedure Reference: Remove a Filter

To remove the filter:

1. Either click the toolbar’s Remove Filter button or choose Records→RemoveFilter/Sort.

ACTIVITY 2-4Displaying 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 Zilinski’s Home Store orders and a printoutof only the Household Helper orders. Using the sorting tools, you can group the orderstogether, but not pull them out of the table. Fortunately, the consultant who implemented yourapplication built a simple Select query to display the orders for Household Helper. So, byusing the Filter By Selection tool, you can display only the orders for each customer.

LESSON 2

Microsoft® Office Access 2003 - Level 128

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 44: Access Level 1

What You Do How You Do It

1. Use the Filter By Selection tool to

display the Household Helper order

recordset, and then view it in Print

Preview.

a. In the CustomerID column, place the

insertion point in any field with a 20151

value. This is the Household Helper Cus-tomer ID number.

b. From the toolbar, click the Filter By

Selection button to display therecordset of Household Helper orders.

2. 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 printedrecordset would appear.

b. Using the Zoom feature, click in the pre-

view to enlarge the display.

c. Press Esc to close the Print Preview win-dow and return to the table.

d. On the toolbar, click the Remove Filter

button to close the recordset displayand return to the tblOrders table.

3. Locate one of the Zilinski’s Home

Stores CustomerID fields and apply

a filter to display the recordset oftheir orders.

a. In the CustomerID column, place the

insertion point in any field with a 21965

value. This is the Zilinski’s Home StoresCustomer ID number.

b. From the menu, choose Records→Filter→Filter By Selection to display therecordset of Zilinski Home Stores orders.

4. Use Print Preview to display the

Zilinski’s Home Stores recordset.

Then, close the Print Preview win-

dow and remove the filter to closethe recordset and return to thetblOrders table.

a. Choose File→Print Preview and size the

display to the screen to preview how theprinted page would appear.

b. Press Esc to close the Print Previewwindow.

c. Choose Records→Remove Filter/Sort toview all the records.

LESSON 2

Lesson 2: Managing Data 29

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 45: Access Level 1

5. Close the open table without sav-

ing, display the Queries objects,

and select the

qryHouseholdHelperOrders query.

a. Close the tblOrders table. Click No whenprompted to save the changes.

b. With the SampleTables Database windowopen, in the Objects pane, select Queries

to display any existing queries.

c. Examine the right pane and verify that

the qryHouseholdHelperOrders query is

present.

d. In the right pane, double-click the

qryHouseholdHelperOrders query to runthe query and display the recordset ofHousehold Helper orders. You will noticethat it was not necessary for any of thetables to be open when the query wasrun.

e. Close the recordset.

TOPIC EUpdate RecordsIn the previous topics, you used a form to view data and a filter to display specific data. In thistopic, you will use the form and query objects together to locate, edit, and update the recordsin a table that meet specific criteria.

There is little doubt that you will be continually changing and updating records in yourdatabase. The more efficiently you can perform operations, the more time you will have forother responsibilities. By using a query and a form in combination, you will be able to quicklylocate the records you need and, when possible, display them in edit mode.

How to Update RecordsProcedure Reference: Update Records

To update a record:

1. In the Database window, in the Objects pane, select Tables.

2. From the list of tables, open the table you wish to update.

3. Locate the field with the information that requires updating.

4. Select the value of this field and modify the data.

5. Press the down arrow or Enter to accept the changes.

LESSON 2

Microsoft® Office Access 2003 - Level 130

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 46: Access Level 1

6. Close the table.

ACTIVITY 2-5Updating Records

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 theSampleTables.mdb database. These include name, phone number, and ZIP Code changes. Thisis your first attempt at editing fields in a table and there are several editing techniques you canuse. By trying several, you can determine which work best for you.

What You Do How You Do It

1. In the tblEmployees table, change

Shelly Griffith’s ZIP Code from

72308 to 99336.

a. Open and maximize the tblEmployees

table.

b. Click in the EmployeeID field with a

value of 0057. This is Shelly Griffith’srecord.

c. Press Tab six times to highlight the ZIPCode.

d. With the ZIP Code selected, type 99336

Notice that the Current Record Indicator to thefar left changes to a pencil .

e. Press the down arrow. The Record Indi-cator returns to its original state and thechange is accepted.

LESSON 2

Lesson 2: Managing Data 31

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 47: Access Level 1

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 CarlBallantyne’s record.

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

Ballantyne.

c. Type i and delete the “y” to changeBallantyne to Ballantine.

d. Press the down arrow to accept the edit.

3. Change Lisa Fitzpatrick’s phone

number from (607) 555–3310 to

(585) 555–5595.

a. Position the insertion point in any field

in the LastName column.

b. Choose Edit→Find to display the Find AndReplace dialog box.

c. Verify that the following criteria are

selected:

• Look In: LastName

• Match: Whole Field

• Search: All

d. In the Find What text box, type

Fitzpatrick and then click Find Next tolocate Lisa Fitzpatrick’s record.

e. Click Cancel to close the Find AndReplace dialog box.

f. With the insertion point located in LisaFitzpatrick’s record, press Tab six times

to the HomePhone field and change the

value to (585) 555–5595

g. Press the down arrow to accept thechange.

LESSON 2

Microsoft® Office Access 2003 - Level 132

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 48: Access Level 1

4. Use the Find And Replace option to

change Lisa Fitzpatrick’s 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 Dia-log Box. Select the Replace tab.

c. With Fitzpatrick in the Find What textbox, type Fitzgerald in the Replace With

text box.

d. Click Find Next.

e. Click Replace.

f. Click Cancel to close the Find AndReplace dialog box.

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

h. Close the SampleTables.mdb database.

TOPIC FRun a ReportYou’ve used forms and queries to make working with table data easier and more efficient.You’ve even combined the skills to create an easy-to-use updating technique. Now it’s time toadd the finishing touch. In this topic, you will run a report that displays your data as a profes-sionally formatted presentation.

You have been invited to a sales meeting and asked to distribute a listing of company prod-ucts, organized by product line. This can be done by sorting the table or using different queriesfor each product line, but neither displays the data in a format you like. By running an Accessreport, you can produce a professionally formatted presentation you will be proud to distribute.

How to Run a ReportProcedure Reference: Run a Report

To run a report:

1. In the Database window, in the Objects pane, select Reports.

2. Run a report:

LESSON 2

Lesson 2: Managing Data 33

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 49: Access Level 1

• Double-click the report you wish to run;

• Or, select the report you wish to run and press Enter.

3. Click Close to close the report.

ACTIVITY 2-6Running a Report

Activity Time:

5 minutes

Data Files:

• UseReports.mdb

Scenario:The consultant who set up your Access database created several reports and stored them in theUseReports.mdb database so you could get started. You will eventually need to create yourown reports, and the consultant was kind enough to show you how to run the reports hecreated. By reviewing the tables that the reports pull data from, you can gain an understandingthat will prepare you to create your own reports.

LESSON 2

Microsoft® Office Access 2003 - Level 134

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 50: Access Level 1

What You Do How You Do It

1. In the UseReports.mdb database, run

the rptFinalReport report.

a. Open the UseReports.mdb database.

b. With Reports selected in the Objectspane, double-click rptFinalReport to runthe report.

c. Use the Zoom feature and size the

report so you can read it.

d. Move though the report, then return to

the top of the first page.

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

3. Record Rachel Middlebrook’s asset

tag, department number, and pur-

chase price.

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

b. From the entry, record the following

information:

• Asset Tag: ___________________

• Department Number:___________

• Purchase Price:_______________

c. Close the report.

LESSON 2

Lesson 2: Managing Data 35

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 51: Access Level 1

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 Middlebrook’s

department number in the report

matches the one in the table.

a. Open the tblEmployees table.

b. Locate Rachel Middlebrook’s record.

c. Locate the department number and

compare it with the number you

recorded to verify that they are thesame.

d. Close tblEmployees.

e. Close the database.

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

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

Lesson 2 Follow-upIn this lesson, you worked directly within an Access table to manage the table’s data. You thenused forms, queries, and reports to indirectly manage table data.

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

2. How would you display a recordset?

LESSON 2

Microsoft® Office Access 2003 - Level 136

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 52: Access Level 1

Establishing TableRelationships

Lesson Objectives:In this lesson, you will examine existing table relationships.

You will:

• Examine tables with established relationships.

• Identify a table’s primary and foreign keys.

• Examine and work with a table’s Subdatasheets.

Lesson Time45 minutesLESSON 3

LESSON 3

Lesson 3: Establishing Table Relationships 37

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 53: Access Level 1

IntroductionAs you have learned, the heart of any Access database is the table. Because Access is a rela-tional database, it allows the data in different tables to be connected. This is a powerfulconcept that allows you to make use of the data in various tables, as if they were in a singletable. In this lesson, you will learn how tables are connected and about an Access feature thatallows 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 andsearching for information in multiple tables can be time-consuming. However, Access allowstables to be connected and provides you with a feature that allows you to gather and summa-rize the information from the different tables in one convenient location.

TOPIC AIdentify Table RelationshipsUsing the form, query, and report objects, you have managed the records in a table. But work-ing with the data in a single table only scratches the surface of the Access program. BecauseAccess is a relational database, separate tables can be connected, allowing the user to makeuse of information in multiple tables. In this topic you will be introduced to tables with con-nections and launch a window with a visual display of the relationships.

Organizing complex data is the job of a relational database. For example, if your business hasfive product lines with 50 products in each line, organizing and displaying this in a single tablecould become overwhelmingly complex. By creating one table that holds information on theindividual products, then connecting it to the appropriate product lines in a second table, youcan manage any individual product in any product line in a simplified manner. Understandinghow tables are connected and how to display the connections will allow you to make full useof the relational concept.

Table Relationships and the Relationships WindowDefinition:

The purpose of relationships between tables is to link one set of information to anotherset of information.

Example:The Access Relationships window is a graphic display of these relationships. The linesthat connect the tables provide a visual indication of how the relationships work.

LESSON 3

Microsoft® Office Access 2003 - Level 138

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 54: Access Level 1

Figure 3-1: The Relationships window.

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 perspectivethe system is not visible. A satellite image displaying the highway connections wouldbe similar to that of the Relationships window, displaying the links between the tablesin a database.

ACTIVITY 3-1Using the Relationships Window to Identify TableRelationships

Activity Time:

5 minutes

Data Files:

• Computers.mdb

Scenario:If you could see a picture of how the tables are connected to one another it would help illus-trate how a relational database works. By launching the Computers.mdb database and openingthe Relationships window, a visual representation of the table connections will be displayed onyour screen. This is just what you are looking for.

LESSON 3

Lesson 3: Establishing Table Relationships 39

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 55: Access Level 1

What You Do How You Do It

1. Open the Computers database and

the Relationships window.

a. Open the Computers database.

b. On the toolbar, click the Relationships

button to launch the Relationshipswindow. This displays a graphic represen-tation of the links between tables.

c. If necessary, maximize the window and

resize the table displays so all of thetables and connections in the display arevisible.

2. According to the Relationships window, how many tables are connected in this data-base?

a) One

b) Three

c) Five

d) Seven

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

a) One

b) Two

c) Three

d) Four

4. How many have more than two links?

a) One

b) Two

c) Three

d) Four

LESSON 3

Microsoft® Office Access 2003 - Level 140

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 56: Access Level 1

5. In the Relationships window, to which table(s) is the tblNotes table linked?

a) tblComputers

b) tblDepartments

c) tblEmployees

d) tblManufacturers

e) tblNotes

TOPIC BIdentify Primary and Foreign Keys inthe Relationships WindowYou have launched the Relationships window and displayed the connections between the tablesin your database. There are field names that are bold and different symbols displayed at theend points of the connecting lines. In this topic, you will examine the properties of the indi-vidual links that connect the tables.

Much of the power of a relational database is derived from the ability to connect informationin different tables. The field is the point of connection. In order to establish the proper relation-ships, the connected fields have a differing status that is displayed in the Relationshipswindow. In order to access the information in the linked tables, you must identify the status ofthe keys that make up the table connections.

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

Primary Key CharacteristicsThe following list describes several characteristics and functions of primary keys:

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

• Table relationships with referential integrity cannot be set without establishingprimary keys.

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

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

LESSON 3

Lesson 3: Establishing Table Relationships 41

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 57: Access Level 1

How to Identify the Keys in Table RelationshipsProcedure Reference: Identify Primary and Foreign Keys

To identify primary and foreign keys in the Relationships window:

1. Open the database.

2. On the toolbar, click the Relationships button.

3. Observe the links and keys. At a link’s termination point (on either end), a boldfield name represents a primary key, and a non-bold field name represents a for-eign key.

ACTIVITY 3-2Identifying the Keys in Table Relationships

Activity Time:

10 minutes

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

Scenario:You wish to learn more about the links between the tables, what they mean, and how to readthem. To do so, you will review some examples and identify the different types of keys thatcomprise the links.

What You Do How You Do It

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

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

a) Primary key

b) Foreign key

c) Primary and foreign key

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

a) Primary key

b) Foreign key

c) Primary and foreign key

LESSON 3

Microsoft® Office Access 2003 - Level 142

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 58: Access Level 1

4. In the tblComputers–tblNotes relationship, in which table is AssetTag a primary key?

a) tblComputers

b) tblNotes

c) Neither

d) Both

A Primary key can consist of multiple fields.

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

b. If prompted, do not save your changes.

TOPIC CWork with SubdatasheetsUnderstanding how tables are linked and what the purpose of the primary and foreign keys arein a table lets you identify and evaluate the possible relationships between tables. This helpsyou comprehend what is going on behind the scenes if you are working in a table and access-ing the information in a table to which it is linked. In this topic, from an individual record in atable, you will launch a window that displays information from a linked table.

Understanding and knowing how Access tables are linked and evaluating the links betweentables is a great starting point. But, if you are working in one table and you need to view thedata in another linked table, how can you display it? The subdatasheet feature allows you tolaunch a window from any record that is linked to another table and display the data from thelinked table.

SubdatasheetsDefinition:

A subdatasheet is a datasheet that is nested within another datasheet and that containsdata related or joined to the first datasheet. The subdatasheet is launched and the datain the joined table is displayed when the plus sign in the left column is clicked. Theplus sign (+) in the first table is changed to a minus sign (–) when the subdatasheet isopened and then returns to a plus sign when the subdatasheet is closed.

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

LESSON 3

Lesson 3: Establishing Table Relationships 43

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 59: Access Level 1

Figure 3-2: A subdatasheet.

How to Find Data in SubdatasheetsProcedure Reference: Find Data in Subdatasheets

To expand and collapse a subdatasheet:

1. Open the table you wish to use.

2. Locate the record you wish to view.

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

4. Click the minus sign (–) to the left of the record to collapse the subdatasheet.

5. Close the table.

LESSON 3

Microsoft® Office Access 2003 - Level 144

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 60: Access Level 1

ACTIVITY 3-3Viewing Data in Subdatasheets

Activity Time:

5 minutes

Setup:The Computers.mdb database is open.

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

What You Do How You Do It

1. Open the tblComputers table and

locate the purchase price of Lynne

McMillan’s computer, and then

close the table.

a. Open the tblComputers table.

b. Attempt to locate Lynne McMillan’s com-

puter in the table. While the informationyou need is in there, there is no way toidentify it.

c. Close tblComputers.

LESSON 3

Lesson 3: Establishing Table Relationships 45

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 61: Access Level 1

2. Open tblEmployees, locate Lynne

McMillan, and record her Employee

ID number. Then, expand her

subdatasheet and record the pur-

chase price of her computer.

a. Open tblEmployees.

b. Locate Lynne McMillan’s record.

c. From tblEmployees, record her Employee

ID: _______________.

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

sign and expand the subdatasheet.

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

e. Record the computer’s purchase price:

_______________.

f. Close the table without saving changes.

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.

b. Locate Lynne McMillan’s employee ID.

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

c. Verify that the value in the

PurchasePrice field matches the value

you recorded from the subdatasheet.

The values displayed in the subdatasheet wereextracted from the tblComputers table.

d. Close tblComputers. If prompted, don’t

save changes.

e. Close the database.

LESSON 3

Microsoft® Office Access 2003 - Level 146

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 62: Access Level 1

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

Haygood’s record.

c. Click the plus sign in the left column todisplay the subdatasheet.

d. Locate Norman Grakowsky’s record.

e. Click the plus sign in the left column todisplay the subdatasheet, and notice thatall of the subdatasheets you’ve openedremain open.

f. Close tblEmployees and the Computers

database.

Lesson 3 Follow-upIn this lesson, you launched the Relationships window and displayed and examined the linksthat connect the tables in an Access database.

1. What window do you open to display the links between the tables in an Access data-base, and how are the links represented in the display?

2. What are the two types of keys that can be used to designate connections betweenlinked tables?

LESSON 3

Lesson 3: Establishing Table Relationships 47

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 63: Access Level 1

Microsoft® Office Access 2003 - Level 148

NOTES

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 64: Access Level 1

Querying the Database

Lesson Objectives: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 field to an Access query.

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

Lesson Time1 hour(s), 15 minutesLESSON 4

LESSON 4

Lesson 4: Querying the Database 49

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 65: Access Level 1

IntroductionIn a previous lesson, you were introduced to the tools used to manage table data. One of thetools was a query. A query is a question that searches a database for information matching aspecific set of conditions that you define. Queries can be developed and customized to yourneeds, then saved in the database and used whenever needed. This lesson will expand yourAccess knowledge to include creating and customizing queries.

Extracting data is another one of the most common operations performed on a database. Open-ing a table and searching through it one record at a time is inefficient, not to mention tiring.There’s also the potential of introducing errors into your results. By creating a query you willhave a customized, stored tool that can be used to accurately retrieve database information thatmeets specified criteria, whenever you need it.

TOPIC ACreate a Select QueryThere are several different types of queries. Some are quite restricted in what they can do andyou may not have a use for them at this point in your Access career. However, the most com-monly used query, and the one you have already seen, is the Select query. In this topic, youwill identify the different ways in which Select queries can assist you in performing your dailydatabase responsibilities. You will also use the Query Design Wizard to create a query.

If you are like most users, after you become comfortable with Access you will begin thinkingabout ways to improve your daily operations. Querying databases to locate and manage infor-mation is one of the most common tasks you perform. Having used existing queries, you havelikely thought of ideas for new queries that would make your life easier. By using the QueryDesign Wizard, you can create those custom queries and bring your dreams to life.

The Query Design EnvironmentA Select query is an Access object that selects and displays data that meets user-defined crite-ria from a table. The query may be viewed in Datasheet or Design view. When in Designview, the query’s structure, properties, and function may be modified.

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

LESSON 4

Microsoft® Office Access 2003 - Level 150

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 66: Access Level 1

The Query Design ButtonsThe following table describes a few of the buttons on the Query Design toolbar.

Icon Button Name DescriptionQuery Type Selects the query type.

Run Runs the query and displays the results.

Show Table Opens the Show Table dialog box.

Totals Adds the Totals row to the query inDesign view.

Properties Opens the query property sheet.

Build Launches the Expression Builder.

ACTIVITY 4-1Examining the Select Query Type

Activity Time:

5 minutes

Data Files:

• SelectQueries.mdb

Scenario:Your manager has asked you to find out which of the company’s computers aren’t covered bya warranty. You decide to use a Select query in order to quickly gather this information.

LESSON 4

Lesson 4: Querying the Database 51

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 67: Access Level 1

What You Do How You Do It

1. In the SelectQueries database, open

the qryNoWarranty query and

examine the datasheet, and then

switch to Design view.

a. Open the SelectQueries database.

b. With Queries selected in the Objectspane, double-click qryNoWarranty toopen the query.

c. Examine the datasheet. There are sevencomputers without warranties.

d. Click the View button to change toDesign view.

LESSON 4

Microsoft® Office Access 2003 - Level 152

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 68: Access Level 1

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 ofthe Warranty field, select No.

b. Replace it with Yes

c. Click the View button to return toDatasheet 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.

How to Create a Select QueryProcedure Reference: Create a Select Query

To create a query using the wizard:

1. In the Database window, in the Objects pane, select Queries.

2. Double-click Create Query By Using Wizard.

3. Select the first table (or query) you wish to include in the query.

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

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

6. Click Next.

7. Select whether you want to view detail or summary information.

8. Click Next.

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

10. Click Finish.

LESSON 4

Lesson 4: Querying the Database 53

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 69: Access Level 1

ACTIVITY 4-2Creating a Select Query

Activity Time:

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 fields in the tblComputers andtblManufacturers tables. By using the Query Wizard, you can create a query to locate and dis-play the required data.

What You Do How You Do It

1. Launch the Query Wizard. a. With Queries selected in the Objectspane, double-click Create Query By

Using Wizard.

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.

b. Click the right-pointing single arrow toadd the AssetTag field to the SelectedFields box.

c. In the Available Fields list box, select

DateReceived.

d. Click the right-pointing arrow.

LESSON 4

Microsoft® Office Access 2003 - Level 154

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 70: Access Level 1

e. In the Available Fields list box, double-

click 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, double-

click Manufacturer.

c. Click Next.

4. Verify that you want to see the

detail records and continue.

a. Verify that Detail is selected, and then

click Next.

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

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

b. Verify that Open The Query To View

Information is selected and click Finish.

c. In the toolbar, click the View button tochange to Design view. The two tables aredisplayed and are joined on theManufacturerID field. The fields youselected in the wizard are in the designgrid.

d. Close the query.

LESSON 4

Lesson 4: Querying the Database 55

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 71: Access Level 1

TOPIC BAdd Criteria to a QueryEven though you have now developed a Select query, the surface has just been scratched whenit comes to querying. In this topic, you will look at the comparison operators and conditionaloperators that are used in Access queries to make them even more useful.

Let’s say you have been asked to locate all of the records with an hourly rate of pay greaterthan $40 per hour, all of the records with work hours less than 30, and then a listing of therecords for employees who work less than 30 hours and whose pay is greater than $40 perhour. You know the information is in the database and that a query is the tool you need toextract it, but how do you do it? By incorporating comparison operators and conditional opera-tors into your query, you’ll be able to access this information.

Comparison OperatorsIncluding the comparison operators in an expression allows one data value to be comparedagainst another, using a set of criteria that has been defined by the user. (An expression is acombination of symbols that produces a result. You’ll learn more about them in the next topic.)

The Comparison OperatorsThe following table summarizes the comparison operators.

Operator Value Example= Equals = 11/29/1961

< Less than < K

<= Less than or equal to <= 2500

> Greater than > K

>- Greater than or equal to >- 2500

<> Not equal to <> Michigan

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

Is Null Null values Is Null (just using “Null” will alsowork)

Conditional OperatorsThe AND, OR, and NOT conditional operators, also referred to as logical operators andBooleans, add the ability to evaluate the truth of an expression, thus increasing its flexibilityand power.

The Conditional OperatorsThe following table summarizes the conditional operators.

LESSON 4

Microsoft® Office Access 2003 - Level 156

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 72: Access Level 1

Operator Description ExampleAND True if both conditions are true > 5 AND <> 100

OR True if either condition is true < 5 OR > 500

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

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

The Access query grid provides multiple rows in which one can identify what recordsare desired in the results. For example, if you wanted to select all the records where aprice field is greater than $100, you could type >100 in the criteria row that is belowthe price field. Using ANDs and ORs would allow you to expand or narrow the search.If you want to select all the records where the price field is greater than $100 ANDwhere the location of the sale is the state of California, you would add the word Cali-fornia to the criteria row below the State field. Both criteria should be placed on thesame line. This automatically creates an AND condition. An AND condition narrowsthe search, and the records that are selected must meet all the criteria in order to bereturned.

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 rowand across from the word or, to the left of the grid area, the query would return all therecords where the price field is greater than $100 as well as all records where the statefield is equal to California. Some prices may well be less than $100—but if they are inCalifornia, they meet the criteria. Some sales may be in Michigan, but as long as theyare over $100, they meet the criteria.

AND and OR criteria may also be typed directly in the same cell. For example, onecould type California or Michigan in a state criteria row to return all records fromeither state. Typing California and Michigan in a state criteria row would return norecords, because the value in the state field cannot be equal to both.

How to Add Selection Conditions to the QueryProcedure Reference: Add Selection Conditions to the Query

To add selection criteria:

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

2. Enter the first criterion in the Criteria row for the field.

3. To create an AND or OR condition on a single field, include the appropriate wordin the criteria.

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

5. To create an OR condition on more than one field, enter the other criteria in theOr row.

LESSON 4

Lesson 4: Querying the Database 57

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 73: Access Level 1

ACTIVITY 4-3Adding Selection Conditions to the Query

Activity Time:

10 minutes

Setup:The SelectQueries Database window is displayed.

Scenario:Comparison operators and conditional operators allow you to perform powerful searches, butcan be confusing. Practicing with the queries in the SelectQueries.mdb database and usingcomparison operators and conditionals to search for computers that meet specific price, depart-ment code, or manufacturer criteria, and even looking for Null or blank fields in records willfamiliarize you with the operation of these features.

What You Do How You Do It

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

2. How many records are displayed?

a) 11

b) 21

c) 23

d) 32

3. In Design view, use the > compari-

son operator in the PurchasePrice

field’s 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 andnote that six records satisfy the condition.

LESSON 4

Microsoft® Office Access 2003 - Level 158

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 74: Access Level 1

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 todisplay the field you use to set acondition.

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. Switch to Design view, and in the

Manufacturer field’s 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 Manu-

facturer field.

c. Type Atlas

d. Switch to Datasheet view.

e. Examine the results. Only two recordssatisfy this condition. By entering twoconditions on the same Criteria row in thedesign grid, you create an AND conditionand records must satisfy both conditionsto be displayed in the query datasheet.

6. Switch to Design view and delete

the existing condition in the Crite-

ria row of the Manufacturer field,

click in the Or row of the Manufac-

turer field and enter the

manufacturer name Cyber, and

then switch to Datasheet view to

run the query and examine the

results.

Remember that you can create AND andOR conditions for the same field byincluding those operators in the criteria.For example, if you wanted to know howmany Atlas and Cyber computers youhave, you can enter the criteria “Atlas orCyber.”

a. Switch to Design view.

b. In the Criteria row of the Manufacturerfield, delete the existing condition.

c. In the Manufacturer field, click in the Or

row.

d. Type Cyber

e. Switch to Datasheet view to run thequery.

LESSON 4

Lesson 4: Querying the Database 59

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 75: Access Level 1

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

a. Switch to Design view.

b. Delete the Cyber and 500 criteria.

c. Click in the Criteria row for the

DateReceived field.

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

e. Run the query and verify that six

records are displayed.

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.

a. Switch to Design view.

b. In the upper pane, right-click the

tblDepartments table.

c. Choose Remove Table.

d. Remove the tblManufacturers table fromthe query.

e. In the DateReceived field, delete the

criteria.

f. In the Criteria row for the ManufacturerIDfield, type Is Null

g. Run the query and note that there arethree records.

h. Save the query as qryMyMissingValuesand click OK.

i. Close the query window.

LESSON 4

Microsoft® Office Access 2003 - Level 160

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 76: Access Level 1

TOPIC CAdd a Calculated Field to a QueryThe ability to use Access comparison operators and conditional operators has greatly expandedyour querying capacity. Now let’s start using the values in a record to produce a result that isnot in the record. In this topic, you will use arithmetic operators to create a query to perform acalculation on a value in a record and then display the results of the calculation in the query’soutput.

Managing money is an important function in all businesses, and for that matter, in your day-to-day life. Imagine that your company’s payroll department wants you to calculate the weeklysalary for an individual who is paid by the hour. By including a calculated field that uses theemployee’s hourly rate, this is easily accomplished.

Arithmetic OperatorsArithmetic operators are used to perform operations on table data. The arithmetic operatorsused in Access are the same operators used by other programs and applications, and theybehave in a similar manner.

The Arithmetic OperatorsThe following table summarizes the arithmetic operators.

Operator Description Example Result+ Addition value1 + value2 Value1 is added to value2

- Subtraction value1 - value2 Value2 is subtracted from value1

* Multiplication value1 * value2 Value1 is multiplied by value2

/ Division value1 / value2 Value1 is divided by value2

Access ExpressionsSimply put, Access expressions are combinations of identifiers, operators, and values that pro-duce 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. Thecalculations are performed in a specific order, with the order of evaluation taking place fromleft to right. Precedence is dictated by the operators, in the following order:

1. Multiplication

2. Division

3. Addition

4. Subtraction

If a portion of the expression is enclosed in parentheses, that portion is evaluated first. If thereare nested sets of parentheses, the innermost set is evaluated first.

LESSON 4

Lesson 4: Querying the Database 61

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 77: Access Level 1

ACTIVITY 4-4Calculating Arithmetic Expressions

Activity Time:

5 minutes

Scenario:You have been asked to incorporate several calculations in your query. Practicing with order ofoperation in expressions will help you accurately incorporate the calculations.

What You Do How You Do It

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

a) 12

b) 14

c) 17

d) 19

e) 35

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

a) 35

b) 12

c) 19

d) 17

e) 60

The Expression BuilderThe Expression Builder is a tool that allows the user to select database objects and then, usingthe application’s built-in operators and functions, build formulas and calculations that are usedwith queries and reports.

LESSON 4

Microsoft® Office Access 2003 - Level 162

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 78: Access Level 1

Figure 4-2: The Expression Builder.

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

Component FunctionExpression box The location where the expression is built.

Operator buttons The location where the operators used in the expression areselected.

Left box Displays the table, query, form, report object, user-definedfunction, and other folders.

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

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

How to Add a Calculated Field to the QueryProcedure Reference: Add a Calculated Field to a Query

To add an arithmetic calculation:

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

2. Choose Build.

3. Using the operator buttons and the lists of fields and functions, select and pasteeach component of the expression.

4. Click OK to enter the expression in the design grid.

LESSON 4

Lesson 4: Querying the Database 63

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 79: Access Level 1

ACTIVITY 4-5Adding a Calculated Field to the Query

Activity Time:

10 minutes

Setup:The SelectQueries database is open.

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

What You Do How You Do It

1. Open the qryPayRates query in

Design view and run the query.

a. Right-click the qryPayRates query.

b. From the shortcut menu, choose Design

View.

c. Observe the design. It includes atblHoursAndRates table and will display alist of employees and their hours andrates.

d. Switch to Datasheet view to run thequery.

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 thatthe field name is added to the expressionand is enclosed in brackets.

e. In the operator bar, click the multiplica-

tion sign (*).

LESSON 4

Microsoft® Office Access 2003 - Level 164

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 80: Access Level 1

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

g. Click OK to close the Expression Builder.

h. Run the query.

3. What is Rob Abbott’s weekly pay?

a) 56

b) 250

c) 760

d) 2,500

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

4. Open the Zoom dialog box, change

the name of the calculated field to

WeeklyGross, and then run the

query.

a. Switch to Design view.

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

Lesson 4: Querying the Database 65

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 81: Access Level 1

e. Run the query to verify that WeeklyGrossis displayed as the column heading.

5. Switch to Design view, open the

Field Properties dialog box for the

WeeklyGross field and set the For-

mat property to Currency, and then

run the query.

a. Switch to Design view.

b. Right-click the WeeklyGross field and

choose Properties.

c. Click in the Format property box.

d. From the drop-down list, select

Currency.

e. Click the Close button to close the FieldProperties dialog box.

f. Run the query and observe that the cal-culated values are displayed in currencyformat.

6. Save the query as

qryMyWeeklyGross, and then close

it.

a. Save the query as qryMyWeeklyGross

b. Click OK.

c. Close the select query.

LESSON 4

Microsoft® Office Access 2003 - Level 166

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 82: Access Level 1

TOPIC DPerform a Calculation on a RecordGroupingYou now know how to use a query to perform a calculation on a single record. It is alsoimportant that you know how to perform a calculation based on a grouping of related records.In this topic, you will develop a query that selects a group of records and performs a calcula-tion using all of the values in one of the group’s fields.

One common, on-the-job use for Access is calculating payrolls by department. Developing aquery that groups employees by department and then performs a payroll calculation on thedepartmental grouping will provide the results you need, and as a bonus, you can save thequery and run it whenever necessary.

How to Perform a Calculation on a Group ofRecordsProcedure Reference: Perform a Calculation on a Record Grouping

To perform a calculation on a group of records:

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

2. Click the Totals button to display the Total row.

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

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

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

6. Run the query.

LESSON 4

Lesson 4: Querying the Database 67

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 83: Access Level 1

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

Activity Time:

10 minutes

Setup:SelectQueries.mdb is open.

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

What You Do How You Do It

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

2. Switch to Design view and, on thetoolbar, click the Totals button to

add the Total row to the design

grid.

a. Switch to Design view.

b. Click the Totals button .

c. Examine the Total row that has beenadded to the grid.

3. Remove the LastName and

FirstName columns from the design

grid.

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.

b. Press Delete.

c. Select and delete the FirstName column.

4. In the Total row for the WeeklyHoursfield, enter the appropriate sum-

mary function to calculate the

average weekly hours for each

department.

a. Click in the Total row for the

WeeklyHours field.

b. From the drop-down list, select Avg.

LESSON 4

Microsoft® Office Access 2003 - Level 168

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 84: Access Level 1

5. In the Total row for the WeeklyGrossfield, 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. 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.

b. Switch to Design view.

c. Right-click the WeeklyHours field and

choose Properties.

d. Click in the Format property box.

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

f. From the Decimal Places drop-down list,select 1.

g. Close the Field Properties dialog box.

7. Run the query, save the query as

qryMyTotals and close the

datasheet window, and then close

the database window.

a. Run the query.

b. Save the file as qryMyTotals and close

the datasheet.

c. Close the database.

LESSON 4

Lesson 4: Querying the Database 69

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 85: Access Level 1

Lesson 4 Follow-upIn this lesson, you created a query. Working in a query’s Design view, you also customizedqueries by adding comparison and conditional operators. You then used the Expression Builderto add a calculation to a field. 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 thequery?

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

LESSON 4

Microsoft® Office Access 2003 - Level 170

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 86: Access Level 1

Designing Forms

Lesson Objectives: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.

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

Lesson Time1 hour(s)LESSON 5

LESSON 5

Lesson 5: Designing Forms 71

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 87: Access Level 1

IntroductionYou have seen several different ways to manage data. On the job, you may be required to enterand update data on a regular basis. A custom form stored in your database that can be recalledeach 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 specific needs.

When opening a table in Datasheet view, the entire table, including all of the records andevery field in each record, is displayed. In large tables with thousands of records, this can beoverwhelming. Searching for individual records or fields can be time consuming, and thechance of making an error by misreading a value is increased. Creating a customized Accessform that allows you to view and edit one record at a time will expedite the process andreduce errors.

TOPIC AExamine Form Design GuidelinesYou have used a form to enter and edit data in a table. Although an unlimited number ofdesigns can be applied to a newly developed form, there are basic design principles that shouldbe applied regardless of the use. Any easy-to-use form with an efficient design will be appreci-ated by all. In this topic, you will identify some of the design principles that should be appliedto any form.

The form is one of the most often used data management tools. A well-designed form allowsthe user to view and enter data in a timely manner with a minimum of mistakes. Using thebasic form design principles, you can develop forms that help ensure an efficient and error-freedata entry process.

AutoFormsAn AutoForm is a one-click form creation tool that automatically creates a form displayingevery field in all records from the table or query on which it is based.

Figure 5-1: An AutoForm.

LESSON 5

Microsoft® Office Access 2003 - Level 172

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 88: Access Level 1

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

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

• By default, the AutoForm button places all fields from the underlying table orquery on the form.

• When launched with the New Object: AutoForm button, the final form displaysone record per page in what is called the columnar layout.

• When working with multiple tables and/or when only specific fields need to beshown from a table, a query should be created first. The AutoForm button can becreated from the query.

• The AutoForm option is also available from within the form object in the Data-base window by clicking the New button. This option allows the user to selectfrom multiple layout options.

The Form WizardThe 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.

• Can build a form based on more than one table.

• Offers design choices for both tabular and datasheet views.

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

Form Layout FeaturesColumnar • One record appears per page.

• Navigation buttons used to scroll through records.

• Field placement easily modified.

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

Tabular • Multiple records appear per page.

• Navigation typically done using the scroll bar.

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

Datasheet • Multiple records appear per page.

• Looks and feels like a spreadsheet to the user.

• Designer has minimal control over field placement and formatting.

Justified • One record appears per page.

• Navigation buttons used to scroll through records.

• Field placement is stacked, starting horizontally and then moving verticallywhen they do not all fit within the form’s width.

LESSON 5

Lesson 5: Designing Forms 73

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 89: Access Level 1

How to Identify the Form Design ViewWhen 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.

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

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

ACTIVITY 5-1Examining the Form Design Guidelines

Activity Time:

5 minutes

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

What You Do How You Do It

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

a) Your boss

b) Your co-worker

c) The user

d) The consultant

LESSON 5

Microsoft® Office Access 2003 - Level 174

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 90: Access Level 1

2. In Design view, which section of a form would typically contain page numbering infor-mation?

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

TOPIC BCreate a Form Using AutoFormNow that you have learned about some basic form design principles, imagine that you havebeen asked to immediately create a form to enter and edit data. Even knowing the design prin-ciples, developing the perfect form requires time, which you don’t have. Luckily, theAutoForm tool will allow you to create a usable form in a minimum amount of time.

Even the most experienced form designers need time to plan and create custom forms. Untilyou have experience developing your own forms, it will take even longer. Perhaps there is animmediate need for the form, or the form will be used on a temporary basis and you don’twish 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.

How to Create an AutoFormProcedure Reference: Create an AutoForm

To create an AutoForm:

1. In the Database window, in the Objects pane, select Tables.

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

3. Click the NewObject: AutoForm button.

4. Save the form.

LESSON 5

Lesson 5: Designing Forms 75

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 91: Access Level 1

ACTIVITY 5-2Creating a Form with the AutoForm Feature

Activity Time:

5 minutes

Data Files:

• UseForms.mdb

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

What You Do How You Do It

1. Open the tblCustomers table. a. With the UseForms database open, open

the tblCustomers table.

2. Create an AutoForm based on the

tblCustomers table.

a. On the toolbar, click the New Object:

AutoForm button .

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

4. True or False? New records can be added to the table with the AutoForm youcreated.

5. Close the form and save it as

frmMyCustomers.a. Click the Close button to close the

tblCustomers form.

b. Click Yes.

c. Type frmMyCustomers

d. Click OK.

e. Close tblCustomers.

6. Create an AutoForm based on the

tblEmployees table, with a link to

another table that includes a

subdatasheet display.

a. From the list of tables in the UseFormsDatabase window, select tblEmployees.

b. From the toolbar, click the New Object:

AutoForm button.

LESSON 5

Microsoft® Office Access 2003 - Level 176

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 92: Access Level 1

c. Examine the form.

This is a combination of a form and a subform. Therelationship between the two is similar to the rela-tionship between the datasheet and subdatasheetthat was discussed earlier in the course.

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

8. Expand the subdatasheet, and then

close the subdatasheet.

a. In the first record displayed in theAutoForm, click the expand indicator (+)

and notice that related data from a thirdtable is displayed.

b. Click the collapse indicator (-).

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.

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 horizontalsizing pointer is not displayed; the size ofthe datasheet must be adjusted in theform’s Design view.

Column widths in the datasheet can beadjusted by dragging the right edge of the col-umn heading.

LESSON 5

Lesson 5: Designing Forms 77

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 93: Access Level 1

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

close the form.

b. Close any open tables.

TOPIC CCreate a Form Using the Form WizardThe AutoForm feature, which is actually an Access wizard, is limited in the design of theforms it produces. The true power of using a form is derived from an interface that presentsdata in an easily understood format and provides the user with a virtually error-proof dataentry capability.

As the person in your business who has received training in Access, you may be looked uponas the resident Access expert and called upon to create custom forms for the users. With theAccess Form Wizard you will be able to accommodate the requests and develop forms thatdisplay only the information needed, in an easy-to-understand format that reduces data entryerrors.

How to Create a Form with the Form WizardProcedure Reference: Create a Form with the Form Wizard

To create a form with the wizard:

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

2. Double-click Create Form By Using Wizard.

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

4. Add the fields you want in the form to the Selected Fields list.

5. Repeat Steps 3 and 4 for any additional data sources and fields. Click Next.

6. If you have fields from more than one table, decide how you want the wizard toorganize them. Then decide whether you want subforms or linked forms for therelated data. Click Next.

7. Choose the form layout and click Next.

8. Choose the form style and click Next.

9. Enter a title for the form and, if necessary, the subform. Select the view in whichyou want to open the form.

10. Click Finish.

11. Close the form.

LESSON 5

Microsoft® Office Access 2003 - Level 178

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 94: Access Level 1

ACTIVITY 5-3Creating a Form with the Form Wizard

Activity Time:

10 minutes

Setup:The UseForms database is open.

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

What You Do How You Do It

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

b. Double-click Create Form By Using

Wizard.

2. Add all the tblEmployees fields to

the form, and then, from thetblComputers table, add the

AssetTag, DateReceived,

PurchasePrice, and Warranty fields.

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

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

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.

f. In the Available Fields list, select

DateReceived.

g. Click the right-pointing single arrow.

LESSON 5

Lesson 5: Designing Forms 79

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 95: Access Level 1

h. Add the PurchasePrice and Warranty

fields to the Selected Fields list.

i. Click Next.

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

a. Observe the preview of the form. Theview is by tblEmployees.

b. Select by tblComputers and observe thepreview.

c. Select by tblEmployees.

d. Verify that Form With Subform(s) is

selected and observe the preview.

e. Select Linked Forms and observe thepreview.

f. Select Form With Subform(s).

g. Click Next.

LESSON 5

Microsoft® Office Access 2003 - Level 180

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 96: Access Level 1

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.

d. Click Finish and examine the form.

7. Close the form. a. Click Close.

TOPIC DModify the Design of a FormAs with any creation, there are generally improvements that can be made. Imagine that youhave been asked by users to alter the order and alignment of some of the form’s controls, andchange the title of some of the labels. In this topic, you will modify the size, alignment, posi-tions, and labels of the controls on your form.

The form you created with the wizard is perfectly usable and fulfills its intended function. But,after using the form for a while, you’ve identified some possible changes in the design andseveral users have also offered helpful suggestions. A custom form can be seen as a livingobject; by modifying the design of your form it will become even more efficient and error-proof, and you will continue to enhance your reputation as the corporate Access expert.

LESSON 5

Lesson 5: Designing Forms 81

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 97: Access Level 1

ControlsDefinition:

A control is an object that allows the user to control the program. Controls are used todisplay data, allow user input, or perform an action. Controls are commonly used onforms and reports. Controls can be selected, sized, aligned, and moved to present aprofessional appearance. They generally are labeled with context-significant names sothat their purpose is easily identified by the user.

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

Figure 5-3: Examples of controls.

Selecting Form ControlsTo modify a form’s controls, they must first be selected. There are four methods of selectingcontrols:

• Click to select a single control.

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

LESSON 5

Microsoft® Office Access 2003 - Level 182

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 98: Access Level 1

ACTIVITY 5-4Selecting Controls

Activity Time:

5 minutes

Setup:The UseForms.mdb database is open.

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

What You Do How You Do It

1. Open the frmSelectControls form in

Design view and select the text box

control holding the CustomerName

field, and then select the label con-

trol for the field.

a. Open the frmSelectControls form in

Design view.

b. Click the text box containing the

CustomerName field. Note that the con-trol has selection handles on all sides.

c. Click the label control for the

CustomerName field. The label controlhas selection handles and the text box hasonly a move handle.

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

Lesson 5: Designing Forms 83

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 99: Access Level 1

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 controlshave selection handles.

c. Click a blank portion of the form todeselect the controls.

3. Use the click-in-ruler technique to

select the labels and text boxes,

observe the selection handles, and

then deselect the controls.

a. Click the vertical ruler at the 1.75-inch

mark and observe the selection handles.

b. Click a blank portion of the form todeselect the controls.

LESSON 5

Microsoft® Office Access 2003 - Level 184

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 100: Access Level 1

4. Using the ruler to select the labels

and text boxes, observe the selec-

tion handles and deselect the

controls.

a. Click at the 0.5-inch mark on the hori-

zontal ruler.

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.

c. Deselect the controls.

5. Using the Shift-click technique toselect controls, observe the selec-

tion handles and deselect the

controls.

a. Click the CustomerID text box.

b. Press and hold the Shift key, and then

click both the Fax text box and the

PostalCode text box.

c. Release the Shift key.

d. Click a blank area to deselect the

controls.

Sizing Form ControlsSizing controls to be proportionate to their use is a critical design component. There are threemethods of sizing controls:

• Drag a sizing handle to increase or decrease the size.

• From the menu, choose Format→Size→To Fit.

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

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

LESSON 5

Lesson 5: Designing Forms 85

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 101: Access Level 1

ACTIVITY 5-5Sizing Controls

Activity Time:

5 minutes

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

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

What You Do How You Do It

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

b. On the navigation bar, click the Next

Record button three times.

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

a) Address text box

b) Postal Code label

c) Postal Code text box

d) Region label

LESSON 5

Microsoft® Office Access 2003 - Level 186

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 102: Access Level 1

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

tal double-headed arrow and click and

drag the sizing handle to the left until

the text box is 0.5 inches wide. Viewand use the horizontal ruler to judge thewidth.

c. Click the Address text box.

d. Using the middle sizing handle on theright side, click and drag to make the

text box about 2 inches wide.

4. Size the PostalCode text box to fit

its contents.

a. Click the PostalCode text box.

b. Choose Format→Size→To Fit.

5. Make the CustomerID text box the

height of the CustomerName text

box, and then undo the sizing.

a. Click the CustomerID text box.

b. Press and hold the Shift key and click

the Customer Name text box.

c. Choose Format→Size→To Tallest.

d. Click the Undo button.

6. Make the Fax text box the same

size as the Phone text box.

a. Select the Fax and Phone text boxes.

b. Right-click one of the selected text

boxes.

c. Choose Size→To Narrowest.

LESSON 5

Lesson 5: Designing Forms 87

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 103: Access Level 1

7. Save the form as frmMyControls,and then view the form.

a. Choose File→Save As.

b. Save the form as frmMyControls

c. View the form.

Aligning and Spacing Form ControlsAligning controls and adjusting the spacing between them improves the appearance of a formor report. To do this:

• Select the controls you want to align and right-click one of them. From the shortcutmenu, 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 chooseeither Format→Horizontal Spacing or Format→Vertical Spacing. You can choose to adjustthe spacing by selecting Make Equal, Increase, or Decrease.

ACTIVITY 5-6Aligning and Spacing Controls

Activity Time:

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. Byusing alignment techniques you can improve the appearance.

What You Do How You Do It

1. With frmSelectControls open inDesign view, align the right side

label controls.

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 Align→Right.

LESSON 5

Microsoft® Office Access 2003 - Level 188

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 104: Access Level 1

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

nique to select the Phone and Fax labels

and text boxes.

b. Right-click a selected control and choose

Align→Bottom.

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 Format→Horizontal Spacing→Make Equal.

4. View and then save and close the

form.

a. View the form.

b. Save and close the form.

Moving Form ControlsIn 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 controlyou 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, themouse pointer should look like a hand with a single pointing finger .

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

.

LESSON 5

Lesson 5: Designing Forms 89

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 105: Access Level 1

ACTIVITY 5-7Moving Controls

Activity Time:

10 minutes

Setup:The UseForms database is open.

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

What You Do How You Do It

1. Move the CustomerName text box

closer to its label.

a. In the UseForms Database window, right-

click frmMoveControls and choose

Design View.

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 toplace it closer to the CustomerNamelabel.

2. Move the CustomerID label and text

box to the upper-left corner of the

form.

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.

LESSON 5

Microsoft® Office Access 2003 - Level 190

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 106: Access Level 1

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.

How to Modify a FormProcedure Reference: Modify a Form

To modify a form:

1. Display the form in Design view.

2. Select the controls you wish to work with.

3. Move the controls.

• If you want to move just the text box or label, and not its associated compo-nent, the mouse pointer should look like a hand with a single pointing finger.

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

4. Size the controls.

• Drag a sizing handle to increase or decrease the size.

• From the menu, choose Format→Size→To Fit.

• Select multiple controls, choose Format→Size, and choose whichever optionis appropriate.

LESSON 5

Lesson 5: Designing Forms 91

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 107: Access Level 1

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

5. Align the controls and adjust their spacing.

• Select the controls you want to align and right-click one of them. From theshortcut 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 andchoose either Format→Horizontal Spacing or Format→Vertical Spacing. Youcan choose to adjust the spacing by selecting Make Equal, Increase, orDecrease.

6. If necessary, adjust the tab order of the form fields.

a. In Design view, choose View→Tab Order.

b. In the Tab Order dialog box, click Auto Order.

c. Click OK.

7. Apply formatting to text boxes or labels.

8. Add a title or other descriptive text.

9. Change the size of the form.

10. Save your changes under an appropriate name.

ACTIVITY 5-8Modifying a Form

Activity Time:

10 minutes

Setup:The UseForms Database window is displayed.

Scenario:Your manager has asked you to improve the appearance of a wizard-created form using thedesign techniques you have learned. By applying these techniques to the frmGSCCustomersform, you will turn it into a professional looking creation your organization will be proud of.

LESSON 5

Microsoft® Office Access 2003 - Level 192

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 108: Access Level 1

What You Do How You Do It

1. Open the frmGSCCustomers form

and size the form to the screen.

a. Right-click frmGSCCustomers and choose

Design View.

b. Place the mouse pointer over the lower-

right corner of the form window until it

becomes an angled double-headed

arrow.

c. Drag down and to the right to enlargethe window.

d. Place the mouse pointer over the right

edge of the form until it becomes a ver-

tical line with a horizontal double-

headed arrow.

e. Click and drag the edge of the form to

the 6-inch mark on the right of the

ruler.

f. Place the mouse pointer over the bot-

tom edge of the form and drag the edge

down to the 3-inch mark.

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

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.

LESSON 5

Lesson 5: Designing Forms 93

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 109: Access Level 1

3. Switch to Form view and check the

tab order.

a. Switch to Form view.

b. Press the Tab key eight times to movefrom the first field in the form to the last.The Phone field would logically follow theCustomerName field in the form’s newlayout, but the tab order is based on theoriginal layout.

4. Return to Design view and correct

the tab order.

a. Switch to Design view.

b. Choose View→Tab Order.

c. In the Tab Order dialog box, click Auto

Order, and then click OK.

5. Return to Form view and check the

tab order.

a. View the form.

b. Press the Tab key to move through thefields. The tab order has been correctedto better suit the form’s new layout.

6. Save the form as

frmMyGSCCustomers, and then

close the form.

a. Save the form as frmMyGSCCustomers

b. Close the form, then close the database.

Lesson 5 Follow-upIn this lesson, you first created a simple AutoForm and then used the Form Wizard to create acustom form. You then selected, sized, aligned, and moved controls to modify the form tomeet your specific needs.

1. What is the primary difference between creating a form with the AutoForm featureand the Form Wizard?

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

LESSON 5

Microsoft® Office Access 2003 - Level 194

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 110: Access Level 1

Producing Reports

Lesson Objectives: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 field to the report.

• Modify the properties that set the appearance of a control.

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

• Adjust the width of a report.

Lesson Time1 hour(s)LESSON 6

LESSON 6

Lesson 6: Producing Reports 95

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 111: Access Level 1

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

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

TOPIC ACreate an AutoReportMuch like the AutoForm feature, AutoReport can be used to quickly create a simple report thatcontains all of the fields in a specific table. This topic will introduce you to the AutoReportfeature and how to use it to quickly create a simple report.

Designing a complex report requires time and planning. You will no doubt encounter situationswhen there is not the time for either. Or, perhaps the report will only be used once and there isno need to create the perfect report. Using the AutoReport tool you can create a report thatdisplays all of the fields for any given table.

AutoReportThe AutoReport feature allows the user to create a one-click report with a standardized format.It is almost instantaneous and often used when timeliness is a factor. The AutoReport feature:

• Launches with the toolbar’s New Object: AutoReports button and works directly with atable or query.

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

• Can make use of multiple tables.

• Is also available from within the Report Design Wizard for the three most common layouttypes (columnar, tabular, and justified).

How to Create an AutoReportProcedure Reference: Create an AutoReport

To create an AutoReport:

1. In the Database window, select the table or query on which you want to base thereport.

2. On the toolbar, from the New Object drop-down list, select AutoReport.

3. Save the report.

LESSON 6

Microsoft® Office Access 2003 - Level 196

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 112: Access Level 1

ACTIVITY 6-1Creating a Report with the AutoReport Wizard

Activity Time:

10 minutes

Data Files:

• UseReports.mdb

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

What You Do How You Do It

1. In the UseReports database, run the

qryInventory query and view the

results in Print Preview format.

Print the report.

a. In the UseReports database, double-click

the qryInventory query.

b. Click the Print Preview button.

c. Enlarge the preview to 100%.

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

both pages.

The ability to print will depend upon yourclassroom setup. Your instructor will adviseyou on this.

e. From the menu, choose File→Print and

click OK to send the output to theprinter.

f. Examine the printed output.

2. What features does the printed datasheet have?

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

LESSON 6

Lesson 6: Producing Reports 97

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 113: Access Level 1

4. Create an AutoReport. a. Close Print Preview. If necessary, reopenqryInventory in Datasheet view.

b. From the New Object: AutoForm drop-down list, choose AutoReport.

5. Examine the preview of the AutoReport.

How does the AutoReport compare to the printed datasheet?

6. Close the preview window and save

the report as rptMyAutoReport. Ifnecessary, close the report Design

window.

a. Close the preview window.

b. When prompted to save, click Yes.

c. In the Report Name text box, type

rptMyAutoReport

d. Click OK.

e. If necessary, close the report Design

window.

f. If necessary, close the qryInventory

query.

TOPIC BCreate a Report by Using the WizardLike AutoForms, the AutoReport feature is a wizard, also limited in the scope of the reports itproduces. Similar to using forms, the real advantages gained from reports lies in the customreport. The custom report can provide the business with a tool to evaluate past and presentactivities and to plan for the future. By using the Report Wizard, you can create custom reportsto 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 WizardThe Report Wizard is the recommended method for creating reports. The Report Wizard hasthe following features:

• It walks users through the report creation process with guided questions.

LESSON 6

Microsoft® Office Access 2003 - Level 198

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 114: Access Level 1

• It will build a report based on more than one table.

• It offers design choices, including the columnar, tabular, and justified views.

How to Create a Report with WizardProcedure Reference: Create a Report with the Wizard

To create a report with the wizard:

1. In the Database window, in the Objects pane, select Reports.

2. Double-click Create Report By Using Wizard.

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

4. Move the fields you want included in the report from the Available Fields list tothe Selected Fields list by using the arrow buttons.

5. Repeat Steps 3 and 4 for any additional data sources.

6. Click Next.

7. If necessary, choose the grouping levels and grouping options you want, and clickNext.

8. Select the sort order for the detail records and click Next.

9. Select the layout for the report and click Next.

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

11. Enter a title for the report and select whether you want the report displayed inPrint Preview or Design view.

12. Click Finish.

ACTIVITY 6-2Creating a Report with the Report Wizard

Activity Time:

15 minutes

Setup:The UseReports.mdb database is open.

Scenario:The Controller of your organization has asked for a report that lists, by department, the currentcomputer 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

Lesson 6: Producing Reports 99

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 115: Access Level 1

What You Do How You Do It

1. Start the Report Wizard. a. In the Database window, display Reports.

b. Double-click Create Report By Using

Wizard.

LESSON 6

Microsoft® Office Access 2003 - Level 1100

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 116: Access Level 1

2. From Query: qryInventory, select the

fields with which you will be

working.

a. With Query: qryInventory selected in theTables/Queries drop-down list, click the

right-pointing double arrow to move allthe available fields to the Selected Fieldslist.

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.

e. Click Next.

LESSON 6

Lesson 6: Producing Reports 101

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 117: Access Level 1

3. View some examples of the avail-

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

c. In the list of views, click By

tblManufacturers and view the sample.

d. Click Show Me More Information to dis-play the Report Wizard Tips.

4. Close the Report Wizard Tips, and

then choose tblDepartments and

continue through the wizard.

a. In the Report Wizard Tips dialog box, click

Close.

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

tblDepartments.

c. Click Next.

d. Since you don’t need any additional levelsof groups, click Next.

5. Sort the detail records in ascending

order, by asset tag number.

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

b. Click Next.

6. View the layout samples and apply

the Outline 1 layout.

a. In the Layout section, select each option

and view the sample.

b. Select Outline 1.

c. Click Next.

7. View the style samples and apply

the Corporate style.

a. In the list of styles, select each style and

view the sample.

LESSON 6

Microsoft® Office Access 2003 - Level 1102

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 118: Access Level 1

b. Select Corporate.

c. Click Next.

8. Enter a title of rptMyDepartmentsand preview your report.

When previewing a report, you can usethe Two Pages and Multiple Pages but-tons to get a big-picture look at thelayout of your report.

a. In the title text box, type

rptMyDepartments

b. Verify that Preview The Report is

selected.

c. Click Finish.

d. Use the scroll and navigation bars to

view all the data and pages.

9. Close the preview window and close

the report.

If you click Close on the Print Previewtoolbar, then the Design view of thereport will be displayed. Close that win-dow as well.

a. In the preview window, click the Close

button.

b. If necessary, close rptMyDepartments.

LESSON 6

Lesson 6: Producing Reports 103

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 119: Access Level 1

TOPIC CExamine a Report in Design ViewAs with forms, there are generally improvements that can be made to reports. Imagine that youhave been asked by users to alter the order and alignment of some of the report’s controls andchange the titles of some of the labels. In this topic, you will view the report in Design viewand 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 openedand viewed in Design view. A report is generally more complex to modify than a form.

Report Design ViewIf a professional presentation is your utmost consideration, then Design view may be the pre-ferred report creation method. However, regardless of how a report is created, the layout of areport can always be modified in Design view. An existing report can be opened in Designview in three ways:

• You can right-click the report in the Database window and choose 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.

How to Examine a Report Displayed in DesignViewProcedure Reference: Identify the Components of a Report in Design View

To identify the components of a report in Design view:

1. Select the report to examine.

2. Open the report.

3. Click the Design view button.

4. Examine the report.

5. Close the report.

LESSON 6

Microsoft® Office Access 2003 - Level 1104

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 120: Access Level 1

ACTIVITY 6-3Identifying the Components of a Report Displayed inDesign View

Activity Time:

10 minutes

Setup:The UseReports.mdb database is open.

Scenario:Knowing that you will be called upon to customize reports, you’ve decided to spend a littletime familiarizing yourself with how the report design determines final format. This way, youwill be prepared to create a report.

What You Do How You Do It

1. Open the rptDepartmentalInventory

report, view all the pages, and then

switch to Design view.

a. Double-click rptDepartmentalInventory.

b. If necessary, maximize the preview

window.

c. Use the navigation bar to view all pages.

d. On the preview window toolbar, click

Close.

e. Open rptDepartmentalInventory in

Design view.

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

Lesson 6: Producing Reports 105

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 121: Access Level 1

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 bydragging it by the title bar.

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.

This indicates that the control is a label that hasbeen named Title.

d. Select other controls on the report and

view the title bar of the properties dia-

log box.

6. Close the property sheet. a. In the properties dialog box, click the

Close button.

LESSON 6

Microsoft® Office Access 2003 - Level 1106

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 122: Access Level 1

TOPIC DAdd a Calculated Field to a ReportTo evaluate past and present business performance and make predictions on future businesstrends, the ability to perform calculations is often needed. These calculations can be includedin reports. In this topic, you will add a control to produce a calculated field in your report.

Imagine that you have been asked to produce a report that displays a payroll total for theResearch and Development department. You already have a report for this department that con-tains the salary amounts. By adding a control with a calculated field to your report you caneasily produce the requested result.

The ToolboxThe toolbox is composed of design tools used to add controls to reports and forms. The sametoolbox is used whether a form or report is being developed.

The Toolbox IconsThe following table displays most of the buttons in the toolbox.

Icon Tool Name Usage WizardLabel Adds text only. No

Text Box Adds a graphical box that can contain fields, expres-sions, and text.

No

Option Group Provides the user with option button choices, whichare buttons that can take on a variety of formats,from round circles to large rectangular boxes.

Yes

Toggle Button A graphical button indicating a true/false or yes/novalue.

No

Option Button This is similar to the option group, but each buttonoperates independently. It can be used to designatetrue/false values, or multiple option buttons could beused to simulate an option group with multiple selec-tions available.

No

Check Box A square graphic where a check mark represents atrue value.

No

Combo Box A graphical box that can contain fields, expressions,and text with a drop-down arrow showing additionalchoices.

Yes

List Box A graphical box that displays all the choicesavailable. It is similar to an option group but therecord source can be text.

Yes

Command But-ton

Used to place a button on the form, the button canbe programmed to perform an action.

Yes

LESSON 6

Lesson 6: Producing Reports 107

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 123: Access Level 1

Icon Tool Name Usage WizardImage Used to place a picture on the form or report. No

Unbound ObjectFrame

Used to place a variety of objects, including pictures,on a form or report.

No

Bound ObjectFrame

This is used to place an OLE object on a form orreport.

No

Page Break This inserts a page break wherever this control isplaced. Using the Page Down key on a form willmove the insertion point to the top of a page break.In a report, a page break will be inserted uponprinting.

No

Tab Control The Tab Control places a graphical object on a formor report that positions data within pages accessed bya tab. Tab Controls are most often used in forms tomaximize use of space.

No

Subform (or)Subreport

This is used to place a subform or subreport on aform or report object.

Yes

Line This places a straight line on the report. No

Rectangle This places a rectangular box on the report and canbe used to cluster similar fields together or toenhance the graphical display.

No

How to Add a Calculated Field to a ReportProcedure Reference: Add a Calculated Field to a Report

To add a calculated field:

1. Open the report in Design view.

2. If necessary, display the Toolbox by clicking the Toolbox button.

3. In the Toolbox, click the Text Box tool.

4. Click the report design surface where you wish to place the calculated control.

5. Click in the text box control to place the insertion point.

6. Type an equal sign (=) and the formula for the calculation.

7. Press Enter or click away from the control.

8. Save the report.

LESSON 6

Microsoft® Office Access 2003 - Level 1108

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 124: Access Level 1

ACTIVITY 6-4Adding a Calculated Field to a Report

Activity Time:

10 minutes

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

Scenario:You’ve created the report for the Controller using the Report Wizard. Now the Controllerwould like you to amortize the cost of the computers over three years and include that calcula-tion in the report. Adding a calculated field to the report will accomplish the amortizationrequest.

What You Do How You Do It

1. Add a control containing an amorti-

zation formula.

Note that when you place the text boxcontrol, it contains the word Unbound.This is because you have not yet desig-nated the contents of the control.

a. If necessary, on the Report Designtoolbar, click the Toolbox button

.

b. In the Toolbox, click the Text Box tool.

c. Click in the Detail section to the right of

the PurchasePrice control to add thecontrol.

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 reportdesign environment. You can also move the Toolbox by dragging it by the title bar.

LESSON 6

Lesson 6: Producing Reports 109

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 125: Access Level 1

2. Delete the default label for the con-

trol, 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 selectit.

b. Press Delete.

c. In the Toolbox, click the Label tool.

d. In the LastName Header section to theright of the PurchasePrice label, drag to

create the label control.

e. Type Amortized

f. In the Toolbox, click the Close button.

g. Click the Print Preview button.

3. Save your report as

rptMyInventoryReport and close

the preview window.

a. Save the report as

rptMyInventoryReport

b. Click Close to close the Print Previewwindow.

TOPIC EModify the Format Properties of aControlYou have added a control and a calculated field to your report and the resulting value is dis-played in the report’s output. You are not pleased with the default display of the value andwish to change it. By modifying the format properties of the control that performs the calcula-tion, you can change the value’s appearance.

Adding a control to a report can greatly enhance the output and the value it has to theorganization. However, the default properties, such as the formatting of output, are not alwayswhat is appropriate. By modifying the format properties of the control, you can produce thedesired presentation.

How to Modify a Control’s PropertiesProcedure Reference: Modify a Control’s Properties

To modify a control’s properties:

1. Open the report in Design view.

LESSON 6

Microsoft® Office Access 2003 - Level 1110

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 126: Access Level 1

2. Select the control and click the Properties button, or right-click the control andchoose Properties.

3. If necessary, in the property sheet, select the Format tab.

4. In the Format property box, from the drop-down list, choose the format you want.

5. Close the property sheet.

6. Preview the report to see the new format.

7. Save the report.

ACTIVITY 6-5Modifying a Control’s Properties to Change the Output’sDisplay

Activity Time:

10 minutes

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

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

What You Do How You Do It

1. Change the format of the new cal-

culated control to currency.

a. In the Detail section, select the control

containing the formula you entered.

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.

2. Change to Design view. In theReport Header section, select the

text box with the Now() function in

its control source and, from the For-mat drop-down list, select the Short

Date choice. Preview the report,

and then save the report.

a. Switch to Design view.

LESSON 6

Lesson 6: Producing Reports 111

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 127: Access Level 1

b. In the Report Header section, select the

control containing the Now() function.

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

d. Click Print Preview.

e. Return to Design view and save the

report.

TOPIC FAutoFormat a ReportWhen you ran the Report Wizard, you probably noticed a list of styles that you could choosefrom. Wouldn’t it be convenient if you could change from one report format to another withoutre-creating the entire report? The AutoFormat feature allows you to accomplish this. In thistopic, you will examine the different AutoFormat reports available and apply your selection toa report.

Imagine that you have created a report that is to be used by several different departments inthe organization. The contents of the report are just what they needed, but you have had sev-eral requests for different formats. This may seem to be a trivial matter, and you really don’twish to redesign the same report over and over. Using the AutoFormat feature, you can easilymodify the report’s format.

LESSON 6

Microsoft® Office Access 2003 - Level 1112

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 128: Access Level 1

How to Apply an AutoFormat Style to a ReportProcedure Reference: Apply an AutoFormat Style to a Report

To AutoFormat a report:

1. Open the report in Design view.

2. Choose Edit→Select Report, or click the Report Selector.

3. On the Report Design toolbar, click the AutoFormat button.

4. In the Report AutoFormats list box, select the new format.

5. Click OK.

6. Preview the report to see the new style.

7. Save the report.

ACTIVITY 6-6Applying an AutoFormat Style to a Report

Activity Time:

10 minutes

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

Scenario:You are not pleased with the format of the rptMyInventoryReport report. You could attempt toadjust a number of properties and controls, but time is critical. There is another possibility—the AutoFormat feature may provide the solution.

What You Do How You Do It

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.

a. In the property sheet dialog box, click the

Close button.

b. Click a blank area of the report to dese-lect all controls.

c. Choose Edit→Select Report.

d. On the Report Design toolbar, click the

AutoFormat button.

LESSON 6

Lesson 6: Producing Reports 113

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 129: Access Level 1

e. In the Report AutoFormats list box, select

the Bold format and observe the

preview.

f. Preview each of the remaining formats

and select the one you prefer.

g. Click OK.

h. Print Preview your report.

2. Switch to Design view. Save and

close the report.

a. Switch to Design view.

b. Click Save.

c. Click the Close button.

TOPIC GAdjust the Width of a ReportThere are times when a report contains so much information that the information to be dis-played 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.

Imagine you have been asked to produce a lengthy report for an important business meeting.When you run and print the report, you find that every other page is a blank page. This is cer-tainly not an acceptable format for the presentation. By modifying the report’s margin valuesyou can eliminate the blank pages.

LESSON 6

Microsoft® Office Access 2003 - Level 1114

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 130: Access Level 1

How to Adjust the Margin Settings on a ReportProcedure Reference: Adjust a Report’s Margin Settings

To adjust a report’s margins:

1. Open the report in Design view.

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

3. Calculate left and right margin settings that, when added to the report width, areno greater than the width of the paper.

4. Choose File→Page Setup and enter the Left and Right margin values.

5. Click OK.

6. Preview the report to check your results.

7. Save the report.

ACTIVITY 6-7Adjusting a Report’s Margin Settings

Activity Time:

15 minutes

Setup:The UseReports.mdb file is open.

Scenario:You’ve spent a lot of time perfecting your report and sent it off to the printer. When youpicked it up, every other page is mostly blank. Adjusting the margin settings will fix it.

What You Do How You Do It

1. Print Preview rptFixMargins, view-

ing two pages side by side.

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 alternatebetween the printed pages.

LESSON 6

Lesson 6: Producing Reports 115

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 131: Access Level 1

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.

a. In Design view, on the horizontal ruler,note the width of the report. It isapproximately 6.75 inches wide.

b. Choose File→Page Setup and note the

margin settings. Each margin is set to 1inch.

4. Why are these settings causing the blank pages?

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

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

b. Click OK.

c. Print Preview all pages of the report.

The blank pages have been removed.

d. Close Print Preview.

e. Save the file as rptMyFixMargins

f. Click the Close button.

6. Close the UseReports database and

close Access.

a. In the Database window, click the Close

button.

b. In the Microsoft Access window, click the

Close button.

LESSON 6

Microsoft® Office Access 2003 - Level 1116

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 132: Access Level 1

Lesson 6 Follow-upIn this lesson, you created an AutoReport and used the Report Wizard to create a report. Then,in Design view, you customized the report by adding a calculated field, modifying the formatproperties of a control, using the AutoFormat feature to change the report’s format, and adjust-ing the width of the report.

1. What kinds of reports will you create for your data?

2. What uses can you think of for calculated fields in your reports?

LESSON 6

Lesson 6: Producing Reports 117

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 133: Access Level 1

Microsoft® Office Access 2003 - Level 1118

NOTES

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 134: Access Level 1

Planning a Database

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

You will:

• List and describe the steps of the process involved in designing a relational database.

• Define the purpose of a new database.

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

• List the necessary fields for your database.

• Logically group your fields in tables.

• Apply database design principles to eliminate potential data maintenance problems.

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

Lesson Time40 minutesLESSON 7

LESSON 7

Lesson 7: Planning a Database 119

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 135: Access Level 1

IntroductionYou have data that needs to be stored in a database. You have used Microsoft® Office Access2003 databases before, but using a database and creating one are not the same thing. In thislesson, you will learn the basics of planning a new database, and in the next lesson, you willcreate a simple database.

Just as you wouldn’t attempt to build a house without a blueprint, you shouldn’t create a data-base without a plan. For a simple department intranet database, this design phase might nottake very long or require input from very many stakeholders. A large financial or HumanResources database, on the other hand, would require a lengthy planning phase with input fromnumerous groups in your organization.

TOPIC ADesign a Relational DatabaseIn order to create a new database effectively you should follow a plan—a process that includesall the phases necessary to create the best database for your needs.

With any complicated activity, following a well-defined process will help you to stay on track,include all the appropriate inputs, and produce the best possible output. Creating a new Accessdatabase is no different: only by following the phases of a good design process can you beassured that your database will do what you want it to and be easily maintained.

The Relational Database Design ProcessThe relational database design process is a simple process that can be used to produce a designplan for a relational database. It is composed of the following stages wherein you will: ]

1. Identify the purpose of the database.

2. Review existing data.

3. Make a preliminary list of fields.

4. Organize the fields into tables.

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

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

LESSON 7

Microsoft® Office Access 2003 - Level 1120

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 136: Access Level 1

Figure 7-1: The relational database design process.

DISCOVERY ACTIVITY 7-1Following the Relational Database Design Process

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 youwill use to create the database, so they can be confident in the final result.

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

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

Organize the fields into tables.

Make a preliminary list of fields.

Identify the purpose of the database.

Identify primary and foreign keys for use in relating the data in the tables.

Review the existing data.

LESSON 7

Lesson 7: Planning a Database 121

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 137: Access Level 1

TOPIC BIdentify Database PurposeThe first step in the design process is to determine what purpose you want the database toserve.

As with any activity, if you don’t have a clear purpose—a well-defined goal—then you run therisk of going off track: wasting time, doing too much or too little, or creating somethingentirely useless. Determining a clear statement of purpose for the database you are designingwill keep you on track and help reduce these risks. You can come back to it throughout thedesign process to help you answer questions that might arise.

Statement of PurposeDefinition:

A statement of purpose is a clear statement that defines the scope of a database andhelps to guide its design. It should imply the kinds of data that will be included in thedatabase, but not state specific table or field names. It can describe who the likelytypes of users of the database will be, but not state specific queries or reports theyintend to run. It is sometimes useful to include a statement of what the database willnot do.

Example:

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

LESSON 7

Microsoft® Office Access 2003 - Level 1122

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 138: Access Level 1

Non-Example:

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

DISCOVERY ACTIVITY 7-2Writing a Statement of Purpose

Scenario:In your new position as head of Information Management for The Green Supply Co., you’vedecided you want to create a custom database to track your company’s computers and whatemployees they are assigned to.

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

2. What is wrong with this statement of purpose: “The database will have tables for com-puters, personnel, manufacturers, product sales, salaries, and company suggestions.”

a) The statement of purpose should not attempt to list specific tables.

b) The statement of purpose is too broad.

c) There is nothing wrong with this statement of purpose.

LESSON 7

Lesson 7: Planning a Database 123

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 139: Access Level 1

3. What is wrong with this statement of purpose: “The database will allow the user togenerate reports that list the computers used by each employee, as well as queriesthat sort records by the date the computer was purchased and the manufacturer of thecomputer.”

a) It doesn’t discuss the scope of information to be included in the database.

b) It doesn’t mention or imply how its information will be related.

c) It discusses specific features (queries and reports) that you would like to seeprovided.

d) There is nothing wrong with this statement of purpose.

TOPIC CReview Existing DataNow that you know what you intend the database to do, you can start thinking about what datait will have to contain to fulfill that purpose. This is the second step in the design process.

Although you may think you know exactly what data should be included in the database youare designing, you’ll be surprised how often you’ll miss something. By considering pre-existing data sources (paper forms, spreadsheets of data, colleagues in your organization, andso on) you can reduce the risk of missing essential kinds of data for your database. You mighteven save time in collecting the data, by discovering that some of it is already in electronicformat.

Existing DataDefinition:

Existing data is information available for you to review that falls within the scope ofyour database as defined in your statement of purpose. This data can be in paper orelectronic 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.

Example: Existing Data in Paper FormatExisting data in paper format could include:

• Internal business forms or documents.

• Third-party or government forms or documents.

• Printed invoices, bills, or sales slips.

LESSON 7

Microsoft® Office Access 2003 - Level 1124

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 140: Access Level 1

Figure 7-4: Existing data in paper format.

Example: Existing Data in Electronic FormatExisting data in electronic format could include:

• Spreadsheets, such as Microsoft Excel.

• Word Processing documents, such as Microsoft Word.

• Other Databases, such as Access, SQL Server, or Oracle.

• Web pages.

LESSON 7

Lesson 7: Planning a Database 125

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 141: Access Level 1

Figure 7-5: Existing data in electronic format.

DISCOVERY ACTIVITY 7-3Gathering and Reviewing Existing Data

Scenario:The statement of purpose for your database is “The database will hold information on the com-pany’s inventory of computers and their assignment to employees.” In your search for existingdata, you find that the Receiving department fills out a ticket for each item that is delivered.See Figure 7-6.

LESSON 7

Microsoft® Office Access 2003 - Level 1126

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 142: Access Level 1

Figure 7-6: A sample Receiving ticket.

1. What pieces of data from the sample ticket do you think should be included in yourdatabase?

a) Date computer acquired

b) Manufacturer name

c) Asset tag number

d) Department of employee

2. What other sources of data might you use for determining what data should beincluded in the database?

LESSON 7

Lesson 7: Planning a Database 127

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 143: Access Level 1

TOPIC DDetermine FieldsFrom reviewing the existing data, you have a good start on your field list. You can completestep three in the design process by questioning potential users of the data about their expecta-tions and, specifically, what reports or summary information they would like. You can thenreverse-engineer that into specific fields of data.

You don’t want to spend a lot of time creating a database and designing beautiful forms andreports only to find out that they don’t meet the needs of the consumers of the information.You can prevent this by involving these people in the design and getting as much detail aspossible about their information needs.

Determining Additional FieldsWhen you appropriately determine additional fields, you will meet your users’ needs whilestaying within the scope of your statement of purpose.

Guidelines:When interviewing the potential users of a database to determine additional fields, besure to:

• State your database’s statement of purpose at the beginning of each conversationto help everyone stay focused.

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

— What sort of data do you expect the database to contain?

— What kinds of reports would you like to be able to generate from the data-base?

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

— What kinds of questions do you want the database to be able to easilyanswer?

If you are the only potential user of the database you are designing, then you will need to considerthese questions yourself. It is still an essential stage in the process and should not be skipped.

Example:You are designing a database for tracking enrollment of employees in benefit plans.You have reviewed existing data and now need to determine additional fields. In inter-viewing other members of the Human Resources department you begin by makingclear your statement of purpose. You then ask them what kinds of reports they willneed to run and what kind of summary information they will need to obtain. Theyhave indicated that they would like to know the number of employees enrolled in aparticular plan and how many have joined each plan during each month. As a result ofthese interviews you know that you will need to include EmployeePlan andPlanEnrollDate fields.

LESSON 7

Microsoft® Office Access 2003 - Level 1128

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 144: Access Level 1

DISCOVERY ACTIVITY 7-4Completing the List of Fields

Scenario:From the Receiving ticket and other sources you have been able to arrive at the following listof pre-existing data:

• Employee department

• Date received

• Asset tag number

• Manufacturer

• Note about each computer

The manager of Technical Services would like to get a weekly report of all new computersreceived and to whom they are assigned so she can arrange to set up the hardware; she wouldalso like to know if the system is covered by a warranty. The Finance manager would like amonthly summary of departmental computer hardware purchases.

1. What additional data will you need to include about each employee?

a) Name

b) Salary

c) Date of birth

d) Computers assigned

e) Manager of employee

2. What additional fields will you need to include in the database to enable the TechnicalServices manager’s weekly reports and the Finance manager’s monthly report?

a) Warranty coverage

b) Purchase price

c) Software games included

d) Number of current files on the computer

LESSON 7

Lesson 7: Planning a Database 129

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 145: Access Level 1

TOPIC EGroup Fields into TablesOnce you’ve identified the fields you need in the database, you can move on to step four ofthe design process and decide how to organize them into tables. That’s what you’ll work onnext.

As you know, tables are the heart of any Access database. They’re the objects that actuallystore your data and are what you use as the basis for queries, forms, and reports. While youcan change the design of tables after they’re created, it’s much less work to try to get the righttable design at the start.

Group Fields into TablesGrouping fields into tables will allow you to effectively relate information in your database.

Guidelines:Use these guidelines when grouping fields into tables:

• A table should hold information on only one subject.

• Don’t be concerned about having too many tables. It’s much more likely that youwon’t have enough.

• Try to identify tables that correspond to tangible objects such as people, physicalobjects, and so on. Such entities have properties that are likely the fields of thetable.

• For intangible subjects, try to identify a collection of logically related informationwith common characteristics.

If five different database designers followed the recommended design process for the same database, itis entirely possible they would arrive at five slightly different designs. This is because each individualcan have a different thought process and may make different assumptions along the way. That’s whythe standard design process is so important. It helps ensure that, whatever the details of the finaldesign, it will comply with good design principles.

Example: Employees and Benefit Plans TablesIn a database for tracking enrollment of employees in benefit plans, you have one tablefor employees and another for benefit plans. These are both entities that have relatedproperties. Each employee has a name, department, phone number, current plan, anddate of enrollment. Each benefit plan has a plan name, provider, benefits, anddescription.

LESSON 7

Microsoft® Office Access 2003 - Level 1130

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 146: Access Level 1

Example: Tables for an Ice Cream BusinessFor a database that holds information about the operation of an ice cream stand, youwould have an IceCream table with flavors and prices. If you sold sundaes as well ascones, you would have a Toppings table that includes the topping name and its addi-tional cost. Then, to associate ice cream and toppings in particular combinations, youwould have a Sundaes table with the name of the sundae and what combination of fla-vor and topping is used to make it.

Business RulesThe procedures and policies of a company represent its business rules, and these canaffect the design of a database. For example, if your company has an internal policythat computers are assigned to departments, rather than to specific employees, thiswould affect the way you design the tables in a computer inventory tracking database.As you look at existing data, talk to potential users, and group fields into tables, youshould be aware of company policies. If you don’t already know the pertinent com-pany policies, you should inquire about them.

LESSON 7

Lesson 7: Planning a Database 131

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 147: Access Level 1

Field and Table NamesAccess has constraints on field and table names. Names:

• Can be no more than 64 characters.

• Cannot include a period (.), exclamation point (!), an accent grave (′), brackets([]), or double quotation marks (“).

• Cannot have a leading space. (Access permits you to have spaces within table andfield names; however, if there is an internal space, you will have to enclose thattable or field name within brackets when you refer to it in expressions and otherplaces. So, you might want to get in the habit of not using spaces in table andfield names. One option is to use the underscore character in place of a space in afield name.)

Names should be brief but descriptive so that another user will know what they mean.Table names are usually plural.

DISCOVERY ACTIVITY 7-5Deciding on Computer Inventory Tables

Scenario:You’re continuing work on designing your computer inventory database, and you’ve decidedthat you need the following fields:

• Employee name

• Asset tag number

• Computer manufacturer

• Date received

• Computer note or comment

• Employee department

• Warranty coverage

• Purchase price

Now you need to group them into initial tables.

1. Based on the information you have now, which two tables would be minimally requiredfor this database?

a) Computers and Notes

b) Computers and Employees

c) Computers and Departments

d) Employees and Departments

LESSON 7

Microsoft® Office Access 2003 - Level 1132

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 148: Access Level 1

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, of them could go in a Computers table.

TOPIC FNormalize the DataOnce you’ve drafted the tables and fields you believe you need in your database, the next stepis to enter some sample data in the tables and look for any potential problems with maintain-ing the data.

Identifying possible data maintenance problems before you enter your real data and start work-ing with your database will save you many headaches and extra work later on. Improperlydesigned tables can also result in inaccurate data, and you certainly don’t want to be makingdecisions based on data that you can’t trust.

Data Normalization GuidelinesData normalization ensures that, when you implement the tables you have planned, the result-ing database will be able to efficiently provide the queries and reports desired and ongoingdata maintenance will be as simple as possible.

Guidelines:Common data normalization guidelines are as follows:

• Each field should contain the smallest meaningful value.

• There should be no repeated groups of fields (similar data belongs in the samefield).

• There should be no unnecessarily repeated data values.

• When reasonable, all fields in a table should pertain to every record.

Non-Example:In this example the fields are not normalized. The Name field is not the smallest mean-ingful value. There are two email address fields, and the second will not always have avalue.

• Full Name

• Work Phone Number

• Work Email Address 1

• Work Email Address 2

LESSON 7

Lesson 7: Planning a Database 133

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 149: Access Level 1

• Social Security Number

• Begin Date

Example:In this example, each field has the smallest meaningful value, there are no repeatedgroups of fields or repeated data values, and every record in the table will have a valuein each of these fields.

• Employee First Name

• Employee Last Name

• Work Phone Number

• Work Email Address

• Social Security Number

• Begin Date

Non-Example:A table containing the following fields would violate the data normalization guidelines.The name field should be split into at least First Name and Last Name, there arerepeated fields for Projects and their Completion Dates, and the Optional Assistantfield would by definition not have a value for each record.

• Name

• Department

• Project 1

• Completion Date 1

• Project 2

• Completion Date 2

• Optional Assistant

Blank ValuesThough not a strict rule, In many cases blank values in fields should appear becausethat value is temporarily missing or unknown—not because that field does not pertainto a record. So, for example, if you have a table listing employees that contains aWebSite field, that field would contain a blank value for some employees (assumingthat not everyone has a Web site, or likely ever will). The value isn’t temporarily miss-ing or unknown; the field just doesn’t apply to every record. That’s a sign that the fieldmight belong in a separate table.

In this case it is quite possible that while some employees do not have a Web site, some have morethan one. This would be another reason that this field belongs in a separate table, otherwise you wouldend up with two or more redundant fields in the same table.

Data Denormalization

Definition:Denormalization occurs when a database designer combines data into one table that thenormalization process indicated should be in two tables. After a database designer hasfully normalized the design of a database, he or she may, on occasion, choose to dothis for any number of reasons:

LESSON 7

Microsoft® Office Access 2003 - Level 1134

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 150: Access Level 1

• Performance reasons, such as making queries run faster against very large tables.

• In order to keep similar data together.

• To keep the overall table structure simple, particularly when it is clear that break-ing normalization guidelines will not negatively affect the ability to run queries orcreate reports.

Example:A common example of denormalization is allowing an occasional field to be blank forsome records. For instance, a database may contain a middle initial field, but not allemployees have or use a middle initial. Strict normalization rules would state that thefield should not be null—but it is common practice to keep this field in the same tablewith the first and last names.

DISCOVERY ACTIVITY 7-6Preventing Data Maintenance Problems

Scenario:You have two draft tables for the computer inventory database. One is called Employees andhas an EmployeeName field and a Department field. The other is called Computers and has theother six fields you decided upon. Now consider what potential data maintenance problemsmight exist by imagining them filled with data. See Figure 7-7 and Figure 7-8.

Figure 7-7: The Employees table with sample data.

Figure 7-8: The Computers table with sample data.

LESSON 7

Lesson 7: Planning a Database 135

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 151: Access Level 1

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 forthe last name.

c) It should include the last name data only.

d) Nothing, it is fully normalized as it is.

2. True or False? Since the Department field holds repeated values, a Departments tableshould hold those values.

True

False

3. True or False? Since not all records have an entry in the Note field, strict adherence tonormalization guidelines would require the note field be moved to a separate table.

True

False

4. What can be done to normalize the data in the Manufacturer field?

a) The entries should be in all lowercase.

b) The entries should be in all uppercase.

c) Since it has repeated entries, there should be a Manufacturers table to hold thatdata.

d) Nothing, it is fully normalized already.

5. If you chose to not normalize the data in the Manufacturer field in this way, that wouldbe an example of the data.

6. What needs to be done to normalize the Warranty field’s data?

a) It should be a text field.

b) Because some check boxes are not checked, that data belongs in a separate table.

c) Nothing, it is fully normalized already.

LESSON 7

Microsoft® Office Access 2003 - Level 1136

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 152: Access Level 1

PRACTICE ACTIVITY 7-7Normalizing Additional Data

Activity Time:

10 minutes

Scenario:A colleague has asked you to help them denormalize some tables in their databases.

1.

The field does not contain the smallest meaningful values.

2. Based on the data shown, which additional fields would you need to add to normalizethis data?

a) City

b) State

c) Zip Code

d) Country

Zip Code information implies the City and State. If a lookup function were available, then havingadditional fields for City and State would, in this respect, amount to denormalizing this data.

3.

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.

LESSON 7

Lesson 7: Planning a Database 137

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 153: Access Level 1

4. Why would these be data maintenance problems?

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.

The field contains unnecessarily repeated values that rely on a non-key field.

7. What data maintenance problem does this cause?

8. True or False? You could normalize this data by moving the ProjectManager and Phonefields into a second but related table.

True

False

LESSON 7

Microsoft® Office Access 2003 - Level 1138

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 154: Access Level 1

TOPIC GDesignate Primary and Foreign KeysNow that you’ve modified the design of the tables so that you’re confident that the data can bemaintained accurately, it’s time to determine the primary and foreign keys for each table,which in turn determines how the tables can be related to each other.

As you know, Access databases have such great querying power in part because tables can beformally related to each other. Properly assigning primary and foreign keys is essential to cre-ating useful relationships between your tables, and without them, you simply won’t be able touse the full querying and reporting power of your database.

Primary KeysDefinition:

A primary key is a field or combination of fields that contains a value that uniquelyidentifies a record. The primary key is used in establishing appropriate relationshipsbetween tables. Primary key fields:

• Have values that are never blank.

• Have values that rarely (if ever) change.

• Include as few fields as necessary.

• Never allow duplicates.

• Can be any datatype.

AutoNumber is a common datatype choice for primary key fields because it guarantees uniqueness.

Access sorts the records by the values in the primary key.

Example: EmployeeID as a Primary Key

Figure 7-9: An EmployeeID field is a good candidate to serve as a primary keyfor an Employees table.

Other common examples of primary key fields include: Student ID number, Order number, Item num-ber, Part number, Serial number, ISBN number, and Date plus Time.

LESSON 7

Lesson 7: Planning a Database 139

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 155: Access Level 1

Non-Example:A LastName field is not a good primary key field because it can have duplicate values.An Email field is also not a good primary key field because it could allow for blankvalues and changes often.

Figure 7-10: Not all fields would be good primary keys.

Foreign KeysA foreign key field is a field or combination of fields that contains a value that relatesto a primary key field. Its datatype must match that of the primary key field. Duplicatevalues can appear in the foreign key field. The combination of primary and foreign keyfields is what gives Access its relational power.

DISCOVERY ACTIVITY 7-8Identifying Primary and Foreign Key Fields

Scenario:Your database design now contains the following tables: Employees, Departments, Computers,Manufacturers, Notes. See Figure 7-11. Now you need to designate which fields will be pri-mary keys and, where necessary, foreign keys. In doing so you are preparing your tables to beproperly related together.

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

d) A new field, EmployeeID

LESSON 7

Microsoft® Office Access 2003 - Level 1140

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 156: Access Level 1

2. In which table should the EmployeeID field appear as a foreign key field?

a) Departments

b) Computers

c) Manufacturers

d) Notes

3. The field should be the primary key field for the Departments table.

4. Which table should have DeptCode as a foreign key field?

a) Employees

b) Computers

c) Manufacturers

d) Notes

5. The field can serve as a primary key field for both the Computers and Notestables.

6. If you were to add a ManufacturerID field to serve as the primary field for the Manufac-turers table, what other table should have a ManufacturerID field as a foreign key?

a) Employees

b) Departments

c) Computers

d) Notes

Lesson 7 Follow-upIn this lesson, you learned all the steps required to plan a simple Access database. You fol-lowed a process that ensures that your resulting database will take into account your existingdata, fulfill the needs of users, and be both robust and easy to maintain. You can feel confidentthat the design that you now have can be implemented as an Access database appropriate toyour goals.

1. Why is it important to create a plan before building your database?

2. What fields might you include in the first database you need to build on your job? Howwould you group them into tables?

LESSON 7

Lesson 7: Planning a Database 141

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 157: Access Level 1

Microsoft® Office Access 2003 - Level 1142

NOTES

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 158: Access Level 1

Building the Structure of aDatabase

Lesson Objectives: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.

Lesson Time1 hour(s)LESSON 8

LESSON 8

Lesson 8: Building the Structure of a Database 143

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 159: Access Level 1

IntroductionOnce you’ve designed a database, you need to create the related tables that will store the data.This lesson will introduce you to the basics of building tables and the relationships betweenthem that will enable robust queries and reports.

A database design is like an architect’s blueprint. Just as builders need to construct the house,you need to build the structure of your database. Building a database from scratch will giveyou the most flexibility. But to create a solid structure, you should use your design as a strictguide when creating your tables and the relationships between them.

TOPIC ACreate a New DatabaseHaving planned a new database, you are now ready to create it. You have several options: cre-ate it based on a template from Microsoft, create it based on the structure of a pre-existingdatabase, or create an empty database. In this lesson you will take the third approach.

Knowing how to create a new database of your very own design frees you from having to findan appropriate template or having to spend a lot of time modifying someone else’s design.

How to Create a New DatabaseProcedure 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 databasebased on a template. You will be unable to use Access during that time.

1. If necessary, start Access.

2. If necessary, choose File→New to display the New File task pane.

3. In the New File task pane, under the Templates heading, click On My Computer.

4. In the Templates dialog box, select the Databases tab.

5. Click the template you wish to use. Click OK.

6. In the File New Database dialog box, navigate to the folder in which you wish tostore the database file.

7. In the File Name text box, enter the name for the file. Click Create.

8. After reading the initial description of this template, click Next.

9. For each table that the template provides, select any optional fields that you wishto include and deselect any fields that you do not want. Click Next.

10. Select the style you want for forms in the database and click Next.

11. Select the style you want for printed reports and click Next.

LESSON 8

Microsoft® Office Access 2003 - Level 1144

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 160: Access Level 1

12. If you want the title of the database to be different from the file name, enter thattitle. Click Next.

13. If you do not want the database to be opened after the wizard builds it, uncheckYes, Start The Database. If you want help on using a database, check DisplayHelp On Using A Database. Click Finish.

TemplatesAccess provides several templates on which you can base a new database. The tem-plate provides a database designed to hold a certain type of data (such as Order Entryor Resource Scheduling). A basic set of templates is installed on your computer whenyou install Access and additional templates are available on the Microsoft Web sitethrough a link provided on the New File task pane.

ACTIVITY 8-1Creating a New Database Based on a Template

Scenario:You’ve decided on Access as your relational database management system. You decide to trycreating the database using a template provided by Microsoft. There is no need to reinvent thewheel, and if a template-based database is close enough to your database design (See Figure8-1), it might save you a lot of time.

Figure 8-1: Your current database design.

LESSON 8

Lesson 8: Building the Structure of a Database 145

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 161: Access Level 1

What You Do How You Do It

1. Create a new database based on the

Asset Tracking template.

You might have a shortcut to Access onyour desktop and can double-click that torun Access.

a. Launch Access.

b. Choose File→New to display the New Filetask pane.

c. In the New File task pane, under the Tem-plates heading, click On My Computer.

If On My Computer is not available, click Moreto see the On My Computer link.

d. In the Templates dialog box, select the

Databases tab.

e. Select the Asset Tracking template.

f. Click OK.

g. If necessary, in the Places bar, select My

Documents.

h. In the File Name text box, type

MyComputersTemp

i. Click Create.

LESSON 8

Microsoft® Office Access 2003 - Level 1146

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 162: Access Level 1

2. The initial description of this template looks promising. Which of your planned data-base tables seem to match to the information listed?

a) Employees

b) Departments

c) Manufacturers

d) Computers

e) Notes

LESSON 8

Lesson 8: Building the Structure of a Database 147

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 163: Access Level 1

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 selectedin the left pane, scroll through the right

pane to view the list of fields.

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.

e. Click Next.

LESSON 8

Microsoft® Office Access 2003 - Level 1148

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 164: Access Level 1

4. Preview the form styles, and then

select the Standard style and con-

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

a. If necessary, select Bold to preview thebold report style.

b. If desired, preview any other report

styles that interest you.

c. Select the Corporate style.

d. Click Next.

LESSON 8

Lesson 8: Building the Structure of a Database 149

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 165: Access Level 1

6. Assign a title of Computer Inventoryand continue with the wizard.

a. In the text box, type Computer Inventory

b. Click Next.

LESSON 8

Microsoft® Office Access 2003 - Level 1150

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 166: Access Level 1

7. The final screen asks if you want toopen the database after the wizardbuilds it. Build the database. Review

its structure and then close it.

On slower computers, it may take Accessseveral minutes to build your databasefrom the template.

a. Click Finish. A switchboard is displayedwith buttons for entering information andperforming other actions.

b. Close the switchboard.

c. Restore Up the minimized database win-

dow from the bottom left of your

screen.

d. After reviewing the Forms created foryou, click the Tables button and review

the tables created for you.

e. Click the Queries button. No querieswere created for you.

f. Click the Reports button and review the

Reports created for you.

g. Although it could be modified to meetyour exact database design, you willinstead create an empty database andbuild from scratch. Close the Computer

Inventory database window by clicking

the close button.

LESSON 8

Lesson 8: Building the Structure of a Database 151

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 167: Access Level 1

Procedure Reference: Create an Empty Database

To create a new blank database:

1. If necessary, start Access.

2. If necessary, display the New File task pane by clicking the New button.

3. In the New File task pane, under the New heading, click Blank Database.

4. If necessary, navigate to the location in which you wish to store the database file.

5. Assign a name to the database file.

6. Click Create.

ACTIVITY 8-2Creating a New Blank Database

Scenario:You’ve decided that you want a database that is precisely tailored to what you need to accom-plish, so you want to start it from scratch. You will create and save a new Access MDB file, soyou can then go on to create your own Access objects.

What You Do How You Do It

1. Choose to create a Blank Database. a. If necessary, choose File→New to displaythe New File task pane.

b. In the New File task pane, under the Newheading, click the Blank Database link.

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.

LESSON 8

Microsoft® Office Access 2003 - Level 1152

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 168: Access Level 1

d. Examine the database window. Thename of the new database is displayed inthe title bar. The title bar also indicatesthat the database is in Access 2000 fileformat.

TOPIC BCreate a Table Using a WizardA new blank database is just that—blank. You need to create all the appropriate tables to storethe data. There is a wizard available to help create tables, so you will try that out next.

Just because you aren’t using a template for your database, that doesn’t mean you can’t savetime creating your tables. Wizards can simplify complex tasks for beginning users and cansave work for all users. It’s helpful to see what wizards are available for creating tables andhow they work so you’ll know when they might be useful to you.

How to Create a Table Using a WizardProcedure Reference: Create a New Table Using the Wizard

To create a new table using the wizard:

1. If necessary, in the database window, select Tables in the Objects bar.

2. Double-click Create Table By Using Wizard.

3. Select the appropriate sample table.

4. From the sample table, add the sample fields you want to the new table.

5. If you wish, rename any fields by selecting the field and clicking Rename Field.Enter the new name and click OK. Click Next.

LESSON 8

Lesson 8: Building the Structure of a Database 153

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 169: Access Level 1

6. Assign a name to your table and select whether you want the wizard to set theprimary key or whether you wish to select it yourself. Click Next.

7. If you choose to set the primary key yourself:

a. Select the field that contains a unique value for each record.

b. Indicate the type of data you want the primary key field to contain.

c. Click Next.

8. If there are already other tables in your database:

a. Indicate whether the new table is related to any of them.

b. If the new table is related to an existing table, select that table, click Rela-tionships, and select the type of relationship.

c. Click OK.

d. Click Next.

9. Select whether you want, after the table is created, to modify the design, enterdata directly in the table, or have the wizard create and display a form for you touse to enter data. Click Finish.

Let Access Set the Primary KeyIf you choose to let the wizard set the primary key for you, one of two things willhappen. If you included an AutoNumber field (such as an ID Field) in your new table,Access will designate that as the primary key. This means that Access will enterunique sequential numbers in that field as you enter records. If there is not anAutoNumber field in your table, the wizard will add one with the same name as thetable followed by the abbreviation ID. You cannot change the values entered by Accessin an AutoNumber field.

When are Numbers not Numbers?Even though a field, such as an EmployeeID field, may contain numbers, it should notnecessarily be assigned a number data type. Examples of this are phone numbers, ZipCodes, and Social Security numbers, which should be a text data type. You should usethe number data type only for fields that you will perform mathematical operations on.

LESSON 8

Microsoft® Office Access 2003 - Level 1154

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 170: Access Level 1

ACTIVITY 8-3Create the Employees Table with a Wizard

Setup:The MyComputerInventory database is open and the tables are displayed.

Scenario:You’re creating your new database and want to start building the tables you need as quickly aspossible, so you’ve decided to try using a wizard. Your database diagram showing the tablesand their primary and foreign keys is in front of you. See Figure 8-2. You’ve decided to createthe table for information on employees first. Assume that the employees have IDs assigned bythe company.

Figure 8-2: Diagram for the MyComputerInventory database.

What You Do How You Do It

1. Start the wizard and review the

Business and Personal sample tables

that are available.

a. Double-click Create Table By Using

Wizard.

b. With Business selected, scroll the Sample

Tables list to see what tables areavailable.

c. Select Personal.

d. Scroll the Sample Tables list.

LESSON 8

Lesson 8: Building the Structure of a Database 155

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 171: Access Level 1

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 .

e. In the Sample Fields list, select

FirstName and click the right arrow.

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

b. Click Rename Field

.

c. In the Rename Field text box, type

DeptCode

d. Click OK.

e. Click Next.

4. Name the table and choose to set

the primary key yourself.

a. Name this table tblEmployees.

b. Select No, I’ll Set The Primary Key.

c. Click Next.

5. Specify that you want the data to

be numbers and/or letters that

you’ll be entering.

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.

6. Choose to enter data directly in the

table and complete the wizard.

a. Verify that Enter Data Directly Into The

Table is selected.

LESSON 8

Microsoft® Office Access 2003 - Level 1156

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 172: Access Level 1

b. Click Finish. The table is created andshown in Worksheet view.

c. Close the table.

TOPIC CCreate Tables in Design ViewYou’ve created a table with the Table Wizard. Now you’ll create additional tables using themore manual approach by working in Design View.

Wizards can be great time-saving devices. But for many tables there won’t be an appropriatewizard. If you would spend more time altering the result of a wizard than creating a table fromscratch, then you should create your table in Design View.

How to Create Tables in Design ViewProcedure Reference: Create a New Table in Design View

To create a new table in Design view:

1. In the database window, in the Objects bar, select Tables.

2. Double-click Create Table In Design View.

3. For each field you wish to include in the table:

a. In the Field Name column, enter the name of the field.

b. Click in the Data Type column for the field, display the drop-down list, andselect the data type.

c. Make any changes you want to the Field Properties displayed in the lowerpane.

4. Select the field(s) you want to set as the primary key and click the Primary Keybutton.

You can also set the primary key by right-clicking the selected field and choosing Primary Key.

5. Click Save.

LESSON 8

Lesson 8: Building the Structure of a Database 157

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 173: Access Level 1

6. Enter a name for the table. Click OK.

Field Size PropertyThe Field Size property is available for Text, Number, and AutoNumber fields. Yourdatabase will perform more efficiently and will occupy less storage space if you set theField Size property to conform with the actual length of the data you will store in thefield. Look in Access Help for the topic on the FieldSize Property for details on thevarious settings.

An AutoNumber Field as a Foreign KeyWhen you have an AutoNumber field as the primary key in one table and wish to usethat same field as a foreign key in another table, in that second table, you must set thefield’s data type to Number and the Field Size property to Long Integer.

ACTIVITY 8-4Creating the Manufacturers Table in Design View

Setup:The MyComputerInventory database is open and the tables are shown.

Scenario:You’re continuing to implement the design of your computer inventory database. See Figure8-2. Since there aren’t appropriate sample tables available for all the tables you need, you’regoing to create the rest in Design view, starting with the Manufacturers table.

What You Do How You Do It

1. 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 col-umn, type ManufacturerID

c. Click in the Data Type field for the

ManufacturerID record.

d. Click the down arrow and select

AutoNumber.

2. What is the default Field Size for the AutoNumber data type?

a) Byte

b) Long Integer

c) Decimal

d) Currency

LESSON 8

Microsoft® Office Access 2003 - Level 1158

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 174: Access Level 1

3. Create a field named Manufacturerthat 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 thedefault.

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 thatyou misspelled the name of the table,you can change it. Right-click the tablename and choose Rename. Enter the cor-rect name and press Enter.

a. Click Save.

b. In the Table Name text box, type

tblManufacturers

c. Click OK.

d. Click Close.

LESSON 8

Lesson 8: Building the Structure of a Database 159

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 175: Access Level 1

ACTIVITY 8-5Create the Computers Table

Setup:The MyComputerInventory database is open.

Scenario:Now that you’ve successfully created your first table in Design view, you’re ready to createthe one to hold information on computers. The fields you need are listed in your databasediagram. See Figure 8-2.

What You Do How You Do It

1. In a new table design window, create

an AssetTag text field that allows

four characters.

a. Double-click Create Table In Design

View.

b. In the first Field Name field, type

AssetTag

c. Press Tab.

d. Select the value in the Field Size prop-

erty box.

e. Type 4

2. Referring to your database diagram, you see that the next field, ManufacturerID is aforeign key field. What data type and field size must it therefore have?

a) AutoNumber and Byte

b) Number and Byte

c) AutoNumber and Long Integer

d) Number and Long Integer

3. Create a ManufacturerID field with

a data type of Number and a Field

Size property of Long Integer.

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.

LESSON 8

Microsoft® Office Access 2003 - Level 1160

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 176: Access Level 1

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 bebetter than number?

a) Text

b) Currency

c) Yes/No

d) Memo

7. Change the datatype to Currency. a. For the DataType of the PurchasePricefield, select Currency.

b. Open the Decimal Places property drop-

down list and select 0.

8. Create a Warranty field as a Yes/No

data type.

a. In the next Field Name field, type War-ranty

b. Open the Data Type drop-down list and

select Yes/No.

9. Create an EmployeeID field as a

Text data type.

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

erty box. EmployeeID is a foreign key tothe Employees table and the primary keyof that table has a field size of 4. Type 4

LESSON 8

Lesson 8: Building the Structure of a Database 161

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 177: Access Level 1

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.

b. In the Table Name text box, type

tblComputers

c. Click OK.

d. Click Close.

PRACTICE ACTIVITY 8-6Completing the Tables for the Database

Activity Time:

10 minutes

Scenario:You need just two more tables to finish the implementation of your database design. You haveyour database diagram, your notes about data types, and the previous activities as resources.

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.

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

LESSON 8

Microsoft® Office Access 2003 - Level 1162

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 178: Access Level 1

TOPIC DCreate Relationships between TablesOnce you’ve built the tables you need in your database, the last step in implementing yourdesign is to establish the appropriate relationships between the tables.

You can’t harness the full power of a relational database management system like Access with-out establishing table relationships and using referential integrity. Together, these features helpto ensure the accuracy of the data, and enable the breadth of queries and reports that you willlikely want to use to retrieve, display, and print your data.

One-to-One RelationshipDefinition:

A one-to-one relationship is a relationship between two tables where both the primarykey and the foreign key are unique. For each record in the first table there will be oneand only one record in the second table.

Example:

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.

LESSON 8

Lesson 8: Building the Structure of a Database 163

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 179: Access Level 1

One-to-Many RelationshipDefinition:

A one-to-many relationship is a relationship between two tables where the primary keyis unique but the foreign key allows duplicate values. For each record in the primary-key table there can be multiple records in the foreign-key table.

Depending on which of the two tables you’re looking at, you can also express this as a many-to-onerelationship.

Example:

Figure 8-4: A one-to-many relationship between a Customers table and anOrders table, using the CustomerID field as the key.

Many-to-Many RelationshipIn examining the relationships between data in tables, you may find that you have amany-to-many relationship between two tables. This is when many records in one tablecan relate to many records in another table. For example, if you had a table foremployees and another for projects, you might find a many-to-many relationship ifeach employee could work on many projects and each project could involve manyemployees. This relationship cannot be implemented directly in Access and would haveto be resolved by the creation of an intersection table containing, for example, justEmployeeID and ProjectNumber fields. This table would have a many-to-one relation-ship with both of the other tables.

Enforce Referential IntegrityEnforcing referential integrity for a relationship can avoid the loss or inadvertent updating ofdata.

Guidelines:You can set referential integrity between two tables if the following are true:

LESSON 8

Microsoft® Office Access 2003 - Level 1164

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 180: Access Level 1

• Both tables are in the same Access database.

• The matching field is a primary key in one table or has a unique index.

• The related fields have the same data type (the exception is that an AutoNumberfield can be related to a Number data type with a field size of Long Integer).

The Effects on Data ModificationWhen referential integrity is enforced (without enabling the cascading options), certainrules apply to the data. This list gives you some examples.

• You can’t enter a value in the foreign key field of one table if there is not amatching value in the primary key of the related table.

• You can’t delete a record from the primary table (the table in which the primarykey is the related field) if a matching record exists in the related table.

• You can’t change the value in the primary key of the primary table if there arerelated 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.

Example:A CustomerID autonumber field in the Customers table is a unique primary key andcan be related to a number field in the Orders table in a one-to-many relationship. Youdon’t want to allow the user to enter any order data for a customer that doesn’t have arecord in the Customers table. Nor do you want the user to alter the CustomerID fieldfor a record in the customers table, because that would break the link with the relatedorders data for that customer. Deleting a customer record that has matching orderrecords would also not be allowed. This is a good candidate for enforcing referentialintegrity.

How to Create Relationships between TablesProcedure Reference: Create a Relationship and Enforce Referential Integrity

To create a relationship between two tables and enforce referential integrity betweenthem:

1. Choose Tools→Relationships to open the Relationships window.

2. In the Show Table dialog box, select the tables you want to work with and clickAdd.

To select multiple tables in the Show Table dialog box, you can use Shift-click to select adjacenttables and Ctrl-click to select non-adjacent tables.

3. Close the Show Table dialog box.

4. Select the key field in the primary table that you want to relate to the secondtable.

5. Drag the key to the related foreign key in the second table.

6. In the Edit Relationships dialog box, check Enforce Referential Integrity.

7. Click Create.

LESSON 8

Lesson 8: Building the Structure of a Database 165

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 181: Access Level 1

8. Close the Relationships window, saving changes to its layout.

ACTIVITY 8-7Creating One-to-Many and One-to-One Relationships

Setup:The MyComputerInventory database is open and the Employees, Manufacturers, Computers,Departments, and Notes tables have been created.

Scenario:By considering your primary and foreign keys, and the type of data that will be stored in yourtables, you can determine what types of relationships there are between your tables. You wantto help ensure the accuracy of the data, so you’ve decided to enforce referential integrity in allrelationships. You do this by working in the Relationships window. See Figure 8-5.

Figure 8-5: The relationships in the MyComputerInventory database.

What You Do How You Do It

1. Display all five tables in the Rela-

tionships window.

a. Choose Tools→Relationships.

b. With tblComputers selected on the Tablestab of the Show Table dialog box, press

Shift, and select tblNotes in the list oftables.

c. Click Add.

d. Click Close.

2. Adjust the size of the tblComputers

table so you can view the entire list

of fields.

a. Place the mouse pointer over the bot-

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

LESSON 8

Microsoft® Office Access 2003 - Level 1166

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 182: Access Level 1

3. The tables in the Relationships window are arranged in order by default.

4. 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 tablesand why?

a) There is a one-to-one relationship because for every department record there will beone employee record.

b) There is a one-to-many relationship because for each department record there couldbe many employee records.

c) There is a one-to-many relationship because for each employee record there couldbe many department records.

6. Create the relationship between

the tblDepartments and

tblEmployees tables.

a. In the Departments table, select the

DeptCode field.

b. Drag the DeptCode field of the

tblDepartments table to the DeptCode

field in the tblEmployees table.

In doing so you are dragging from the one-sideto the many-side of the relationship.

7.

In the Edit Relationships window, what kind of relationship is given as the Relationshiptype?

a) One-to-One

b) One-to-Many

c) Many-to-One

d) Many-to-Many

LESSON 8

Lesson 8: Building the Structure of a Database 167

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 183: Access Level 1

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 atmost one note record, and vice-versa.

b) There is a one-to-many relationship because for each computer record there couldbe many note records.

c) There is a one-to-many relationship because for each note record there could bemany computer records.

10. Create the relationship between

the tblComputers and tblNotes

tables but do not enforce referen-

tial 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 One-

To-One. Click Create.

Given that the data was fully normalized so thatthe Notes information is in a separate table,you would not want to enforce referential integ-rity on this one-to-one relationship. Doing sowould require that every record in thetblComputers table have a correspondingrecord in the tblNotes table, which is not thecase and was the reason for normalizing thisdata (there were blank fields). This is anexample where denormalizing the Notes data isan option.

11. Create the relationship between

the tblEmployees and tblComputers

tables and enforce referential

integrity in the relationship.

a. Drag the EmployeeID field from the

tblEmployees table to the EmployeeID

field of the tblComputers table.

b. Verify that the Relationship Type is One-

To-Many and then check Enforce

Referential Integrity.

c. Click Create.

LESSON 8

Microsoft® Office Access 2003 - Level 1168

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 184: Access Level 1

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

To-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 File→Print Relationships to pre-

view the printing of the Relationships

window.

b. Click Print.

If you do not have a printer available you willnot be able to actually print this page and mayget an error message.

c. Close the Report window that was

opened and save the changes when

asked.

Be sure to save the changes you have made tothe relationships or the same graphical repre-sentation of the relationships will not bedisplayed the next time you open the window.

d. Close the Relationships window.

e. Close the MyComputerInventory

database.

Lesson 8 Follow-upIn this lesson, you implemented your database design plan. You saw that creating a blank data-base is fairly easy, but adding custom tables can be a little trickier. When appropriate, usingthe Table Wizard, or even a template for an entire database, can save you time andaggravation. You also learned that no database is complete without the right relationshipsbetween your tables to help maintain the accuracy of your data.

1. In what circumstances would you prefer to create a database using a template overcreating one from scratch?

LESSON 8

Lesson 8: Building the Structure of a Database 169

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 185: Access Level 1

2. Do you think the Table Wizard will offer most of the table-building functions yourequire, or will you often build tables in Design view?

LESSON 8

Microsoft® Office Access 2003 - Level 1170

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 186: Access Level 1

Controlling Data Entry

Lesson Objectives:In this lesson, you will control data entry by modifying the design of a table to streamline dataentry and maintain data integrity.

You will:

• Restrict data entry with field properties that set a default value, require data entry, andvalidate data.

• Create an input mask to limit the type of information that can be entered.

• Add a lookup field to a table and modify a lookup list used in a lookup field.

Lesson Time40 minutesLESSON 9

LESSON 9

Lesson 9: Controlling Data Entry 171

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 187: Access Level 1

IntroductionYou have a simple database and you want to control how data will be entered. There arenumerous enhancements you can make to tables to enable this. In this lesson you will considersome that will help you to better control data entry.

Data consistency is one of the most important aspects of a good database. For example, toenable consistent phone number formatting, you can pre-format how data will be entered inthat field. Or consider a required name field: you can ensure consistency and reduce errors byrequiring that each record have a name value.

TOPIC ARestrict Data Entry with FieldPropertiesThe first thing you’ll do to get started in controlling data entry is to work with properties ofthe fields in your tables. These properties can help make data entry more accurate.

Having the right kind of data in a field can often be critical. Consider the case where a calcu-lation on a number field demands that no null (empty) fields be present. To avoid thepossibility that a user forgets to enter a value, you can set field properties to require data entryand provide a default value of 0. Or consider a case where you must have a value between 1and 5. By using field properties you can restrict the data so that a value of 6, for instance,would not be permitted. Simple field properties can help to restrict data entry and eliminateerrors in your tables and queries.

Field PropertiesTo enhance a table’s design and to facilitate data entry in the datasheet and its related forms,you can set field properties. Each field in your table has a set of field properties that you canchange and modify to affect how the field looks and works. When you set these properties,you can increase the ease, speed, and accuracy of entering data. (See Table 9-1.)

Table 9-1: Essential Field Properties that Affect How a Field Appears and Behaves

Property DescriptionFormat Determines the way data is displayed. For example, if you use the greater

than (>) symbol, it forces all characters to uppercase so Access automati-cally capitalizes the data entered. Use the Format field property when youneed to display data in a consistent format.

Default Value A value that will be automatically entered for the field when you create anew record. It only affects new records and does not alter the values ofexisting data. Establishing default values can save you a lot of typing,especially when one value will be consistently entered in a field.

Caption The text that will be displayed in place of the FieldName as the columnheading in Datasheet view. It will also be used as the Label control in aform where the field is dragged from the field list.

LESSON 9

Microsoft® Office Access 2003 - Level 1172

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 188: Access Level 1

Property DescriptionRequired If set to Yes, a value is required for that field. If set to No, the value can

be left blank. Access displays an error message if you attempt to save arecord that has a null value in a required field.

Validation Rule Establishes a rule to set boundaries for data entry in a field. For example,this property can be used with currency and number fields to check forminimum or maximum allowed values, or it can be used with date fieldsto ensure that the data isn’t entered before or after a specified date.

Validation Text A message that is displayed when the validation rule is violated. You cancustomize the error message that’s displayed when a validation rule is vio-lated or a required field is left blank.

How to Restrict Data Entry with Field PropertiesProcedure Reference: Set Field Properties

To set field properties:

1. Display the table in Design view.

2. In the upper pane, click the name of the field to display the properties for thatfield.

3. In the lower pane, click the text box for the desired property and add or update itsvalue.

To obtain help specific to this property, press F1.

4. Save your changes to the table.

Modified Field PropertiesEach time you change the properties in a table’s design, you must save the table beforeyou can switch to Datasheet view and work with the records. If you are working witha table that already contains records, then the new validation rules will be applied onlyto new data entered after you set the rules. You will be asked whether you wantAccess to check existing table data to see if it complies with the validation rules. AfterAccess checks the existing records, a message box is displayed letting you knowwhether the records do or do not meet the new criteria. (There is no notification on anindividual record basis. You would have to use queries to find the data that does notmeet the validation rules.)

If you save a table using a different name after setting new validation rules, this wouldcreate a new table with no records. The new table’s design contains the validationrules, so each new record you enter must meet these validation rules.

You can’t override a validation rule during data entry or editing. If you attempt to type or copy/pastedata, you must satisfy the validation rule for the corresponding field.

LESSON 9

Lesson 9: Controlling Data Entry 173

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 189: Access Level 1

ACTIVITY 9-1Setting a Default Value, Requiring Data Entry, andValidating 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 tobuild in some constraints so data is entered as you would expect. You know that some peoplewill enter uppercase codes and others will use lowercase. Therefore, you want to have Accessautomatically capitalize the letters in the Dept and ParkingLotCode fields. Also, most employ-ees work 40 hours a week and none get paid more than $30 per hour.

What You Do How You Do It

1. In the Control database, open

tblPayroll in Design view.

a. Open Control.mdb.

b. Maximize the Control database window.

c. Open tblPayroll in Design view.

2. Format the ParkingLotCode and

Dept fields so that the values will

be displayed in uppercase.

a. Display the properties for the Dept field.

b. In the Field Properties pane, in the For-mat property text box, enter > to forceuppercase.

c. In the Field Name column, click in the

ParkingLotCode cell.

d. In the Format field property, enter >

e. In the Caption property, enter ParkingLot

3. Set the default for the Hours field

to 40.

a. Display the properties for the Hours

field.

b. The Default Value field property is set to0. Select the Default Value property and

change it to 40

c. Press Enter.

LESSON 9

Microsoft® Office Access 2003 - Level 1174

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 190: Access Level 1

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 tothe 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 prop-erty box.

d. From the Required drop-down list, select

Yes.

6. Save this table as tblMyPayroll. a. Choose File→Save As to save the tablewith a new name.

b. Save this table as tblMyPayroll

c. Switch to Datasheet view.

7. A default value of is displayed in the Hours field.

8. In the EmployeeID field, enter en1-60.

a. In the EmployeeID field, type en1-60

b. Press Enter.

c. In the Hours field, press Enter.

9. In the PayRate field, test the valida-

tion properties and then enter

22.50.

a. In the PayRate field, type 32.50

b. Press Enter.

c. Click OK.

LESSON 9

Lesson 9: Controlling Data Entry 175

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 191: Access Level 1

d. Delete the value you typed, and then

with the field empty press Enter.

e. Click OK.

f. Enter 22.50

g. Press Enter.

10. Complete the record by entering twin the Dept field, bl in the

ParkingLotCode field, and a check

mark in the Health field.

a. In the Dept field, enter tw

b. In the ParkingLotCode field, enter bl

c. In the Health field, press Spacebar toenter a check mark.

You can also click in the check box to check(or uncheck) it.

11. Save the record and close the table. a. The pencil icon is still displayed at theleft end of the record, indicating that therecord isn’t saved yet. Press Enter tosave the record and remove the pencilicon.

b. Close the table.

LESSON 9

Microsoft® Office Access 2003 - Level 1176

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 192: Access Level 1

TOPIC BCreate an Input MaskYou have just used some of the properties of your fields to improve the accuracy of the data inyour tables. In this topic you will use another field property to limit the format that users canenter data in.

Suppose you have a phone number field. Assume further that as you enter phone numbers, youneed to add parentheses around the area code and a hyphen between the digits. Sometimes youremember the pattern and other times you forget. If you could force data input to match a spe-cific pattern, this problem would be solved, thereby eliminating inconsistency in this field inyour table. An added bonus of sticking to a pattern is that you can save time because Accessautomatically enters characters for you, such as slashes and hyphens, so you don’t have toenter them yourself.

Input MasksDefinition:

An Input Mask is a field property that establishes a pattern that dictates how users canenter data into the field. An input mask contains literal characters (for example, spaces,dashes, or parentheses) that separate blanks the user fills in. The blanks are representedby characters that control the type of data the user can type in.

Input Mask SectionsAn input mask definition can contain up to three sections, separated by semicolons:

• The first section is the input mask itself.

• The second section determines whether the literal display characters are stored. Ifyou leave this section blank or enter a 1, only the characters the user enters arestored; if you enter a 0, the display characters (along with the characters the userenters) are stored. By not storing the literal display characters, you can reduce thesize of your database.

• The third section represents the character that is displayed for blanks in the inputmask. By default, it is an underscore, but you can use any of a variety ofcharacters. To display a space (or empty string), use two quotation marks (“ ”).

LESSON 9

Lesson 9: Controlling Data Entry 177

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 193: Access Level 1

Example: Telephone Number Input Mask

Figure 9-1: The input mask for a standard telephone number including areacode.

Example: Zip Code Input Mask

Figure 9-2: The input mask for a Zip Code with an optional four-digitextension.

Input Mask WizardMost often, input masks are created using the Input Mask Wizard. This wizard pro-vides several common, predefined input masks, and takes you through the steps ofcreating your own custom input masks. If you need to modify an input mask, see theAccess Help topic, “Valid Input Mask Characters,” for a table of the characters youcan use. Be sure to check your data first to be aware of any conflicts that might arisefrom a modified input mask.

How to Create an Input MaskProcedure Reference: Add an Input Mask Using the Wizard

To add an input mask using the wizard:

1. In the Table Design view window, click the field that the input mask will belongto.

2. In the Field Properties pane, click in the Input Mask property box.

3. Click the Build button at the end of the line to start the Input Mask Wizard.

4. Choose an input mask type. Click Next.

5. Choose the desired placeholder. Click Next.

LESSON 9

Microsoft® Office Access 2003 - Level 1178

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 194: Access Level 1

6. Choose whether the symbols will display to the user. Click Next.

7. If you want to modify an input mask, click Edit List. You can change theplaceholder character and choose to store constant characters like dashes andslashes with the field value.

8. Click Finish when you are done with the wizard.

The Input Mask Wizard is available for Text and Date/Time fields. If you want to create an inputmask for a Number or Currency field, you must create it manually instead of using the wizard.

Procedure Reference: Manually Add an Input Mask to a Field

To manually add an input mask to a field:

1. In the Table Design view window, click the field that the input mask will belongto.

2. In the Field Properties pane, click in the Input Mask property box.

3. Enter the input mask desired for this field.

Placeholders are replaced as you enter data into the field. The default placeholder is theunderscore.

ACTIVITY 9-2Adding Pre-defined and Custom Input Masks

Data Files:

• Control.mdb

Setup:The Control database window is open. The additional wizards were installed as part of theclass setup.

Scenario:In order to improve data entry for the tblPersonal table, you decide to add input masks to thePhone, ZipCode, and EmployeeID field properties to ensure that data entry is uniform.

What You Do How You Do It

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

Lesson 9: Controlling Data Entry 179

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 195: Access Level 1

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

acter drop-down list. There are severaloptions available.

c. Select the underscore character so it’sdisplayed in the Placeholder Characterbox.

d. Click Next.

e. Verify that the default option, Without

The Symbols In The Mask, Like This, is

selected. Click Next.

f. Click Finish. Press Enter. The input maskis entered in the property box for thePhone field.

For more information about the symbols used inInput Masks, press F1 to consult the Help specificto this property.

g. Save the modified table design.

LESSON 9

Microsoft® Office Access 2003 - Level 1180

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 196: Access Level 1

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 inthe property box for the ZipCode field.

i. Save the modified table design.

5. Create an input mask that reflects

the pattern for the EmpID field.

a. Display the field properties for the

EmpID field.

b. Start the Input Mask wizard.

c. You can customize or create an inputmask list right in the wizard. Click Edit

List.

d. To create from scratch, rather than editan existing mask, click the New Record

button .

e. In the Description text box, type

Employee ID and press Tab.

f. Type !LL0-00 and press Tab.

g. Type _ (the underscore character), and

then press Tab.

LESSON 9

Lesson 9: Controlling Data Entry 181

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 197: Access Level 1

h. Type EN1-80 and press Tab.

You need to enter a value in the Sample Data boxnow; it’s later displayed in the list of input masks.

i. Click Close.

j. Select the Employee ID input mask from

the list.

k. Click Next twice to advance in thewizard.

l. This time, select the With The Symbols

In The Mask, Like This option. Click

Next.

m. Click Finish.

6. Save the modified table design. Pre-

pare to enter a new record.

a. Save the modified table design.

b. Change to Datasheet view.

c. Click the New Record button .

LESSON 9

Microsoft® Office Access 2003 - Level 1182

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 198: Access Level 1

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. Type 08/20/2001 and press Enter.

j. Close tblPersonal.

TOPIC CCreate a Lookup FieldYou’ve looked at field properties and input masks as a means for controlling data entry in yourtables. Another way to control data entry is to limit the exact values that can be entered in afield. In this topic, you’ll create a drop-down list of items to choose from when entering datain a field.

When someone should choose only from a specific set of options, it’s much easier to havethem select from that set of options, rather than leaving it wide open to fill in what theyplease, in the way they please. A set of choices is particularly useful if you repeatedly enterthe same data in a field 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 thefield, because you can more easily build queries using that field as a criteria.

Lookup List FieldsDefinition:

A lookup list is a list of values that you can choose from when entering data in a field.These values can be from a custom listing of possible values or a table or query in thedatabase. A lookup list can display one or more columns of data, but designates onecolumn as the provider of the value to be stored in the field. Column headings can beoptionally displayed, and column widths can be adjusted as needed.

LESSON 9

Lesson 9: Controlling Data Entry 183

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 199: Access Level 1

A lookup list can be created by using the Lookup Wizard or can be created manually by using variousfield properties on the Lookup tab in Design View. The resulting list that the user will see can be eithera List Box or a Combo Box.

Example: Single-column Lookup List

Figure 9-3: A lookup list with custom values for personal title abbreviations.

Example: Multi-column Lookup List

Figure 9-4: A lookup list that displays multiple columns to ease the selectionof a product’s CategoryID.

LESSON 9

Microsoft® Office Access 2003 - Level 1184

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 200: Access Level 1

Lookup List RelationshipsRelationships will automatically be created when you create a lookup list field. To seethese relationships, you can choose the Show All option in the Relationships Window.

How to Create a Lookup FieldProcedure Reference: Create a Lookup Column Based on a Table

To create a lookup column based on a table (or query):

1. In table Design view, select the field in which you want to include a drop-downlist of values.

2. In the Data Type column, select Lookup Wizard.

3. Choose to base the list on the values in a table (or query). Click Next.

4. Choose the desired table (or query). Click Next.

5. Select fields to appear in the lookup list. Click Next.

6. Choose any desired sort criteria for the displayed columns in the lookup column.Click Next.

7. If desired, uncheck Hide Key Column.

8. If necessary, double-click column borders to resize them for the best fit. ClickNext.

9. Choose a column whose value will be stored for this field. Click Next.

10. Type a label for this field. Click Finish.

11. Save your table.

ACTIVITY 9-3Adding a Lookup Field to a Table Using the LookupWizard

Data Files:

• Control.mdb

Setup:The Control database window is open. The additional wizards were installed as part of theclass setup.

Scenario:The Dept field in tblPayroll stores department codes for each department. To ensure a validdepartment code in a new record and to simplify data entry, you will create a lookup list thatdisplays both the department codes and the names, with column headings. You will restrictdata entry to only the department codes in the tblDeptNames table. (See Figure 9-5 .)

LESSON 9

Lesson 9: Controlling Data Entry 185

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 201: Access Level 1

Figure 9-5: A lookup list that displays department codes and names.

What You Do How You Do It

1. In tblPayroll, start the Lookup Wiz-

ard for the Dept field.

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.

2. Specify the source data for the

lookup column. Display both columnsfrom tblDeptNames in the lookupcolumn.

a. Verify that the I Want The Lookup Col-

umn To Look Up The Values In A Table

Or Query option is selected. Click Next.

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.

LESSON 9

Microsoft® Office Access 2003 - Level 1186

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 202: Access Level 1

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 thekey column, in this lookup list, you want to seeit and later use it to store the value entered inthe lookup column.

d. For best fit, double-click the DeptName

right column border.

This will only resize the column to fit the values thatare shown.

e. Click Next.

4. Use DeptCode as the field that

uniquely identifies the row in the

lookup column and finish the

wizard.

a. In the Available Fields list box, verify that

DeptCode is selected. Click Next.

b. For the lookup column label, type

DeptCode

c. Click Finish.

d. Click Yes to save the table before Accesscan create relationships.

LESSON 9

Lesson 9: Controlling Data Entry 187

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 203: Access Level 1

5. Test the behavior of the lookup list

by assigning the first employee to anew department.

a. Switch to Datasheet view.

b. In the first record, select the DeptCode

field. A drop-down arrow indicates thepresence of the list.

c. Click the drop-down arrow to display thelookup list.

d. Select AC for the Accounting

department.

6. Display the properties established

by the wizard for the lookup list.

a. Switch to Design view.

b. If necessary, select the DeptCode field.

c. In the Field Properties pane, select the

Lookup tab.

7. Include the column headings in the

lookup list and display the lookup

list.

a. On the Lookup tab, change the Column

Heads field property to Yes.

b. Save the modified table design.

c. Switch to Datasheet view.

d. In the DeptCode field, display the Lookup

list for the first record to see the columnheadings.

e. Close the lookup list.

LESSON 9

Microsoft® Office Access 2003 - Level 1188

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 204: Access Level 1

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 areacceptable. Click OK. Click Undo.

d. Close tblPayroll.

e. If asked, save your changes.

f. Close the Control database window.

Lesson 9 Follow-upIn this lesson, you controlled data entry by modifying the design of a table. By modifyingvarious field properties, and by using input masks and lookup fields, you have increased theconsistency of your data and reduced data entry errors.

1. 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?

LESSON 9

Lesson 9: Controlling Data Entry 189

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 205: Access Level 1

Microsoft® Office Access 2003 - Level 1190

NOTES

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 206: Access Level 1

Finding and Joining Data

Lesson Objectives:In this lesson, you will find and retrieve desired data by using filters and joins between tablesand within a single table.

You will:

• Apply a filter to view records that match criteria you specify.

• Create query joins to retrieve the desired data.

• Join two unrelated tables by including additional tables in a query.

• Relate data within a single table to itself.

Lesson Time1 hour(s)LESSON 10

LESSON 10

Lesson 10: Finding and Joining Data 191

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 207: Access Level 1

IntroductionYou’ve worked with simple queries that returned a specific record or a subset of records froma table. In this lesson, you will further this knowledge by using filters, building queries thatretrieve data from multiple tables, and relating data within a single table to retrieve the desiredrecords.

You are a project manager who needs to build a team of Java developers for a newapplication. Using your personnel skills database you could quickly find the available employ-ees who know Java from both your Seattle and Baltimore offices. Joining those results togetherinto one set of records would efficiently create the ideal project team.

TOPIC AFind Data with FiltersThere are many ways to find the data you need. In this topic you will learn the simplestapproach by using table filters. You’ll use several different methods for finding and displayingthe desired records.

Consider the following scenario: you are working in a table in worksheet view, and you wantto quickly see all the records that have the same value in the LastName field. Instead of leav-ing the table and creating a query to return these records, you can save time by simplyapplying a filter to the table. Such a filter is like a magic wand for quickly getting to the datayou want.

Types of FiltersFiltering data can help you review and analyze information in your database. You can use oneof several techniques to filter data. (See Table 10-1.)

Table 10-1: Filter Techniques

Filter Technique ResultsFilter By Selection Lets you select a value in a datasheet or form and click a button to view any

matching records.

Filter ExcludingSelection

Looks for values other than what you select.

Filter By Form Shows you a blank record where you can enter either the value you want to findor choose it from a drop-down list.

Advanced Filter/Sort

Lets you freely combine conditions and fields for a filter. You can also use this tosort a filtered view or set up multi-field sorts.

Saving a FilterFilter settings are saved with the table or form. Therefore, even if you do not modifythe data in a table, if you altered a filter setting, upon closing the table you will beasked if you would like to save the table or not. When using an Advanced Filter, youcan quickly remove the saved filter settings: right-click in the top pane and chooseClear Grid.

LESSON 10

Microsoft® Office Access 2003 - Level 1192

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 208: Access Level 1

How to Find Data with FiltersProcedure Reference: Use the Filter By Selection Technique

To use the Filter By Selection technique, perform the following steps:

1. Open a table or query in datasheet view.

2. Select one instance of the value that you want included in the view.

3. Click the Filter By Selection button.

You can continue filtering 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. Open a table in datasheet view.

2. Open the Filter By Form window.

3. Specify the criteria on the Look For and Or tabs.

4. Apply the filter.

Procedure Reference: Create an Advanced Filter or Sort

To create an advanced filter or sort, perform the following steps:

1. Open the Datasheet or Form view you want to filter.

2. Open the Advanced Filter/Sort dialog box.

3. In the filter window, clear the grid.

4. Enter a field name in the grid. You can use any of the following techniques:

• On the list in the top of the window, double-click a field name.

• In the Field row, type a field name.

• From the list in the top of the window, click and drag a field name.

• From the drop-down list for the Field row, choose a field name.

5. Enter a value in the Criteria row for the field.

• For an And filter, enter criteria for two fields.

• For an Or filter, enter an additional condition in the Or row for whateverfield it applies to.

6. If necessary, sort records.

7. Apply the filter.

Using Criteria to Filter RecordsCriteria are conditions that identify the records you want to find.

Criteria Finds Values Example= with the exact match =11/29/1961

LESSON 10

Lesson 10: Finding and Joining Data 193

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 209: Access Level 1

Criteria Finds Values Example< less than <K

<= less than or equal to <=2500

> greater than >K

>= greater than or equal to >=2500

<> not equal to <>Michigan

Is Null that are empty

Between And within a range Between 5/1/2001 And 8/31/2001

Removing a FilterClick Remove Filter if you need to remove a filter before applying a new one. You cancheck the bottom of a Datasheet view or Form view to see if you are looking at a filterview.

ACTIVITY 10-1Finding Data with Filters

Data Files:

• Join.mdb

Scenario:You have a couple of burning questions on your mind related to project management and salesterritories. You decide to use filters on your various database tables to get answers. First, intblBookProjects, 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, you’re considering redistricting the sales territories and want to see whetheror not adding the Canadian customers to Lauren’s sales territory would be too much.

What You Do How You Do It

1. In Join.mdb, apply a filter to

tblBookProject to include only

those projects managed by Sarah

Rubenstein.

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.

LESSON 10

Microsoft® Office Access 2003 - Level 1194

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 210: Access Level 1

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 twotabs, Look For and Or. The Look For tab isselected.

c. Place the insertion point in the Salesper-

son field and display the drop-down list.

d. Select en1-20.

e. Click the Apply Filter button.

5. How many records matched this filter?

a) 3

b) 5

c) 6

d) 7

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

Lesson 10: Finding and Joining Data 195

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 211: Access Level 1

c. Display the Country drop-down list and

select Canada.

d. Click the Apply Filter button.

The Remove Filter and Apply Filter buttonsfunction as one toggle button.

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.

a. Click the Remove Filter button to viewall 14 records again.

b. Close the table, without saving the

changes.

ACTIVITY 10-2Finding Data with Advanced Filters

Data Files:

• Join.mdb

Setup:The Join.mdb database is open in Access.

Scenario:As President of the Book Source business, development costs are always an area of concernfor you. You decide to gather some historical data by combining criteria about costs and dates.You are working with tblBookProject and you want to find any projects whose developmentcosts were greater than $12,000 and whose product ship date was after January 1, 1999.

LESSON 10

Microsoft® Office Access 2003 - Level 1196

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 212: Access Level 1

What You Do How You Do It

1. In tblBookProject, use the Advanced

Filter dialog box to set the criteria

for the development costs to

greater than $12,000.

a. Open tblBookProject.

b. Choose Records→Filter→Advanced

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

a. Click the Remove filter button.

b. Close tblBookProject without saving the

changes.

LESSON 10

Lesson 10: Finding and Joining Data 197

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 213: Access Level 1

TOPIC BCreate Query JoinsYou have worked with filters to eliminate from view the records that don’t match your criteria.You can do something similar when two or more tables are related to each other to display thedesired data from each. In this topic, you’ll use query joins to accomplish this goal.

When you run a query to find records in related tables, by default, Access looks for recordsthat have matching values on both sides of the relationship. However, by knowing how to usethe different types of query joins, you can control the records that will be displayed as output.This enables you to again find exactly the data you want—not more and not less.

Query JoinsA join is a temporary relationship you create between two tables in a query that do not alreadyhave an established relationship or a common field with the same name and datatype. Tablesjoined in a query are related only within that query and nowhere else. The type of join indi-cates which records the query selects or performs an action on.

Creating a query join will not establish a permanent relationship between the tables. Permanent relationships canbe created only in the Relationships window.

Inner JoinDefinition:

An inner join is a join that selects only those records from both tables that havematching values. Records with values in the joined field that do not appear in bothtables will be excluded. One or more fields can serve as the join fields.

The inner join is alternately known as an equi-join.

The inner join is the default join type in Access.

LESSON 10

Microsoft® Office Access 2003 - Level 1198

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 214: Access Level 1

Example:

Figure 10-1: Conceptual diagram of an inner join between Projects data andEmployees data.

Analogy:Consider a business that employs both managers and engineers—and some people whoare both. An inner join is like the union of this set: it selects the set of people who areboth managers and engineers and provides information about them in both roles.

Outer JoinDefinition:

An outer join selects all the records from one table and only those records in the sec-ond table that have matching values in the joined field. In a left outer join, the selectedrecords will include all records of the first table. In a right outer join, the selectedrecords will include all records of the second table. One or more fields can serve asthe join fields.

LESSON 10

Lesson 10: Finding and Joining Data 199

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 215: Access Level 1

Example: Left Outer Join

Figure 10-2: Conceptual diagram of a left outer join between Projects dataand Employees data.

Analogy:Consider again the business that employs both managers and engineers. A left outerjoin selects the set of all managers, providing information about them, but in the caseof managers who are also engineers, it provides additional information about them.

Example: Right Outer Join

Figure 10-3: Conceptual diagram of a right outer join between Projects dataand Employees data.

Analogy:Consider again the business that employs both managers and engineers. A right outerjoin selects the set of all engineers, providing information about them, but in the caseof engineers and also managers, it provides additional information about them.

LESSON 10

Microsoft® Office Access 2003 - Level 1200

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 216: Access Level 1

How to Create Query JoinsProcedure Reference: Create a Join Line Between Tables in a Query DesignView

To create a join line between the tables in the query Design view:

1. Display the query in Design view.

2. Drag a field from one table to the matching field in the other table.

Procedure Reference: Change the Join Type

To change the join type of a query:

1. Display the query in Design View.

2. Click the Join Type button to display the Join Properties dialog box.

3. Click 2 or 3, depending on which table you want to show all the records for.

4. Click OK.

Cross-product QueryWhenever you construct a query that involves two or more tables, you must tellAccess how to join the information in the tables. If you fail to do so, you will producea query results datasheet in which every record in table A is joined with every recordin table B. This is called a cross- or Cartesian product.

Changing the Join TypeThe Join Properties dialog box enables you to specify how two tables are to be joinedin 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 drawnstarting from the table on the left, the second option represents the left outer join andthe 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 “leftside”, and the right outer join includes all records from the table on the “right side”.

Removing Joins in QueriesIf you need to delete the join between tables in a query, right-click the join linebetween them. From the shortcut menu, choose Delete (or, from the main menu,choose Edit→Delete); or, in query Design view, select the join line and then press theDelete key. Deleting a join line in a query affects only that query.

The broken join is effective only for the query in which you broke the join.

LESSON 10

Lesson 10: Finding and Joining Data 201

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 217: Access Level 1

ACTIVITY 10-3Creating an Inner Join and an Outer Join

Data Files:

• Join.mdb

Setup:The Join database window is maximized.

Scenario:Suppose you’ve created a select query, qselBooks, that enables you to view what books havebeen purchased from which customers. It uses the following tables: tblBookProject (29records) and tblBookSales (100 records). However, the tables are not joined. What you want tosee is book information for books that have a sales record, and then for all books includingthose that lack any sales records.

What You Do How You Do It

1. Run the existing query. a. Open qselBooks in design view and

observe its current structure.

b. Run the query.

2. records are in the query results.

3. True or False? The reason this many records appear is because no join between thetables has been established, so each record from tblBookProject is combined with eachrecord from tblBookSales.

True

False

LESSON 10

Microsoft® Office Access 2003 - Level 1202

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 218: Access Level 1

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

5. Join the tables and then run the

query again.

a. If necessary, change to Design view and

drag Part# from the tblBookProject field

list to PartNumber in the tblBookSales

field list.

You must drag in this direction to create the correctjoin.

b. Run the query.

LESSON 10

Lesson 10: Finding and Joining Data 203

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 219: Access Level 1

6. Only books with sales are displayed. How many records for such books are in theresult?

a) 29

b) 90

c) 100

d) 2900

7. Change the join type to an outer

join so that the query will list all therecords from tblBookProject and onlythe matching records from the joinedtable, tblBookSales.

a. Change to Design view and double-click

the line that joins the two tables.

b. Select option 2. Click OK.

c. Verify that the arrowhead points to the

table contributing only the matching

records. This is a left outer join.

d. Run the query.

8. All the records from tblBookProject are displayed. Only the matching records fromtblBookSales are displayed. How many results are displayed?

a) 29

b) 100

c) 108

d) 2900

LESSON 10

Microsoft® Office Access 2003 - Level 1204

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 220: Access Level 1

9. Save and close the query. a. Save the query as qselMyOuterJoin

b. Close the query.

TOPIC CJoin Unrelated TablesYou know how to retrieve data from multiple, related tables by using a query join. In thistopic, you will consider how to handle the case where two tables have the desired data, but areonly indirectly related to each other.

Consider the case where you have two tables with the data you need, but the tables are notdirectly related to each other by a common field. To join such unrelated tables, you can ofteninclude an additional table as a middle-man to create the link relationship. Doing so willenable you to retrieve exactly the data that you desire from multiple, unrelated tables.

How to Join Unrelated TablesProcedure Reference: Join Unrelated Tables by Adding a Table to a QueryDesign

To join unrelated tables, you can add a table to the query design:

1. Open a query in Design View.

2. Click the Show Table button.

3. Select the table and click Add.

4. If necessary, join the tables.

5. Complete your query design by adding the fields you want to display to the grid.

You can create more than one join between a pair of tables.

LESSON 10

Lesson 10: Finding and Joining Data 205

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 221: Access Level 1

ACTIVITY 10-4Joining Two Unrelated Tables

Data Files:

• 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. Thefield Part# is in tblBookProject and the field CustomerName is in tblCustomer. However, thetables tblBookProject and tblCustomer do not have any fields in common.

What You Do How You Do It

1. View the current design of

qselCustomerNames and add

tblBookSales to the query design

grid.

Just as a bridge connects two places, theBook Sales table is like a bridge betweenthe tables whose data you want to use.

a. In Design view, display the query

qselCustomerNames. The two tables donot share a common field.

You must open the query in Design view; oth-erwise, you will get an error message.

b. Click the Show Table button .

c. Select tblBookSales. Click Add. Click

Close.

d. The tables are already related. Verify

that the tables are automatically joined

together.

LESSON 10

Microsoft® Office Access 2003 - Level 1206

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 222: Access Level 1

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.

b. Verify that 100 records are displayed.

Save the updated query.

c. Close the query.

4. True or False? Books that lack sales will not appear because this is an equi-join and nota left-outer join.

True

False

LESSON 10

Lesson 10: Finding and Joining Data 207

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 223: Access Level 1

TOPIC DRelate Data Within a TableYou have worked with a range of join types, from the default inner join to more complicatedouter 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 ofsituation.

Consider the case where all the data you need is in a single table, but you need to be able torelate columns in that table to each other to extract the desired records. For example, perhapsan employee table has both an ID field for each record and also a field showing the ID of thatemployee’s supervisor. To retrieve the desired data, you need to somehow relate the data toitself. Fortunately, you can do this with a special kind of join designed for exactly this kind ofuse.

Self JoinsDefinition:

A self join is a join that relates data in a table to itself. A table is joined to itself basedon a field or combination of fields that have duplicate data in different records. Thedatatype of the inter-related columns must be the same.

Example:

Figure 10-4: A self join that compares records within a table. The EmpID andHireByID fields are the same datatype and contain the same data across differ-ent records.

LESSON 10

Microsoft® Office Access 2003 - Level 1208

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 224: Access Level 1

How to Relate Data Within a TableProcedure Reference: Create a Self Join

To create a self-join:

1. Open a query in Design View.

2. Click the Show Table button.

3. Add the table to your query so that it appears twice.

4. Join the related fields.

5. Complete your query design by adding the fields you want to display to the grid.

Using an AliasWhen you use the same table twice in a query, it is a good idea to change the name ofone of the tables. Assigning an alias to a table in the query does not rename the under-lying table.

ACTIVITY 10-5Creating a Self Join

Data Files:

• Join.mdb

Setup:The Join database window is maximized.

Scenario:You need to design a query to display supervisor names for each employee. The tblSupervisorstable contains information about employees and their supervisors. The supervisor is identifiedaccording to his or her Employee ID number.

LESSON 10

Lesson 10: Finding and Joining Data 209

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 225: Access Level 1

What You Do How You Do It

1.

In order to design a query to display supervisor names for each employee, which twofields 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.

a. In Design view, display qselSupervisors.

You must open the query in Design view; oth-erwise, you will get an error message.

b. Click the Show Table button.

c. Select tblSupervisors. Click Add.

d. Close the Show Table dialog box.

You may want to make this second table listwider in order to see its full title.

3. Assign an alias of Managers to the

second table.

a. Right-click the tblSupervisors_1 field list

to display the object menu. Choose

Properties.

LESSON 10

Microsoft® Office Access 2003 - Level 1210

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 226: Access Level 1

b. In the Alias property box, type Managersand 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.

b. Drag the SupervisorId field from the

tblSupervisors field list to the Id field of

the Managers table.

LESSON 10

Lesson 10: Finding and Joining Data 211

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 227: Access Level 1

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.

c. From the Managers field list, add

LastName to the third Field cell of the

query design grid.

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

d. Close the Field Properties dialog box.

e. Set the caption property for the

LastName field from tblSupervisors to be

LastName.

LESSON 10

Microsoft® Office Access 2003 - Level 1212

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 228: Access Level 1

f. Run the query.

You might need to expand the column width to viewthe complete caption.

7. Save and close the query and the

Join database.

a. Save the query as qselMySelfJoin

b. Close the query.

c. Close the Join database.

Lesson 10 Follow-upIn this lesson, you focused on finding and displaying data using filters and queries. Being ableto filter data means that you can locate and work with the specific information that you’reinterested in at a particular time. By using query joins, you can obtain data from multiplerelated tables or from related data in a single table. Doing so greatly expands the kind of datareports you can create.

1. You can use filters and query joins whenever you find yourself thinking, “I need toknow,” or when you’re asking who, what, where, when, and how questions. What aresome of the questions you might ask in your day-to-day work that could be answeredby putting a filter to work or by joining tables for a query?

2. Can you think of any scenarios with databases you will be using that would requirerelated data from multiple tables and, therefore, will likely benefit from a query join?

LESSON 10

Lesson 10: Finding and Joining Data 213

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 229: Access Level 1

Microsoft® Office Access 2003 - Level 1214

NOTES

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 230: Access Level 1

Creating Flexible Queries

Lesson Objectives:In this lesson, you will create flexible queries to display specified records; allow for user-determined query criteria; and add, update, and delete data with queries.

You will:

• Set select query properties to show top and bottom values and show records that containunique values in selected fields.

• Create queries that accept criteria from the user on the fly.

• Create action queries that update, add, and delete multiple records in an underlying table.

Lesson Time1 hour(s)LESSON 11

LESSON 11

Lesson 11: Creating Flexible Queries 215

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 231: Access Level 1

IntroductionYou’ve worked with simple queries, and you’ve retrieved related data from multiple tablesusing query joins. Flexible queries can do even more than this, however, and in this lesson youwill see how to use queries to automatically return subsets of data, accept criteria from theuser at runtime, and modify the data in a table.

As a member of the Human Resources department, you have been asked to find the people inyour resume database that have networking or HTML skills. Instead of using two separate que-ries, you can use the same flexible query twice by allowing for dynamic criteria. Once adecision is made on who will be hired, an additional query could be used to automaticallyupdate their records to reflect this change in status.

TOPIC ASet Select Query PropertiesAt this point, you are familiar with the most common type of query, the select query. In thistopic, you’ll use select query properties to display only the top or bottom values, select recordswith unique values, and suppress records that contain duplicate information.

There are some types of select queries that you’ll find yourself creating again and again. Forexample, showing the top ten salespeople on your staff or the bottom five products in yourinventory. Or consider a case where you need to show the records that have a unique value fora particular field, such as the books that have an author who hasn’t written any other titles. Atother times you’ll want to find records with non-unique values in a field, perhaps to helpremove duplicate entries. While select queries could be written manually to achieve all of theseresults, you can save a lot of time and energy by using the built-in select query properties thatAccess provides.

Select Query PropertiesAccess provides properties you can set for a select query to restrict what records will beshown.

Table 11-1: Select Query Properties

Property DescriptionTop Values 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 num-ber of records to show (for example, 15) or as a percentage of therecords returned by the query (for example, 20%). To show top valuesor bottom values, set values of either Ascending or Descending for theSort cell of the query design grid for that field.

Unique Values A query property that when set to Yes will restrict the records returnedto those that have unique values in the fields in the query design grid.

Unique Records A query property that when set to Yes will restrict the records returnedto those that have unique values in all fields in the underlying tables orqueries. That is, the records in those tables are themselves unique.

LESSON 11

Microsoft® Office Access 2003 - Level 1216

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 232: Access Level 1

How to Set Select Query PropertiesProcedure Reference: Show Top or Bottom Values

You can show top or bottom values in a query as follows:

1. Open a query in Design view.

2. Provide a value for the Top Values property box on the toolbar:

• Enter a number or a percent value. (The default value is All.)

• Select an option value.

Procedure Reference: Show Records that Contain Unique Values

To show records that contain unique values in selected fields:

1. Open a query in Design view.

2. Display the Query Properties dialog box.

3. Set the Unique Values property to Yes.

Procedure Reference: Show Unique Records Only

To suppress records that contain duplicate information:

1. Open a query in Design view.

2. Display the Query Properties dialog box.

3. Set the Unique Records property to Yes.

ACTIVITY 11-1Showing Top Values

Data Files:

• Flex.mdb

Setup:Access is open and maximized.

Scenario:For an upcoming presentation you need a query that will display the top five book customersfrom your database, sorted by total sales.

What You Do How You Do It

1. Set the qselBookSales query to dis-

play the customer name and the

total number of books sold to each

customer.

a. Open Flex.mdb.

LESSON 11

Lesson 11: Creating Flexible Queries 217

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 233: Access Level 1

b. Open qselBookSales in Design view.

There are four field lists, so this query can displayinformation 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.

e. Click the Totals button to add theTotal row to the design grid.

f. From the Total drop-down list in theQuantitySold column, select Sum to addthese values in the datasheet.

g. Run the query.

2. records are included in the query results.

LESSON 11

Microsoft® Office Access 2003 - Level 1218

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 234: Access Level 1

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 inquantity sold are displayed.

a. Return to Design view.

b. In the QuantitySold field column, choose

Descending as the sort value, and then

run the query.

c. Save the query as qselMyTop5Values

d. Close the query.

LESSON 11

Lesson 11: Creating Flexible Queries 219

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 235: Access Level 1

ACTIVITY 11-2Showing Records with Unique Values

Data Files:

• 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 byeach customer. The number of times a title was ordered and the dates on which it was orderedaren’t important; you only want to see one record for each customer and title combination.

What You Do How You Do It

1. Open

qselCustomerNamesAndBooks.

a. Open qselCustomerNamesAndBooks.

b. Examine the results and look for dupli-

cate combinations of customer and book

title.

2. There are total records returned by this query.

3. There are records with a customer of Allendale Books and a book title of “ImprovingYour Tennis Game.”

4. In the design of the query, remove

the TransactionDate field.

a. Switch to Design view.

b. Place the insertion point in the

TransactionDate column.

c. Choose Edit→Delete Columns.

LESSON 11

Microsoft® Office Access 2003 - Level 1220

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 236: Access Level 1

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

ues property to Yes.

You can type “yes,” select Yes from the property’sdrop-down list, or select No and type “y.”

d. Close the Query Properties dialog box.

e. Run the query.

6. There are now total records displayed by the query.

7. There is now record with a customer of Allendale Books and a book title of “Improv-ing Your Tennis Game.”

8. Save and close the query. a. Save the query as

qselMyCustomerNames

b. Close the query.

LESSON 11

Lesson 11: Creating Flexible Queries 221

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 237: Access Level 1

TOPIC BCreate Parameter QueriesIn the queries you’ve used so far, you’ve entered criteria in the query design grid to select agroup of records. In this topic, you will enable the user to input the criteria to be used by thequery.

You may find, in some cases, that it would be valuable if you could select a group of recordsyou choose on the fly, by supplying a criteria value for a field at runtime. For example, sayyou regularly need to retrieve all records in a table for each U.S. state. You could create aseparate query for each of the fifty states, but a far better approach would be to create onequery that will ask the user for the state he is interested in. Doing so will save you a lot ofdevelopment time and let you create a leaner database.

Parameter QueriesDefinition:

A parameter query is a flexible query that prompts the user for additional criteria. Amessage or command is placed in the criteria row beneath the applicable field, withopening and closing brackets [ ] around it. When the query is run, this text appears asa prompt, awaiting input from the query user. A parameter query can prompt for morethan one criterion, with a separate dialog box displayed for each criterion.

Example: Single Parameter Query

Figure 11-1: A parameter query that generates a prompt for the user to entera State criterion.

LESSON 11

Microsoft® Office Access 2003 - Level 1222

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 238: Access Level 1

Example: Multiple Parameter Query

Figure 11-2: A parameter query that generates prompts for the user to enterCity and State criteria.

The Like Operator and WildcardsYou can use the Like operator with one or more wildcards to display query results from inex-act criteria. The Like operator will search for records with a value in a field that follow thepattern set by the wildcards used. (See Table 11-2.)

You can use wildcard characters in the Criteria cell for select queries or in response to parameter query prompts.

Table 11-2: Common Wildcards

Character Description Example of Use* Matches any number of characters

but can only appear at the begin-ning or the end of the string.

Like “S*” would match Stone, Smith, andSullivan.

? Matches any single alphabeticcharacter and can appear in themiddle of a string.

Like “B?nd” would match Band, Bind, andBend, amongst others.

[ ] Matches any single character pro-vided in the brackets.

Like “B[ai]nd” would match Band and Bind,but not Bend.

[! ] Matches any character not pro-vided in brackets.

Like “B[!a]nd” would match Bend and Bind,but not Band.

[ - ] Matches any single character fromwithin the range provided inbrackets.

Like“B[a-d]nd” would match Band, Bbnd,Bcnd, and Bdnd only.

LESSON 11

Lesson 11: Creating Flexible Queries 223

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 239: Access Level 1

Character Description Example of Use# Matches any single numeric char-

acter and can appear in the middleof a number.

Like “9#7” would match 907, 917, 927, andso on.

Ampersand and AsteriskYou can use the ampersand (&) character along with the asterisk wildcard to link moredata to criteria specified by the user as part of a parameter query. For instance, toprompt the user for an area code and to find all the telephone numbers listed for thatarea code, you could use the following criterion: Like [Enter an Area Code]&*. Theampersand links the area code from the user with the asterisk wildcard.

Between... And OperatorAnother valid operator in a parameter query is the Between... And operator. To ask fora range of values in a single cell, use the Between ... And operator with the bracketedprompts (for example, Between [Start Date] and [End Date]).

How to Create Parameter QueriesProcedure Reference: Create and Run a Parameter Query

To create and run a parameter query:

1. Open a query in design view.

2. Click in the Criteria cell for the appropriate field(s), and type the desired expres-sion within square brackets ([ ]).

When the query is run, Access displays this text to prompt the user for criteria. The text of theprompt must be different from the field name, although it can include the field name.

3. Run the parameter query.

4. When you are prompted to enter a parameter value, enter the value of the datayou want to view and click OK.

The Prompt MessageWhen you specify a prompt message, it should be brief but meaningful. Access candisplay 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 messagecannot be the same as the field name.

The Zoom BoxThe Zoom dialog box enables you to type and view the entire expression. Use theZoom dialog box when an expression is too long to be displayed completely in thecell. Another way to display the Zoom dialog box is to right-click the cell and chooseZoom from the shortcut menu.

LESSON 11

Microsoft® Office Access 2003 - Level 1224

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 240: Access Level 1

ACTIVITY 11-3Creating a Single-parameter Query

Data Files:

• Flex.mdb

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 spe-cific customer name. This query uses the Flex database, which contains multiple tables todisplay the fields CustomerName, BookTitle, and TransactionDate, and sorts the records bycustomer name and transaction date. Rather than needing multiple queries, a better approachwould be to create a parameter query that prompts the user to specify which customer name touse as a criterion.

What You Do How You Do It

1. Run the existing qselCustomerOrder

query and open it in Design view.

a. Open qselCustomerOrder to see itsresults.

b. Switch to design view.

2. Modify this query to have it prompt

for a customer name each time it

runs. Run the query using BookWorld as the customer name.

a. In the Criteria cell for the CustomerNamefield, type [Enter a Customer Name]

b. Run the query.

LESSON 11

Lesson 11: Creating Flexible Queries 225

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 241: Access Level 1

c. In the Enter Parameter Value dialog box,type Book World

d. Click OK.

3. Run the query again; this time pro-

viding Jamison Books as the

customer name.

a. Press Shift+F9 to run the query again.

b. In the Enter Parameter Value dialog box,type Jamison Books

c. Click OK to view the results.

d. Save the query as qselMyCustomerOrder

e. Close the query.

LESSON 11

Microsoft® Office Access 2003 - Level 1226

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 242: Access Level 1

ACTIVITY 11-4Creating a Multiple Parameter Query

Data Files:

• Flex.mdb

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 moreflexibility. You want a query that will prompt for the first letter of the customer name andprompt for the date of transaction (between two dates).

What You Do How You Do It

1. Set the query to prompt the user

for the first letter of the customer

name.

a. Open qselMyCustomerOrder in Design

view.

b. Place the insertion point in the Criteria

cell of the CustomerName field.

c. To display the Zoom dialog box, right-

click and choose Zoom.

d. Change the parameter criteria to read

Like [Enter the first letter of a Cus-tomer Name]&*

e. Click OK.

LESSON 11

Lesson 11: Creating Flexible Queries 227

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 243: Access Level 1

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

actions dated between 4/1/2001

and 6/30/2001.

a. Run the query.

b. Type b and click OK.

Because the wildcard characters are added to theparameter expression, you need to enter only thefirst letter of the desired customer name.

c. To enter a start date, type 4/1/2001 and

click OK.

d. To enter an end date, type 6/30/2001and click OK.

LESSON 11

Microsoft® Office Access 2003 - Level 1228

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 244: Access Level 1

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 CCreate Action QueriesSo far you’ve worked with select queries to create a view of data from one or more tables. Butqueries can be used to change data, as well as to retrieve and display it. In this topic, you’llsee how to use queries to update data, delete records, or add records from one table to another.

Consider the case where a set of records in your products table needs to be altered to reflect a10 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 secondarytable that match a particular primary key. Again, rather than doing this manually, you can savetime by writing a query that locates the desired records and automatically deletes them.

Action QueriesDefinition:

An Action query is a query that modifies data in the underlying table or tables. It per-forms a data operation, instead of selecting data. An action query can be an efficienttool for making data modification in bulk.

Example: Update QueryAn Update query changes specified values in a table for all the records or for thoserecords that match specified criteria.

It is generally a good idea to make a backup of your data before using update and delete actionqueries.

LESSON 11

Lesson 11: Creating Flexible Queries 229

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 245: Access Level 1

Figure 11-3: An Update query that increases prices by five percent.

Example: Append QueryAn Append query copies data from specific fields or complete records from one tableto another.

Figure 11-4: An Append query that copies matching records fromtblProductsExternal to tblProducts.

You can use an append query even if some of the fields in the first table are not contained in the sec-ond table, because Access appends values where the fields match and ignores the other fields.

LESSON 11

Microsoft® Office Access 2003 - Level 1230

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 246: Access Level 1

Example: Delete QueryA Delete query removes records from a table that match selected criteria.

Figure 11-5: A Delete query that deletes matching records in a table.

Make Table QueryA fourth kind of action query is quite different from the others. Instead of modifyingthe data in an existing table, a Make Table query creates a new table from the resultsof the query.

Action Query IconsEach action query has a different icon to alert you that they will modify data. Simplyopening an action query causes the query to be run, modifying the table data. Be care-ful when working with action queries, always opening them in Design view to seewhat they will do first!

How to Create Action QueriesProcedure Reference: Create an Action Query to Update Records

To create an action query that will update selected records:

1. Run a select query to determine that it will affect the desired records.

2. In Design view, click the drop-down arrow next to the Query Type button andselect Update Query.

3. If necessary, modify the query so that the proper fields will be updated with thedesired new data.

4. Click the Run button to run the query.

LESSON 11

Lesson 11: Creating Flexible Queries 231

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 247: Access Level 1

To run an action query, use the Run button rather than the View button. Use View to see a list ofall records that will be updated, but not their new values. Using Run will update the values.

5. When a dialog box appears indicating the number of records that will be affected,click Yes.

6. If desired, save this query.

Add All Fields to the QueryTo add all of the fields from a table to the query design grid, drag the asterisk from thefield list to the field row of the query design grid. This procedure ensures that if youadd or delete fields from a table, the query using that table still includes all of thefields.

When you use the asterisk to add all the fields to the query design grid, and you wantto sort values or specify criteria, you must first add the individual fields to the fieldrow; and then you can define specifications for those fields. To prevent the fields fromappearing twice in the query results, uncheck the Show check box for each.

ACTIVITY 11-5Updating Records with a Query

Data Files:

• Flex.mdb

Setup:The Flex database is open and the query objects are displayed.

Scenario:You’ve just gotten word that all projects beginning with 31 or 34 will have a price increase offive percent. You’ve decided to use an update query to change relevant records intblBookProject. You have an existing query, qselRetailPrice, that you can modify to accomplishthis goal.

What You Do How You Do It

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

LESSON 11

Microsoft® Office Access 2003 - Level 1232

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 248: Access Level 1

e. In the Table Name text box, type

tblMyBackupBookProject

f. Click OK. The copied table has beenadded to the database.

g. Open your original table,

tblBookProject.

2. True or False? For books with part numbers that begin with 31 or 34, the prices rangefrom $25.95 to $45.95.

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 theirresults are permanent, so you’ll want totest an action query first, as a selectquery, to see how your data will changebefore you actually make the change.

a. Close tblBookProject.

b. In the database window, display the

query objects.

c. Display qselRetailPrice in Design view.

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 calcu-late a five percent increase in the bookprice. Run the query.

4. There are records that have a part number that begins with either 31 or 34.

LESSON 11

Lesson 11: Creating Flexible Queries 233

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 249: Access Level 1

5. Running the select query does notchange the prices in the table. Con-

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

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 Tocell, type [BookPrice]*1.05 and press

Enter.

6. Run the update query, save the

query, and view the results.

a. Click the Run button .

b. A dialog box indicates the number ofrecords that will be changed. Click Yes.

c. Save the query as qupdMyPriceIncrease

The object prefix “qupd” indicates that it isnow an update query.

d. Close the query.

e. Open tblBookProject.

7. What is the new range of prices for books with part numbers beginning with 31 or 34?

a) $25.95 to $45.95

b) $27.25 to $48.25

c) $30 to $50

LESSON 11

Microsoft® Office Access 2003 - Level 1234

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 250: Access Level 1

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 5percent.

b) The values in the BookPrice field in the underlying table would again be increased by5 percent.

c) The previous prices would be reinstated: the 5 percent increase in price would berevoked.

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

ing the query objects.

Procedure Reference: Create an Action Query to Append Records

To create an action query that will append records:

1. If desired, run a select query to determine the records that will be appended.

2. In Design view, click the drop-down arrow next to the Query Type button andselect Append Query.

3. In the Append dialog box, select the table you are appending records to. ClickOK.

4. If necessary, modify the query further so that the proper fields will be appendedwith the desired new data.

5. Click the Run button to run the query.

6. When a dialog box appears indicating the number of records that will beappended, click Yes.

7. If desired, save this query.

LESSON 11

Lesson 11: Creating Flexible Queries 235

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 251: Access Level 1

ACTIVITY 11-6Appending Records to a Table with a Query

Data Files:

• 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 structureis identical to tblBookProject. In both tables, the first two digits of the part number for eachbook represents a category of books. For instance, category 41 is devoted to books on modelairplanes and category 43 is comprised of books about mountain biking. The category 41projects are now complete, and you need to add those records from tblNewProjects totblBookProject.

What You Do How You Do It

1. Review the contents of

tblNewProjects.

a. Open tblNewProjects.

b. Verify that the table has seven records,

four with a part number beginning with

41 and three with a part number begin-

ning with 43. Close the table.

2. Create a select query that shows all

fields for all records from

tblNewProjects.

a. With tblNewProjects selected in the data-base window, display the New Object

drop-down list .

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.

LESSON 11

Microsoft® Office Access 2003 - Level 1236

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 252: Access Level 1

3. Use criterion for the PartNumber

field to find records with part num-

bers that begin with 41. Avoid

displaying the PartNumber field

twice in the query datasheet.

a. In the second Field cell, display the drop-

down list and select PartNumber.

b. In the Criteria cell for the PartNumberfield, type 41* and press Enter.

The Like operator and quotation marks areadded automatically.

c. The PartNumber field is set to be dis-played as part of the entire table (basedon the first Field cell). Above the criteriafor the PartNumber column, uncheck the

Show check box.

d. Run the query.

4. records are displayed by this query.

5. Change the select query to an

append query that will add this data

to tblBookProject.

a. Change to Design view and display the

Query Type drop-down list.

b. Select Append Query.

c. In the Append dialog box, from the TableName 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.

LESSON 11

Lesson 11: Creating Flexible Queries 237

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 253: Access Level 1

e. In the Append To cell for the PartNumberfield, delete PartNumber, but do not

delete the Like “41*” criterion below it.

The PartNumber field was included in the secondField cell of the query design grid to supply a crite-rion for the query. It was also included when theasterisk was dragged to the first Field cell.

6. Run the append query, save it, and

view the results.

Access does not automatically refresh theview of the table that has records addedto it.

a. Click the Run button.

b. The warning dialog box indicates the num-ber of records that will be appended.Click Yes.

c. The object prefix “qapp” is used to indi-cate an append query. Save the query as

qappMyAppend

Append queries are often not used again; inthat case, once you have confirmed the results,you can delete the query.

d. Open tblBookProject.

7. The tblBookProject table had 26 records before the append query was run. How manyrecords does it have now?

a) 26

b) 29

c) 30

d) 33

LESSON 11

Microsoft® Office Access 2003 - Level 1238

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 254: Access Level 1

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. If desired, run a select query to determine the records that will be deleted.

2. In Design view, click the drop-down arrow next to the Query Type button andselect Delete Query.

3. If necessary, modify the query further so that the proper fields will be deletedwith the desired new data.

4. Click the Run button to run the query.

5. When a dialog box appears indicating the number of records that will be deleted,click Yes.

6. If desired, save this query.

ACTIVITY 11-7Deleting Records with a Query

Data Files:

• Flex.mdb

Setup:The query qappMyAppend is open in Design view.

Scenario:Projects in category 41 are no longer considered new. They are complete and have been addedto tblBookProject. You now want to remove these records from tblNewProjects.

LESSON 11

Lesson 11: Creating Flexible Queries 239

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 255: Access Level 1

What You Do How You Do It

1. Change qappMyAppend to a delete

query and preview the records that

will be deleted.

a. Display the Query Type drop-down list.

b. Select Delete Query.

The Delete Query choice is on the extendedmenu.

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 wherepart number begins with 41 will bedeleted, click the View button.

2. Run the query and delete the four

records.

a. Change to Design view and click the Run

button.

The deletion is permanent; you cannot retrievedeleted records by using the Undo feature.

b. Click Yes to delete the records.

LESSON 11

Microsoft® Office Access 2003 - Level 1240

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 256: Access Level 1

3. Save the query and verify that the

records were deleted.

a. An object prefix of qdel is used to indi-cate a delete query. Save the query as

qdelMyNewProjects

b. Close the query.

c. To verify that the deletion occurred andthat three records remain, open

tblNewProjects.

d. Close tblNewProjects.

e. Close the Flex database.

Lesson 11 Follow-upIn this lesson, you used select query properties that let you quickly accomplish common taskssuch as showing the top values or showing unique values. You saw that typical select queriesare quite limited because they are static, but that by using a flexible parameter query you canallow for the dynamic entry of one or multiple criteria. By using another type of advancedquery, the action query, you were able to automatically add, update, and delete records in atable. All of these query types have expanded your ability to work with data in flexible andpowerful ways.

1. Considering your current or planned Access projects, can you foresee needing to cre-ate parameter queries? In what contexts and why?

2. Considering your current or planned Access projects, can you foresee needing to cre-ate action queries that add, update, or delete data? In what contexts and why?

LESSON 11

Lesson 11: Creating Flexible Queries 241

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 257: Access Level 1

Microsoft® Office Access 2003 - Level 1242

NOTES

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 258: Access Level 1

Improving Your Forms

Lesson Objectives:In this lesson, you will enhance the appearance, data entry, and data access capabilities of yourforms.

You will:

• Add text and graphic elements including lines, rectangles, and pictures to a form.

• Restrict data entry in forms by adding Combo Box and Option Group controls.

• Add a command button to a form.

• Add a subform to a form.

Lesson Time40 minutesLESSON 12

LESSON 12

Lesson 12: Improving Your Forms 243

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 259: Access Level 1

IntroductionIf you’re lucky, you might never need to customize a form. The forms you create withAutoForm or the Form Wizard might work perfectly for you, but chances are you’ll end up inthe Form Design view window to improve your forms at some point. This lesson will providean 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 alsoenable related data from multiple tables to be edited in a single form window, allowing usersto more efficiently add and update records.

TOPIC AEnhance the Appearance of a FormYou’ve created your own forms, but if you used the AutoForm feature of a Form Wizard, yourforms will more than likely look a little bland. You may have tinkered with them a bit in FormDesign view already, but in this topic, you will add text and graphics to really improve theirappearance.

Although unnecessary distraction should be avoided, an entirely plain form might not be themost 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 toenter and manipulate information. See Figure 12-1.

Figure 12-1: A form with a heading, graphic, and shaded rectangle grouping box.

LESSON 12

Microsoft® Office Access 2003 - Level 1244

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 260: Access Level 1

Form Design ViewThe Form Design view window (see Figure 12-2) is the design environment for makingchanges to a form’s design. It provides numerous tools to help you improve the design of yourforms 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 mostcommonly used.

Tool DescriptionForm Design toolbar Provides buttons for common tasks like View, Save, and Print. It also

has special buttons to open Design tools like the Toolbox and Fieldlist.

Formatting toolbar Has buttons for typical formatting jobs, like changing font sizes andcolors.

Toolbox Has buttons for placing labels, fields, combo boxes, command but-tons, and other special-purpose objects in a form. This is where youtypically go to find controls to add to your form.

Field list A handy way to reference fields in the Design view window. Showsfields from the table or query that is the source of data for the formyou are working on.

Properties dialog box Each object in a Form Design view window has its own propertiesdialog box with tabs that list the properties you can change for theobject.

Control Wizards toggle button Often when you click a button in the Toolbox to place an object onthe form design, you get some help from one of the Access wizards.

LESSON 12

Lesson 12: Improving Your Forms 245

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 261: Access Level 1

Figure 12-2: The Form Design view window.

Formatting PalettesA formatting palette can be used to enhance forms and reports with color or othereffects from a predetermined set of options. The Formatting toolbar includes severalbuttons that offer palettes. See Table 12-1.

Table 12-1: Buttons on the Formatting Toolbar that Display a Palette

Button Name DescriptionFill/Back Color Changes the background color of a control or

section.

Font/Fore Color Changes the color of text in a control.

Line/Border Color Changes the color of a control’s border.

Line/Border Width Changes the thickness of a control’s border.

Special Effect Controls whether a control or section appearsflat, raised, sunken, etched, shadowed, orchiseled.

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 recentcolor you selected from the palette. You don’t need to use the drop-down paletteto select the same color.

LESSON 12

Microsoft® Office Access 2003 - Level 1246

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 262: Access Level 1

• To avoid clicking the Palette toolbar button each time you need to display a givenpalette, you can drag that palette away from the button to keep it displayed whileyou design the form or report.

Unbound ControlsAn unbound control is not bound or connected to a field or an expression. They candisplay informative text (such as in a label), a rectangle, a line, a command button, ora picture such as a company logo, which might be stored in a bitmap file, separatefrom any tables.

Section SelectorThere might be times when you need to select an entire section of a form or report—for example, the Header, Footer, or Detail sections. To select a specific section of theform or report, use the section selector—a box in the left of the section bar in Form orReport Design view. After you select a section, you can display the properties dialogbox for that section.

You can also display the properties for that section automatically by double-clicking its section selectorbox.

Grouped ControlsGrouped controls are two or more controls that can be treated as one unit whiledesigning a form or report. You can select the group instead of selecting each indi-vidual control as you’re arranging controls or assigning properties. You can group textboxes and other controls on a form or report by using the Group command on the For-mat menu. When you carry out that command, a black box appears around all of theselected objects. This is now considered a group for the purposes of moving themaround the layout window and applying properties such as text font color.

To select multiple adjacent controls, place the mouse pointer on the vertical or horizontal ruler andwhen the mouse pointer changes shape to a horizontal or vertical arrow, click the mouse button. Thismethod selects all the controls that have been placed in the same horizontal or vertical position.

How to Enhance the Appearance of a FormProcedure Reference: Work with Lines, Boxes, and Labels

To work with lines, boxes, and labels, as you design forms with a variety of features:

1. From the toolbox, select the tool you would like to work with.

2. Click in the Design view window where you want the object (line, box, and soon) to start.

3. Depending on the object, drag to the end or the other opposite corner and releasethe mouse button.

4. If desired, apply special effects to the control.

Procedure Reference: Add an Image

To add an image to a form in Design view:

1. From the toolbox, choose the Image tool.

LESSON 12

Lesson 12: Improving Your Forms 247

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 263: Access Level 1

2. Click in the form where you want the image displayed.

3. Browse to the desired file’s location, select it, and click OK.

4. Double-click the image to display its properties.

5. Alter any properties as needed and then close the properties dialog box.

6. If necessary, resize and relocate the image on the form.

ACTIVITY 12-1Adding Text and Graphic Elements

Data Files:

• Improve.mdb

Setup:Access is open.

Scenario:You’ve started a form, frmSalesAndProfit, that could be used for order entry at the BookSource. You’ve identified 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.

• Surround several of the remaining controls with a rectangle to enhance the visualdesign of a form.

• Add a label, Book Source Sales, and an image to the top of the form.

What You Do How You Do It

1. In the Improve database, open

frmSalesAndProfit in Design view.

This form is based on a multiple-table query.

a. Open the Improve database. Maximize

the database.

b. Open frmSalesAndProfit, and then

switch to Design view.

LESSON 12

Microsoft® Office Access 2003 - Level 1248

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 264: Access Level 1

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 Format→Group.

c. Deselect the group by clicking in any

open gray space. There is no indicationthat this set of controls is considered agroup; it has no visible boundary.

d. Click the OrderID label control to selectthe group.

Any of the controls could be clicked to select thegroup.

e. You can still work with each controlindividually. Click the OrderID label con-

trol again. Press Delete. The group stillexists without this deleted control.

f. Click Undo .

g. Place the mouse pointer on the group

boundary. When the mouse pointerchanges to a hand, drag to the right. Thismoves the group of controls as a singleunit.

h. Click Undo.

i. With the group still selected, select a red

font color .

If the Formatting toolbar is not displayed,choose View→Toolbars→Formatting (Form/Report).

LESSON 12

Lesson 12: Improving Your Forms 249

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 265: Access Level 1

j. Choose Format→Ungroup. When youungroup controls, the group rectangle isdeleted.

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 .

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.

4. Format the rectangle with color and

a shadowed effect.

a. On the Formatting toolbar, next to theSpecial Effect button, click the drop-

down arrow to display the special effectsoptions for the rectangle control.

b. Select Special Effect: Shadowed. Therectangle control changes its appearanceand remains selected.

c. On the Formatting toolbar, next to theLine/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.

5. Make room to add a label and pic-

ture control to the Form Header

section.

a. The Form Header is currently hidden. Toview it, choose View→Form Header/

Footer.

LESSON 12

Microsoft® Office Access 2003 - Level 1250

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 266: Access Level 1

b. Double-click the Form Header section

selector to display the properties for theForm Header section.

c. If necessary, select the Format tab.

Instead of changing the value in the propertiesdialog box, you could drag the Detail sectionbar down to the 2” mark on the vertical ruler.

d. Change the Height setting to 2”

e. Close the properties dialog box.

6. In the upper-left corner of the FormHeader section, create a label that

reads Book Source Sales.

a. Choose the Label tool .

b. Click the mouse pointer in the upper-

left corner of the Form Header section.

c. Type Book Source Sales and press Enter.

d. From the Font Size drop-down list, select

20.

e. Choose Format→Size→To Fit.

7. Insert the Book file image and size

it so that it is smaller.

a. Choose the Image tool .

LESSON 12

Lesson 12: Improving Your Forms 251

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 267: Access Level 1

b. In the Form Header section, click near

the 3” horizontal mark at the top of the

section.

c. The contents of the My Documents folderare displayed. From the list of files,select Books.

d. Click OK.

You can change the object’s position by drag-ging it or by using Ctrl+arrow keys.

e. Double-click the image to display itsproperties.

f. If necessary, select the Format tab.

g. Set the Size Mode property to Stretch.

h. Close the properties dialog box.

i. Place the mouse pointer on the lower-

right corner of the image until it turns

into a double-ended arrow and drag up

and to the left to make the graphicsmaller.

j. Drag the top border of the Detail section

up under the graphic.

LESSON 12

Microsoft® Office Access 2003 - Level 1252

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 268: Access Level 1

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.

TOPIC BRestrict Data Entry in FormsYou’ve seen how to improve the appearance of your forms by adding text and graphicelements. But even more important than appearance is how well your forms can produce accu-rate data in your tables. In this topic, you will use special kinds of controls to restrict dataentry.

In some cases, users of a form need the freedom to enter any value they desire in a text box(for example, a name field). However, in other instances you can drastically reduce data-entryerrors by restricting the possible values that can be entered by using a set of buttons or othersuch control. Doing so can also greatly increase the efficiency of users of the form, since theyare being presented with a simple choice of preset options and do not need to remember theset of valid values they can enter.

LESSON 12

Lesson 12: Improving Your Forms 253

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 269: Access Level 1

Control WizardsWhen 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 Wizardson 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, commandbutton, chart, subreport, and subform.

Combo Box ControlDefinition:

A Combo Box control is a form control that provides a combination of a text box towhich a drop-down list of choices is attached. You can type in a value or choose fromthe list. The list is displayed only when you click the drop-down arrow. Combo boxescan display more than one column of values, but only one column will provide thevalue to be stored for that field. A combo box is typically accompanied by a labelcontrol.

Example:

Figure 12-3: A combo box that can be used to assign a product category foreach product record.

List Box ControlDefinition:

A List Box control is a form control that displays a list of values to choose from. It issimilar to a combo box, but it does not allow direct typing of values and it can displaymultiple rows. A list box is typically accompanied by a label control.

LESSON 12

Microsoft® Office Access 2003 - Level 1254

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 270: Access Level 1

Example:

Figure 12-4: A list box that can be used to assign a product category for eachproduct record.

Option Group ControlDefinition:

An option box group is a type of form control that consists of a group frame contain-ing option buttons, check boxes, or toggle buttons. You can select only one element inthe option group; therefore, you should use an option group when only one choice ispossible within the group. To simplify data entry, one option can be set as the default.A label for the option group is typically provided.

Although you can place check boxes in the group, it is usually better to use option buttons or togglebuttons. Windows users have come to expect that, with square boxes, they can choose more than oneoption, and that with option buttons they can choose only one.

LESSON 12

Lesson 12: Improving Your Forms 255

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 271: Access Level 1

Example:

Figure 12-5: An option group can be used to restrict the possible values forthe Reason field in a table for employee time off.

How to Restrict Data Entry in FormsProcedure Reference: Add a Combo Box or List Box Control

To add a Combo Box or List Box control based on a table or query to a form inDesign view:

1. If necessary, activate the Control Wizards button.

2. In the toolbox, click the Combo Box (or List Box) button.

3. Click in the form to place the control in the desired location.

4. Select the I Want The Combo Box To Look Up The Values In A Table Or Queryoption. Click Next.

5. Choose the table or query that will provide the values. Click Next.

6. Choose the field(s) to display in the control. Click Next.

7. Set any desired sort criteria for the items in the control. Click Next.

8. If desired, uncheck Hide Key Column.

9. If necessary, double-click column borders for best fit. Click Next.

10. Choose a field to uniquely identify the row in the control and to provide the valuethat will be stored in the table. Click Next.

11. Choose whether or not to store the values in the field and specify a field, and thenclick Next.

12. Accept the suggested label name or enter a name for the Combo Box and thenclick Finish.

LESSON 12

Microsoft® Office Access 2003 - Level 1256

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 272: Access Level 1

ACTIVITY 12-2Adding a Combo Box Control

Data Files:

• Improve.mdb

Setup:The frmMySalesAndProfit form is open in Form view.

Scenario:You continue to work with frmMySalesAndProfit and decide to add some choices to simplifydata entry. To begin, you’ll add a Combo Box that displays the part numbers and book titlesfor each record, and records the part number field.

What You Do How You Do It

1. Delete the existing PartNumber

text box and label controls.

a. Switch to Design view.

b. Delete the PartNumber text box and

label controls.

2. Start the Combo Box Wizard. a. In the Toolbox, verify that the Control

Wizards button is selected. Itappears a different color when selected.

b. Choose the Combo Box tool .

c. On the form, click below the

TransactionDate controls to start theCombo Box Wizard.

LESSON 12

Lesson 12: Improving Your Forms 257

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 273: Access Level 1

3. Using the wizard, select two fields in

tblBookProject that will be dis-

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

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, fromthe list of tables select tblBookProject.

Click Next.

d. With PartNumber selected in the AvailableFields list box, click the right arrow but-

ton .

e. Move the BookTitle field from the Avail-

able Fields list box to the Selected

Fields list box. Click Next.

LESSON 12

Microsoft® Office Access 2003 - Level 1258

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 274: Access Level 1

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.

LESSON 12

Lesson 12: Improving Your Forms 259

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 275: Access Level 1

5. Ensure that both columns will dis-

play in the combo box and adjust

the column widths.

a. Uncheck Hide Key Column.

Although the wizard recommends that you hidethe key column, for this example, you want todisplay it in the combo box with the book title.

b. To make the best fit for the column,double-click the right edge of the

BookTitle column.

c. Double-click the right edge of the

PartNumber column. Click Next.

d. In the Available Fields list box, verify that

PartNumber is selected. Click Next.

This field uniquely identifies the row in thecombo box, and it contains the value you wantto store or use in the database.

6. Specify that Access should store the

combo box value in the PartNumber

field and complete the wizard.

a. Select Store That Value In This Field.

b. From the drop-down list, select

PartNumber.

c. Click Next.

LESSON 12

Microsoft® Office Access 2003 - Level 1260

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 276: Access Level 1

d. Accept the suggested label and Click

Finish.

7. Display and scroll through the val-

ues listed in the new combo box.

a. Change to Form view.

b. Click the combo box drop-down arrow.

c. Close the combo box list.

d. Save the modified form.

LESSON 12

Lesson 12: Improving Your Forms 261

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 277: Access Level 1

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 To→List Box.

c. In Form view, scroll through the list box.

d. Change to Design view and click Undo.

To use this List Box control effectively, addi-tional design changes would be needed so thatit does not overlap the Text Box controls belowit.

e. Close frmMySalesAndProfit.

If you are asked to save changes again, clickNo.

Procedure Reference: Create an Option Group

To add an option group to a form in Design view:

1. If necessary, activate the Control Wizards button.

2. In the Toolbox, click the Option Group button.

3. Click in the form where you want the option group created.

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

5. From the drop-down list, select a default value for the field and click Next.

A default choice is not required for option buttons, but Windows users have come to expect thatwith this type of control, a default option will already be selected.

6. Accept the default values that will be used for each option or change them to suityour needs and click Next.

7. Specify whether the value is saved for later use or stored in a selected field andclick Next.

LESSON 12

Microsoft® Office Access 2003 - Level 1262

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 278: Access Level 1

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-3Adding an Option Box Group to a Form

Data Files:

• Improve.mdb

Setup:You must have installed the Additional Wizard set when setting up this course. Otherwise, youwill be prompted at this point for a CD.

Scenario:In addition to an Order Entry form, you also have a New Customer Information form. On thisform, you’ll also include the payment method. You decide to add an option group as an inter-face for adding the payment method number.

What You Do How You Do It

1. Add an option group to

frmNewCustomer by starting the

wizard.

a. Open frmNewCustomer in Design view.

b. If necessary, enlarge the Design view

window so that all the fields can be

seen.

c. Verify that the Control Wizards tool is

selected.

d. In the Toolbox, choose the Option Group

tool .

LESSON 12

Lesson 12: Improving Your Forms 263

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 279: Access Level 1

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 Cardas the default choice.

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

c. Click Next.

d. Verify that the Yes, The Default Choice

Is option is selected. Display the drop-

down list of labels, and select Credit

Card. Click Next.

e. To accept the default values, click Next.

3. Store the value in the Payment

field, use the Sunken style with

option buttons, and add a label.

a. Select the option Store The Value In This

Field.

LESSON 12

Microsoft® Office Access 2003 - Level 1264

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 280: Access Level 1

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 controltypes and view the examples.

d. Type Payment Method

e. Click the Finish button. The option groupis created on the form design.

f. Save the form as frmMyNewCustomer

4. Page through the records to see the

effect of the option group.

a. Change to Form view.

b. Page through the records. Differentoption buttons are selected for eachrecord, depending on which paymentmethod the customer has chosen.

c. Click the New Record button.

d. Verify that the default value for the

option group is Credit Card.

LESSON 12

Lesson 12: Improving Your Forms 265

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 281: Access Level 1

TOPIC CAdd Command ButtonsAt this point, your forms look good and produce accurate data. Now you’ll learn how to add acommand button to your form to make repetitive functions easier to use.

Once you start working with your forms, you might discover that there are things you or oth-ers who use your form commonly do—like print a form, close a form, or add a record. Byadding a command button to a form, you can automate tasks such as these, which could reducethe time spent on such repetitive tasks. Such buttons also add a touch of professionalism toyour Access database, by giving them the appearance of a more robust application.

Command ButtonsDefinition:

A Command button is a control that carries out a pre-defined function. The appearanceof 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, includingform operations such as closing the form or printing the form, record operations suchas deleting a record, and many more.

Example:

Figure 12-6: Three common command buttons: Close Form, Print Form, andDelete Record.

How to Add Command ButtonsProcedure Reference: Create Command Buttons Using the Wizard

To use the Command Button Wizard to create command buttons:

1. In Design view, open the form you want to add buttons to.

LESSON 12

Microsoft® Office Access 2003 - Level 1266

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 282: Access Level 1

2. If necessary, make room for the buttons on the form.

3. If necessary, open the Toolbox and activate the Control Wizards button.

4. In the toolbox, choose the Command Button tool.

5. In the Form Design view window, click where you want the command button toappear.

6. Click one of the categories.

7. Select an action. Click Next.

8. The remaining steps of the wizard depend on the type of action you chose. ClickNext.

9. Enter a name for the button and click Finish.

ACTIVITY 12-4Adding a Command Button to a Form

Data Files:

• Improve.mdb

Setup:The frmMyNewCustomer form is open in Form view.

Scenario:Once an order is taken, the form can be closed. This is a fairly common routine: open theform to record a transaction, and then close the form. You’ve decided that it would be nice tohave a button to do that, so you will add a command button to close the form.

LESSON 12

Lesson 12: Improving Your Forms 267

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 283: Access Level 1

What You Do How You Do It

1. Add a command button to the bot-

tom of the form that will close the

form.

a. Change to Design view and choose the

Command Button tool from the

Toolbox.

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.

e. Select Text. Click Next.

f. Type Close Form and click Finish.

2. Test the Close Form button. a. Save the form.

b. To close the form, switch to Form view

and click the Close Form command but-

ton .

If you are asked to save the form again, clickYes.

LESSON 12

Microsoft® Office Access 2003 - Level 1268

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 284: Access Level 1

TOPIC DCreate a SubformYou’ve improved the appearance and usability of your forms, but there is more you can do. Inthis 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 mightmake sense to allow users to add or update data in both tables at once. By creating a subformyou enable users of a form to add or update records in the primary table while at the sametime modify any related data in the secondary table. This saves them from needing to work intwo separate forms at once and reduces the chances for data-entry errors.

SubformsDefinition:

A subform is a form that is displayed as an object within another form called a mainform. When a one-to-many relationship exists between tables or queries, you can usethe main form to represent the “one” side of the relationship and a subform to repre-sent the “many” side. The subform is often displayed in Datasheet view so thatmultiple records can be shown for each related record in the main form. You canmodify the data for both the fields in the main form and the rows in the subform.

Although the subform is displayed as part of another form, it is a separate form, and its design is inde-pendent of the main form.

Example:

Figure 12-7: A main form with Orders data that contains a subform withrelated Order Details data.

LESSON 12

Lesson 12: Improving Your Forms 269

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 285: Access Level 1

How to Create a SubformProcedure Reference: Create a Subform Using the Wizard

The Subform/Subreport Wizard can guide you through the steps of creating a subformwhen a main form exists. To create a subform by using the Subform/Subreport Wizard:

1. From the Toolbox, choose the Subform/Subreport tool.

2. Click in the desired location on the form on which you would like to place thesubform.

3. 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 asubform.

4. Select the object that will create the subform. Click Next.

• If you select the tables and queries option, display the table or query thatcontains the fields you would like to use and add them to the Selected Fieldslist box.

You can select fields from more than one table or query.

• If you select the forms option, select the form that you want from the listbox.

5. Select one of the links that Access suggests, or create one of your own. ClickNext.

6. Name your form and click Finish.

Other ways to add a subform to a form: drag a form from the database window to the Designview window; or drag a table from the database window.

Using a Form that has a SubformIn Form view, you can switch between a main form and a subform by using the Tabkey 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 inthe “many” table will also have a record in the “one” table to relate to. Each record isalso saved automatically as you add it to the subform.

LESSON 12

Microsoft® Office Access 2003 - Level 1270

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 286: Access Level 1

ACTIVITY 12-5Adding a Subform Control to an Access Form

Data Files:

• Improve.mdb

Setup:The Improve database is open in Access.

Scenario:You have a simple form, frmCustomersMain, that displays basic information about eachcustomer. 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 accomplishthis by adding a subform to the main form.

What You Do How You Do It

1. Start the Subform/Subreport Wizard

to add a subform to

frmCustomersMain.

a. Open frmCustomersMain.

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

trols to launch the wizard.

LESSON 12

Lesson 12: Improving Your Forms 271

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 287: Access Level 1

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.

c. Add all the fields to the Selected Fields

list box except CustomerID.

d. Click Next.

e. To accept the wizard’s suggestion regard-ing the linking of the forms, click Next.

f. In the Subform text box, type

fsubMyBookSales

g. Click Finish.

You may need to resize the form window to see theentire Subform control as shown.

3. With the Subform control selected,change the Width property to 4”.Save your work.

a. If necessary, using the Object drop-downmenu on the Formattingtoolbar, select fsubMyBookSales.

LESSON 12

Microsoft® Office Access 2003 - Level 1272

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 288: Access Level 1

b. On the Form Design toolbar, click the

Properties button .

c. In the Width property box, enter 4”

d. Close the properties dialog box.

e. Save the main form as

frmMyCustomersMain

LESSON 12

Lesson 12: Improving Your Forms 273

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 289: Access Level 1

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.

c. To extend the widths of the other threecolumns, do the same on the field bor-

ders between TransactionDate and

PartNumber, PartNumber and

QuantitySold, and at the right edge of

QuantitySold.

5. True or False? Although the CustomerID field is not found in the subform, because thetblCustomer and tblBookSales are related, the data in the CustomerID field in the mainform will be used for the CustomerID data in the related table as well.

True

False

6. Close the form and the database

window.

a. Close the frmCustomersMain form.

b. Close the Improve database window.

Lesson 12 Follow-upIn this lesson, you learned techniques to make forms work more efficiently and intuitively forthe user. By grouping form controls and making other aesthetic improvements, users will feelmore comfortable while entering data. By using command buttons and subforms, you canmake users more efficient, and these gains can be very large—as in many databases the bulk oftime spent by users is in forms.

1. What do you expect will be the most challenging aspects of improving your forms?

LESSON 12

Microsoft® Office Access 2003 - Level 1274

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 290: Access Level 1

2. Do you expect to make more aesthetic improvements to your forms or more improve-ments to enhance data entry efficiency? Or both?

LESSON 12

Lesson 12: Improving Your Forms 275

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 291: Access Level 1

Microsoft® Office Access 2003 - Level 1276

NOTES

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 292: Access Level 1

Customizing Your Reports

Lesson Objectives:In this lesson, you will customize reports to better organize the displayed information and pro-duce specific print layouts such as mailing labels.

You will:

• Sort and group report records.

• Set report control properties that enhance the display of data.

• Control whitespace between records and manual page breaks.

• Include data that is printed at the beginning or end of each group of data on your report.

• Add a subreport to a report footer.

• Create a mailing label report.

Lesson Time1 hour(s)LESSON 13

LESSON 13

Lesson 13: Customizing Your Reports 277

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 293: Access Level 1

IntroductionThe reports you create with AutoReport or the Report Wizard might work perfectly for you,but chances are you’ll end up in the Report Design view window to improve your reports atsome point. This lesson will provide an opportunity to try your hand at many report designtasks.

You have been assigned to produce invoices from a product orders database. Using basicreport features, you could create one report for the customer’s information and a second reportfor the products they have just ordered. But, by customizing a report, you can create a single,far more effective invoice.

TOPIC AOrganize Report InformationYou have created some basic reports using the Report Wizard. You may have noticed thatwhile the desired information was all included, it was not optimally organized and it lackedany summary information. In this topic, you take the first step in customizing your reports bysorting and grouping report records to show summary information.

By determining the order in which the data is displayed in the report and by grouping relevantdata together in the report, you can present information in a more logical and concise format.For example, you may want to group employees by department, and then list them in alpha-betical order by last name. Or, you could use record grouping to view or print data bydepartment or by sales territory. Such simple changes can be very valuable for the reader ofyour report.

Report Design EnhancementsRegardless of the method you chose to initially create a report, you can always modify thereport design to improve it. There are many report design features that you can use to accom-plish this. (See Table 13-1.)

Table 13-1: Report Design Enhancements

Enhancement DescriptionText display Change the alignment of text within a control to provide greater balance.

Whitespace Reduce or increase the amount of whitespace between records in theDetail section.

Graphic elements Add lines, rectangles, borders, or dashes to your report.

Pictures Add pictures and logos to your report for visual appeal.

Page breaks Control whether to keep the data in a group together on a page or force apage break before or after a section.

Custom pages Create a custom page, such as one with a subreport.

LESSON 13

Microsoft® Office Access 2003 - Level 1278

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 294: Access Level 1

Report Design ViewThe Report Design view window (see Figure 13-1) is the design environment for makingchanges to a report’s design. It provides numerous tools to help you improve the design ofreports 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 avail-able in Form Design view.

Tool DescriptionReport Design toolbar Provides buttons for common tasks like View,

Save, and Print. It also includes the useful Sortingand Grouping button.

Formatting toolbar Has buttons for typical formatting jobs, like chang-ing font sizes and colors.

Toolbox Has buttons for placing labels, fields, images, andother special-purpose objects in a report. This iswhere you typically go to find controls to add toyour report.

Field List Shows fields from the table or query that is thesource of data for the report you are working on.

Properties dialog box Each object in a Report Design view window hasits own properties dialog box with tabs that list theproperties you can change for the object.

Control Wizards toggle button Often when you click a button in the Toolbox toplace an object on the report design, you get somehelp from one of the Access wizards.

LESSON 13

Lesson 13: Customizing Your Reports 279

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 295: Access Level 1

Figure 13-1: The Report Design view window.

How to Organize Report InformationProcedure Reference: Add Report Grouping using the Wizard

To build grouping and sorting features into a report based on a query by using theReport Wizard:

1. Open a query in Design view.

2. From the New Object button’s drop-down list, select Report.

3. In the New Report dialog box, select Report Wizard and click OK.

4. Select the desired fields and click Next.

5. Choose the desired field to group records by and click Next.

6. If desired, choose additional grouping levels. Click Next.

7. If desired, choose a field to sort records by and choose a sort order (Ascending orDescending).

8. If desired, specify any calculated fields by clicking Summary Options and makinga selection. Click OK, and then click Next.

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

LESSON 13

Microsoft® Office Access 2003 - Level 1280

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 296: Access Level 1

Procedure Reference: Add a Report Grouping Section Manually

If, after using the Report Wizard, you decide to add record grouping and sorting, youcan still do so. To manually add a Report Grouping section to a report:

1. Open a report.

2. Display the report in Design view.

3. Open the Sorting And Grouping dialog box.

4. To specify a sort, click in the first blank line under the Field/Expression section toshow its drop-down arrow, and then select the field you want from the list offields. Under the Sort Order heading, specify Ascending or Descending.

5. In the bottom half of the dialog box, select the group properties you would like,such as a header or a footer.

6. As desired, move the sort field higher in the field list.

7. Close the Sorting And Grouping dialog box.

ACTIVITY 13-1Sorting and Grouping Report Records

Data Files:

• Report.mdb

Setup:Access is open.

Scenario:You need to create a report with customer order information grouped by book titles. The reportwill be based on a query, qselSalesAndProfit, that draws data from four tables and displays allkinds of information about the book’s transactions. Under each book title will be customername, quantity sold, transaction date, and order ID. These detail records will be sorted by cus-tomer name. Under each title, you also want to show how many of that book you’ve sold.

What You Do How You Do It

1. Start the Report Wizard to create a

report based on qselSalesAndProfit.

Include the BookTitle,

CustomerName, QuantitySold,

TransactionDate, and OrderID

fields.

a. Open Report.mdb.

b. Open qselSalesAndProfit in Design view.

c. From the New Object button’s drop-downlist, select Report.

d. In the New Report dialog box, select

Report Wizard. Click OK.

LESSON 13

Lesson 13: Customizing Your Reports 281

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 297: Access Level 1

e. From the Available Fields list box, move

the BookTitle, CustomerName,

QuantitySold, TransactionDate, and

OrderID fields to the Selected Fields list

box. Click Next.

2. Group the data by book title. Sort

the detail records by customer

name in ascending order.

a. To view your data by book title, verify By

TblBookProject is selected. Click Next.

b. You don’t want other grouping levels.Click Next.

LESSON 13

Microsoft® Office Access 2003 - Level 1282

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 298: Access Level 1

c. From the first sort drop-down list, select

CustomerName. The default sort order isAscending.

3. Specify the sum of the quantity sold

as the only summary value to be

calculated.

a. To summarize detail records, click Sum-

mary Options .

b. For the QuantitySold field, check Sum.

c. Click OK, and then click Next.

LESSON 13

Lesson 13: Customizing Your Reports 283

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 299: Access Level 1

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

c. In the report title text box, type My BookSales and click Finish.

As you scroll through the report, you might see fea-tures you would like to change.

5. What are some things you could improve about the data layout?

6. What are some things you could improve about the pagination? For example, is there alot or a little white space? Where do pages break?

7. What are some things you could improve about the summary data in each group andthe end of the report?

8. Close the Print Preview of the

report and close qselSalesAndProfit.

a. To display Design view, click Close

.

b. Close qselSalesAndProfit.

LESSON 13

Microsoft® Office Access 2003 - Level 1284

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 300: Access Level 1

TOPIC BSet Report Control PropertiesYou’ve created a report that includes groups, which is a big step in the organization of thereport. But that effort will be all for naught if the data doesn’t display very well in the report.In this topic, you will use control properties to enhance the data layout.

Of course you want your reports to look good, and generally the Report Wizard does anadequate job of creating the initial report based on your specifications. But to look truly out-standing, in most cases, you’ll need to bring a little finesse to the situation by altering somekey control properties. In the end, the effort will be worthwhile—a report that really stands outfor both its organization and its layout design.

Display PropertiesReport control properties allow you to customize the look and capabilities of controls in yourreports.

Control Property DescriptionCaption Provides an alternate label to be used in place of the default name for

the control.

Width Sets an object’s width to specific dimensions.

Height Sets an object’s height to specific dimensions.

Can Grow Controls the appearance of controls that are printed or previewed. Whenset to Yes, the control automatically resizes vertically so that all the datait contains is shown.

Can Shrink Similar to Can Grow. When set to Yes, the control automatically resizesvertically so that all the data it contains is shown but no additional spaceis displayed.

Text Align Specifies 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 havethe same height or width.

Hide Duplicates PropertyIf you use the Report Wizard to design a report and you select a field for grouping,Access automatically puts that field in a Group Header, where it is printed only oncefor each group. The Hide Duplicates property provides an alternative method for sup-pressing repeating values without choosing groups. To use the Hide Duplicatesproperty, sort the records on a field (either by basing the report on a query or in thereport design itself), so that the repeating values in the field appear together. In thereport Design view, select the appropriate control. Set the Hide Duplicates property forthe control to Yes.

LESSON 13

Lesson 13: Customizing Your Reports 285

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 301: Access Level 1

How to Set Report Control PropertiesProcedure Reference: Modify the Properties of a Control

To enhance the appearance of the report by modifying the properties of its controls:

1. Select the control in report Design view.

2. Change the properties displayed in the properties dialog box as desired.

ACTIVITY 13-2Setting Report Control Properties

Data Files:

• Report.mdb

Setup:The My Book Sales report is open in Design view.

Scenario:You have decided to make some improvements to the My Book Sales report. Your first focusis the data layout. For example, some book titles and customer names are truncated. In addi-tion, some customer names are repeated. A better way would be to list each customer nameonce along with its corresponding transaction dates. The end result will be a concise, efficientreport that does not display repeating data.

LESSON 13

Microsoft® Office Access 2003 - Level 1286

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 302: Access Level 1

What You Do How You Do It

1. For both the report title bar and forthe report title, change the caption

to Book Sales.

a. Choose View→Properties to display thereport’s properties.

b. Change the report’s Caption property to

Book Sales

You won’t see this change take effect unless thereport is in Print Preview.

c. In the Report Header section, select the

label control.

d. Change the label’s Caption property to

Book Sales

You can keep the property window open andsimply select each of the controls whose prop-erties you wish to modify, as the propertywindow will dynamically display the currentcontrol’s properties.

2. Change the width of the BookTitle

text box to fit each title on a singleline. Modify the CustomerName text

box control so long names wrap to asecond line.

a. In the BookTitle Header section, provide

enough space for each title to be dis-

played on a single line by selecting the

BookTitle text box and changing its

Width property to 3.75”

b. In the Detail section, select the text box

CustomerName. On the Format propertypage, change the Can Grow property to

Yes.

3. Change the alignment of the

QuantitySold data in the Detail sec-

tion to center the values.

a. Select the QuantitySold text box.

b. Scroll down the list of properties on the

Format tab and change the control’s

Text Align property to Center.

LESSON 13

Lesson 13: Customizing Your Reports 287

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 303: Access Level 1

4. Center the values of the

TransactionDate and Sum Of

QuantitySold text boxes.

a. For the TransactionDate text box in theDetail section, change the Text Align

property to Center.

b. For the SumOfQuantitySold text box in theBookTitle 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 GrandTotal, set its width to 1.35”, and

center it.

a. For the Sum label in the BookTitle Footersection, change the Caption property to

Total Sold

Set its Width property to 0.56”

Access might change this to 0.5597”.

b. For the Grand Total label in the ReportFooter section, change the Caption prop-

erty to Books Grand Total

Set its Width property to 1.35”

c. For the QuantitySold Grand Total Sum textbox in the Report footer, change the Text

Align property to Center.

d. Preview the report by clicking Print Pre-

view .

LESSON 13

Microsoft® Office Access 2003 - Level 1288

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 304: Access Level 1

6. Hide repeating data in the

CustomerName text box control.

Save your work as rptMyOrders.

a. Change to Design view. In the Detail sec-tion, select the CustomerName text box

control.

b. On the Format page of the properties dia-log box, change the Hide Duplicates

property to Yes.

c. Close the properties dialog box.

d. Preview the report. No repeated data isdisplayed in the CustomerName column inthe report.

e. Change to Design view. Save the report

as rptMyOrders

LESSON 13

Lesson 13: Customizing Your Reports 289

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 305: Access Level 1

TOPIC CControl Report PaginationSo far in this lesson, you’ve organized the desired information through grouping and sorting,and you’ve dealt with data layout issues. The next step is to hone in on the report pagination—where the pages break and how much white space is displayed on each page.

A report loses much of its appeal when the data seems to extend from one page to the nextwith little or no concern as to when the page breaks. Although it might not seem like a bigdeal, having data spill over in no organized fashion can cause your audience to become dis-tracted and lose interest, and it may prevent them from arriving at the conclusions you aretrying to make. However, setting your pagination squarely and properly does not take muchadditional effort and can be the clincher for a great-looking report.

Keep Together PropertyThe Keep Together property can be used to control page breaks for control groups such as thegroup header, detail section, and group footer. This property can prevent widowed recordsfrom being displayed alone at the top of a new page.

The Keep Together property can also be directly applied to a particular section. In this case its possible valuesare simply Yes and No.

Keep Together Property Settings

Setting DescriptionNo Allows the group to print without keeping the

Group Header, Detail, and Group Footer sec-tions on the same page.

Whole Group Forces the Group Header, Detail, and GroupFooter sections to print on the same page.Groups that are too large to fit on a singlepage will be split across pages.

With First Detail Allows the Group Header to print on a pageonly if the first Detail record can also beprinted on that page.

Force New Page PropertyThe Force New Page property can be used to force each new section to print on a new page ofthe report. This property can guarantee that critical information is shown on a fresh page.

LESSON 13

Microsoft® Office Access 2003 - Level 1290

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 306: Access Level 1

Force New Page Property Settings

Setting DescriptionNone Allows the section to print on the current

page.

Before Section Forces the section to start printing at the topof a new page.

After Section Forces the following section to start printing atthe top of a new page.

Before & After Forces the current and following sections tostart printing at the top of a new page.

How to Control Report PaginationProcedure Reference: Control Pagination of a Report

To control report pagination:

1. If necessary, open the report in Design view.

2. If desired, adjust line spacing in one of two ways:

• Drag the section header to the desired location on the vertical ruler.

• Select the section and then change the Height property.

When the mouse pointer is in position to move a report band up or down, it changes to a crosswith a double-headed vertical arrow.

The settings are confined to the section in which they are made. For example, if you increase thesize of the Report Heading section, it won’t affect the spacing in the Detail section of the report.

3. Open the Sorting And Grouping dialog box.

4. Set the Keep Together and/or Force New Page properties for the group.

5. Close the Sorting And Grouping dialog box.

Troubleshooting a ReportWhen you print your report, you might get unwanted blank pages for one of severalreasons.

• If you get a blank page only at the end of the report, it could be that you have anempty Report Footer section with a Height property set to something other thanzero. Check the Report Footer’s Height property and make sure it’s set to zero.

• If you’re getting blank pages on every other page of your report, make sure thatthe total width of the report plus the widths of the left and right margins don’texceed the paper size specified in the Page Setup dialog box. If they do, then youcan either reduce the width of the report, reduce the margins, or change the pageorientation.

LESSON 13

Lesson 13: Customizing Your Reports 291

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 307: Access Level 1

ACTIVITY 13-3Reducing the Amount of White Space Between Recordsand Controlling Manual Page Breaks

Data Files:

• Report.mdb

Setup:The rptMyOrders report is open in Design view.

Scenario:You’ve decided to optimize your Book Sales report to make it easier to read. Currently, thereis 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 correctthese layout flaws.

LESSON 13

Microsoft® Office Access 2003 - Level 1292

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 308: Access Level 1

What You Do How You Do It

1. The records in the report are ratherspaced out. Reduce the unnecessary

white space under the controls in

the Detail section by decreasing its

size.

a. To select all of the controls in the Detailsection, click in the vertical ruler to the

left of the controls in the Detail section.

b. To position the controls higher in theDetail section, press the up arrow key

once.

c. Place the mouse pointer on the top bor-

der of the BookTitle Footer band. Drag

the band up a small distance to nearly

touch the bottoms of the four text box

controls in the Detail section.

Instead of dragging the band, you could change theHeight property of the Detail section to 0.225”.

2. To prevent groups from splitting onthe report, open the Sorting And

Grouping dialog box and set the

Keep Together property to Whole

Group.

a. Click the Sorting And Grouping button

.

b. With BookTitle selected, under the GroupProperties heading, display the Keep

Together drop-down list.

LESSON 13

Lesson 13: Customizing Your Reports 293

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 309: Access Level 1

c. To keep category groups together on thesame page, select Whole Group.

d. Verify that the Group Header and Group

Footer properties for the BookTitle field

are each set to Yes. Each section will dis-play in the report. Close the Sorting And

Grouping dialog box.

3. Preview the report and save your

work.

a. Select Print Preview to preview yourreport.

b. Customer names are closer together, sothere’s less white space. No groups aresplit across pages. Close print preview toreturn to Design view. Save the report.

TOPIC DSummarize InformationAs you saw earlier, you can use the Report Wizard to show summary information in a report.Now you’ll go through the steps of setting up summary fields by hand, and you’ll add otherfields to the Group Footer as well.

Sometimes your reports call for even more detail and organization than you’ve created thus far.For these more complex reports, manually using groups and summary information fields is theticket. While this can take some extra effort, the results are definitely worthwhile, as it permitsyou to provide exactly the information desired in your report.

How to Summarize InformationProcedure Reference: Define a Summary Field

To define a summary field, perform the following steps:

1. If necessary, open the report in Design view.

LESSON 13

Microsoft® Office Access 2003 - Level 1294

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 310: Access Level 1

2. Make room in the report for the new control.

3. Choose the Text Box tool.

4. From the Toolbox, click the report design where you want to create a Text Boxcontrol.

5. In the properties dialog box for the new control, in the Control Source property,enter an expression for the summary you want to perform.

Adding Fields to Sections in a ReportDepending on the information you display in your report and how it’s grouped, youmight still need to add fields to a report section. You can do this by dragging fieldsfrom the field list to the appropriate section of your report.

Moving Report ControlsTo move a control you’ve placed on the design, select it and drag or select it and usethe Ctrl key in combination with the arrow keys for precise placement.

ACTIVITY 13-4Including Group Data and Defining a Summary Field

Data Files:

• Report.mdb

Setup:The rptMyOrders report is open in Design view.

Scenario:You would like to provide the readers of your Book Sales report with more information abouteach 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.

What You Do How You Do It

1. Make room on the report for two

new controls.

a. Display the properties dialog box for the

BookTitle Footer.

LESSON 13

Lesson 13: Customizing Your Reports 295

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 311: Access Level 1

b. Change the Height property to 1”

c. Close the property dialog box.

LESSON 13

Microsoft® Office Access 2003 - Level 1296

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 312: Access Level 1

2. Add the InStock and OnOrder fields

to the BookTitle Footer and align

them as necessary.

a. If necessary, choose View→Field List todisplay the field list window.

b. From the bottom of the field list, select

InStock and OnOrder.

c. Drag the selected fields to the 1” hori-

zontal position in the BookTitle Footer,

below the Total Sold label and text box

controls.

You can fine-tune the placement of selected controlsby using Ctrl-arrow keys.

d. With the InStock and OnOrder label con-trols selected, shift-click the Total Sold

label to select it as well.

e. To align all three labels, choose Format→Align→Left.

f. Close the field list.

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 .

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 newcontrol, click the Data page.

LESSON 13

Lesson 13: Customizing Your Reports 297

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 313: Access Level 1

d. On the Data page, in the Control Sourceproperty box, enter

=([InStock]+[OnOrder])

Your property dialog box may have a title other thanText Box: Text33.

e. Select the new label control.

f. On the Format page of the properties dia-log box, edit the caption to read TotalInventory

g. Set the Width property to 0.9”

h. Close the properties dialog box.

i. With the Total Inventory label and textbox controls selected, Shift-click the

OnOrder text box to select it as well.

j. To align these controls, choose Format→Align→Bottom.

LESSON 13

Microsoft® Office Access 2003 - Level 1298

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 314: Access Level 1

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 line’s Border Style property

to Dashes.

e. Change the line’s Border Width property

to 2 pt.

f. Close the properties dialog box.

g. Save the updated report.

5. Preview your report. a. Click Print Preview.

b. Close the report preview.

LESSON 13

Lesson 13: Customizing Your Reports 299

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 315: Access Level 1

TOPIC EAdd a Subreport to an Existing ReportYou’ve already done a number of things to improve the look and value of your reports. In thistopic, you will add a subreport to a report. Doing so goes beyond the mere display aspects ofyour 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 youdisplay in your reports. Rather than creating two separate reports, you can combine them byusing a subreport. Doing so will save you time and result in a single, effective report with allthe data you need to convey.

SubreportsDefinition:

A subreport is a report inserted into another report called the main report. This is oftendone in the main report’s Report Footer section. A main report can be bound andbased on a table, query, or SQL statement, with the subreport linked to the main reportusing a link field. A main report can also be unbound and act as a folder for unrelatedsubreports that you want to combine.

The use of a link field to link a subreport to a main report is similar to the link field used to link asubform to a main form.

Example: Subreport in a Bound Main Report

Figure 13-2: A subreport to display product names in a bound main report dis-playing orders.

LESSON 13

Microsoft® Office Access 2003 - Level 1300

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 316: Access Level 1

How to Add a Subreport to an Existing ReportProcedure Reference: Create a Subreport

To create a subreport:

1. If necessary, open the main report in Report Design view.

2. If necessary, make room for the subreport.

3. Click the Subform/Subreport tool.

4. Click in the report where you want to place the subreport.

5. In the SubReport Wizard, select the record source for the subreport. Click Next.

6. Choose which fields will link the main report to the subreport, or choose None.Click Next.

7. Name the control and click Finish.

Another way to add a subreport to a report is to vertically tile the database window and theReport Design view window. Drag the subreport from the database window to the appropriatelocation in the main report that is displayed in the Report Design view window.

ACTIVITY 13-5Adding an Existing Subreport to an Existing Report

Data Files:

• Report.mdb

Setup:The rptMyOrders report is open in Design view.

Scenario:Suppose someone who uses your Book Sales report also wishes to see an ID reference numberfor each customer. Fortunately, you already have a separate report that includes each custom-er’s name and ID reference. You will therefore add the second report,rsubCustomerNameAndID, as a subreport to the main report. By placing the subreport in theReport Footer section, it will be printed once at the end of the report.

LESSON 13

Lesson 13: Customizing Your Reports 301

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 317: Access Level 1

What You Do How You Do It

1. Make room for a subreport and then

add rsubCustomerNameAndID to the

Report Footer section.

a. To make room for the subreport, enlarge

the Report Footer section by setting its

Height property to 2.5”

You could also accomplish this by dragging the bot-tom border of the Report Footer section.

b. In the Toolbox, click the Subform/

Subreport tool .

c. To start the wizard, click in the Report

Footer area directly below the Books

Grand Total label.

d. Specify the data for the subreport. Select

Use An Existing Report Or Form tospecify the data for the subreport.

e. Select rsubCustomerNameAndID. Click

Next.

f. From the list, select None. Click Next.

LESSON 13

Microsoft® Office Access 2003 - Level 1302

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 318: Access Level 1

g. To leave the name intact, click Finish.

h. Save the modified report design.

LESSON 13

Lesson 13: Customizing Your Reports 303

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 319: Access Level 1

2. Preview your report to verify thesubreport and see what design issuesremain.

a. Preview the report.

b. To view two pages at a time, click the

Two Pages button .

c. Scroll through the first several pages.

d. Verify that when you added this

subreport to the report, the report’s

width became greater than the printable

width, so the number of pages doubled

and every other page is blank.

e. To see the grand total of books sold in thesubreport in the report footer, view the

second-to-last page.

LESSON 13

Microsoft® Office Access 2003 - Level 1304

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 320: Access Level 1

f. Close Print Preview.

3. Eliminate the blank pages. Save

your work.

a. Choose File→Page 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 File→Page Setup.

f. On the Page tab, change the orientation

to Portrait.

g. On the Margins tab, change the Right

Margin setting to 0.5

h. Click OK.

i. Save the modified report design.

LESSON 13

Lesson 13: Customizing Your Reports 305

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 321: Access Level 1

4. Preview the report. a. Preview and page through the report in

the two-page layout.

b. Verify that the blank pages in the report

have been eliminated. Close the pre-

view and the report.

If the blank pages remain, make sure that thereport design grid is not more than seveninches wide.

TOPIC FCreate Mailing LabelsThe sort of reports you have been working with are great for common data printingrequirements. But there are times when an entirely different kind of printout is required, suchas when mailing labels are needed. Fortunately, Access provides a wizard specifically for thisneed, and in this topic, you will use it to create a mailing labels report.

Typically, in a large enough company or organization, labels are created for mailingpurposes—for addressing envelopes and packages. However, you can just as easily create prod-uct labels, tape labels, name tags, or any other type of label you want. Rather than having tocreate a report from scratch, or use the standard Report Wizard, you will find that the AccessLabel Wizard will save you a lot of time and create exactly the kind of result you need to printlabels.

LESSON 13

Microsoft® Office Access 2003 - Level 1306

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 322: Access Level 1

How to Create Mailing LabelsProcedure Reference: Create a Report that Prints Mailing Labels

To create a report that prints mailing labels by using the Mailing Label Report Wiz-ard:

1. In the database window, display the report objects and click New.

2. Double-click Label Wizard to open the first wizard step.

3. Choose a table or query for the labels and then click OK.

4. Choose the type of mailing label you’re using. Click Next.

5. Choose the text style for the labels. Click Next.

6. Arrange fields in the Prototype Label box to create a label layout. (Double-click afield to move it to the Prototype Label box. Press Spacebar, add punctuation, andpress Enter as necessary to create the layout.) Click Next.

7. Select a field to sort your labels by. Click Next.

8. Name the mailing label report. Click Finish.

If you want to change the sort order after the labels are designed, click the Sorting And Groupingbutton on the toolbar to display the Sorting And Grouping dialog box, in which you can specify anew sort order.

Changing the Record Source and the Control SourceIf a report design suits records from another table or query, you can display thoserecords by changing the record source for the report. For instance, you might have onetable that holds employee names and addresses and another that holds customer namesand addresses. An efficient and versatile way to produce mailing labels for both sets ofpeople would be to change the record source in the report’s properties dialog box; thatway, the report can print data from different tables. When you change the recordsource, you might also need to change control sources on the report. You can changecontrol sources in each control’s properties dialog box.

LESSON 13

Lesson 13: Customizing Your Reports 307

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 323: Access Level 1

ACTIVITY 13-6Creating Mailing Labels

Data Files:

• 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, whetherit be for a promotional offer, a quarterly catalog, or a revised price information sheet. From thecentral office, you want to create a mailing label for every one of your customers. You will usethe Label Wizard to create a report design that prints Avery C2160 labels for records intblCustomer.

What You Do How You Do It

1. Begin to create mailing labels using

the wizard. Specify that the data

should come from tblCustomer.

a. If necessary, display the report database

objects.

b. Click New . The New Report dia-log box appears.

c. Select Label Wizard.

d. Click the drop-down list.

e. Select tblCustomer.

f. Click OK.

LESSON 13

Microsoft® Office Access 2003 - Level 1308

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 324: Access Level 1

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 labelappears, click Next.

3. Add the CustomerName, Address,

City, Region, and PostalCode fields

to the label.

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.

LESSON 13

Lesson 13: Customizing Your Reports 309

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 325: Access Level 1

d. Double-click PostalCode. Press Enter.

e. Click Next.

4. Sort the labels by customer name

and name the report rptMyLabels.a. Double-click CustomerName. Click Next.

b. Type rptMyLabels

c. Click Finish.

5. Close the report and the database. a. Close the report preview.

b. Close the report window.

c. Close the Report database.

LESSON 13

Microsoft® Office Access 2003 - Level 1310

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 326: Access Level 1

Lesson 13 Follow-upIn this lesson, you modified reports to make them more visually effective and rich withinformation. You were able to reduce white space, modify page breaks, and generally improvethe look of a report. But you also improved the report’s effectiveness at conveying informationby including calculated fields and a subreport, as well as creating a mailing labels report fromaddress information in your database. You should now be able to open most of the reports youcome 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 ofyour reports?

2. What do you think will be the most challenging requirements for increasing the infor-mation that is conveyed by your reports?

LESSON 13

Lesson 13: Customizing Your Reports 311

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 327: Access Level 1

Microsoft® Office Access 2003 - Level 1312

NOTES

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 328: Access Level 1

Expanding the Reach ofYour Data

Lesson Objectives:In this lesson, you will use Access data in other applications, including Microsoft Word andExcel.

You will:

• Publish data from Access as a Word document.

• Analyze data from Access in an Excel spreadsheet.

• Export data from individual database objects to a text file.

• Merge data from Access with an existing Word document.

Lesson Time30 minutesLESSON 14

LESSON 14

Lesson 14: Expanding the Reach of Your Data 313

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 329: Access Level 1

IntroductionThe Access application is a great tool and it may be all you need to use to work with yourdata. But you haven’t yet explored ways to take your data beyond Access. In this lesson, you’llexport data to a text file and look at some of the methods for using your data in other pro-grams with Office Links.

As a member of the Human Resources department, you have been asked to send a letter toeach employee in your company that explains new safety procedures. You have the employeedata in your Access database, but you need to use it in a Microsoft Word template. You canexpand the reach of your data by using Office Link technology to auto-populate the desiredletters, potentially saving you hours of tedious manual typing.

TOPIC APublish Access Data as a WordDocumentThere are numerous ways you can use Access data outside of the Access program itself. Thefirst you will consider is how to use a table worksheet or a report in Microsoft Word.

Access reports and datasheets often include just the kind of information you need in a detailedWord-based report, white paper, or memo. Sure, you could print your documents from Accessand staple them alongside your Word document, but you can create a better looking report andsave collating time by actually publishing the Access data directly into Word.

Office LinksThe Office Links tool enables you to share Access data with Word and Excel. There are threeOffice Links options, each of which works with different types of Access objects and has adifferent result. (See Table 14-1.)

Table 14-1: Office Links Options and Results

Office Link Works With ResultsPublish It With Microsoft OfficeWord

Forms, Reports, Tables, Queries Creates an RTF file of theAccess object and opens it inWord.

Analyze It With Microsoft OfficeExcel

Forms, Reports, Tables, Queries Saves Access data as an Excelfile and opens it in Excel.

Merge It With Microsoft OfficeWord

Queries, Tables Creates an Access data sourcefor mail merge documents andlaunches the Mail Merge Wizardin Word.

LESSON 14

Microsoft® Office Access 2003 - Level 1314

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 330: Access Level 1

How to Publish Access Data as a Word DocumentProcedure Reference: Publish an Access Document with Word

To publish an Access document with Word:

1. In the database window, select the datasheet, form, report, or query that you wishto publish.

2. Choose Tools→Office Links→Publish It With Microsoft Office Word. Word willopen, displaying the Access object as an RTF file.

3. Save the Word document.

ACTIVITY 14-1Publishing Access Data as a Word Document

Data Files:

• Expand.mdb

Setup:Access is open.

Scenario:Your manager was pleased with the Book Sales report you created. However, she has asked toreceive it in Word format so that she can incorporate it in a larger document, highlight certainareas, and make other formatting changes. You decide to use Office Links to publish theAccess report to Word.

What You Do How You Do It

1. Publish rptMyOrders with Word. a. Open Expand.mdb.

b. In the database window, display the

report objects.

c. If necessary, select rptMyOrders.

LESSON 14

Lesson 14: Expanding the Reach of Your Data 315

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 331: Access Level 1

d. Choose Tools→Office Links→Publish It

With Microsoft Office Word.

2. Save the Word document as

rptBookSales.rtf and close the

document in Word.

a. In Microsoft Word, choose File→Save As

and name the file rptBookSales.rtf

b. Click Save.

c. Close Word.

TOPIC BAnalyze Access Data in ExcelYou have seen how Access data can be used in Word. Now you’re ready to see what you cando with Access data in Excel.

Excel provides data analysis options that just aren’t available in Access. Plus, Excel has amuch wider variety of charting options. Moving data from your Access database to an Excelworksheet allows you to take advantage of these features, extending your ability to analyze,manipulate, and display your data.

Excel Office LinksSince they aren’t available or easily accessible in Access, you can take advantage of Excel’sfinancial analysis tools and charting options by using the Analyze It With Microsoft OfficeExcel office links option. In doing so, your data is saved as an Excel XLS file.

LESSON 14

Microsoft® Office Access 2003 - Level 1316

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 332: Access Level 1

Any formatting that you have done in Access, such as font style and color, will be transferred to Excel.

Dragging and Dropping Tables and Queries to ExcelAnother way to export data from Access to Excel is by dragging and dropping anAccess object, such as a table or query, from the database to Microsoft Excel. This is afast way to export data for further analysis using Excel’s toolset.

How to Analyze Access Data in ExcelProcedure Reference: Analyze Access Data in Excel

To analyze Access data in Excel:

1. In the database window, select the datasheet, query, form, or report that you wishto publish.

2. Choose Tools→Office Links→Analyze It With Microsoft Office Excel. Excel willopen, displaying the Access data in an Excel worksheet.

3. Save the Excel file.

ACTIVITY 14-2Creating an Excel Chart with Access Data

Data Files:

• Expand.mdb

Setup:The Expand database is open in Access.

Scenario:Your manager has asked for sales data for each book part number. She needs only the totalsales quantities for each item. However, she wants the data in an Excel spreadsheet, not inAccess table format. You decide to use Office Links to analyze the qselQuantitySold query inExcel. She would also like to see the totals in a 3-D exploded pie chart—an option not easilyaccessible in Access.

What You Do How You Do It

1. Analyze the qtotCategories query in

Excel.

a. In the database window, display the

query objects.

b. If necessary, select qselQuantitySold.

LESSON 14

Lesson 14: Expanding the Reach of Your Data 317

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 333: Access Level 1

c. Choose Tools→Office Links→Analyze It

With Microsoft Office Excel. Excel opensand the query is displayed.

LESSON 14

Microsoft® Office Access 2003 - Level 1318

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 334: Access Level 1

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 theStandard Types page, under the ChartType 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.

d. To accept the default worksheet dataselection, click Next.

e. The next screen of the wizard asks you toadd a chart title. The wizard uses “TotalQuantity” from the column heading forthe sales totals. To accept the default,click Next.

f. The final screen in the wizard asks whereyou wish to place the chart. Verify that

As Object In qselQuantitySold is

selected, and then click Finish.

LESSON 14

Lesson 14: Expanding the Reach of Your Data 319

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 335: Access Level 1

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.

b. Hover your mouse over the resize

handle in the middle and bottom of the

chart graphic. When it turns into a doublevertical arrow, resize the chart object so

that all of the labels in the box on the

right are shown.

c. Choose File→Save As and name the file

rptQuantitySold

d. Click Save.

e. Close Excel.

LESSON 14

Microsoft® Office Access 2003 - Level 1320

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 336: Access Level 1

TOPIC CExport Data to a Text FileBesides Word and Excel, you can also use your Access data in other applications or in anotherAccess database. In this topic, you will export your data to a text file so that it can be usedelsewhere.

Access is a great program for managing lists of data; however, it doesn’t do everything. Forexample, you may want to export data from Access into a specific accounting application totake advantage of its advanced mathematic capabilities. By exporting data from Access to atext file, you are then in a position to import that data into other databases or programs. This isa flexible approach to expanding the reach of your data, allowing Access data to be used in awide range of applications.

ExportingExporting is a means of outputting data and database objects to another database, spreadsheet,or file format, so another application can use the data. A copy of the data is created in anexternal source file, so the original data is still stored in your database.

As you consider exporting data to other sources, keep in mind that other database systems have limitations onthe types of files they will accept. Some database systems will accept files in Excel format; others might onlyaccept text file formats. All of the Access objects allow you to export their data into a variety of formats (Excel,text files, 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 file is likely to result in a file that can be utilized in another database system.Exporting a form or report to a text file is unlikely to have the same result.

LESSON 14

Lesson 14: Expanding the Reach of Your Data 321

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 337: Access Level 1

Figure 14-1: A copy of data from a table, query, form, or report can be made in vari-ous file formats.

How to Export Data to a Text FileProcedure Reference: Export Data to a Text File

To export data from an Access table to an external text file:

1. Open the database window and select the object you want to export.

2. Choose File→Export.

3. Change the folder, if needed, and enter a name for the new file.

4. Change Save As Type to the type of file you want to export to.

5. Click Export.

6. Choose an export format. Click Next.

7. If you chose Delimited, then choose a character delimiter. Click Next.

8. Choose a destination for the output file. Click Finish.

9. 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 Definition Only if you want to export an empty table. Click OK.

LESSON 14

Microsoft® Office Access 2003 - Level 1322

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 338: Access Level 1

ACTIVITY 14-3Exporting Database Records to Notepad

Data Files:

• Expand.mdb

Setup:The Expand database window is open.

Scenario:The data in tblCustomer has value to another department in your company. They currently usean alternate proprietary database application and have requested that you send the data fromtblCustomer to them as a delimited text file. To accomplish this, you will export the data fromAccess to a semicolon delimited text file.

LESSON 14

Lesson 14: Expanding the Reach of Your Data 323

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 339: Access Level 1

What You Do How You Do It

1. Export tblCustomer to a text file,

and save it as CustomerData.txt.a. In the database window, display the table

objects.

b. If necessary, select tblCustomer.

c. Choose File→Export.

d. Type a file name of CustomerData

e. Open the Save As Type drop-down list

box and choose Text Files.

f. To start the Export Text Wizard, click

Export.

g. For the export format, verify that Delim-

ited is selected. Click Next.

h. Select Semicolon as the delimiter.

i. Click Next.

j. Verify that the document will be saved

in My Documents. Click Finish.

k. The export is complete. Click OK.

LESSON 14

Microsoft® Office Access 2003 - Level 1324

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 340: Access Level 1

2. Open the CustomerData.txt file in Notepad to verify that the export was successful.

3. True or False? The headings for each column of data were not exported with thevalues.

True

False

4. True or False? When a value was empty (null) a space is placed between the two semi-colons that delimit this field from the previous and next fields.

True

False

5. In order for this exported data to be optimally used by another application, whichcharacter must not appear in the data?

a) Comma

b) Semicolon

c) Space

d) Ampersand

6. Close Notepad. a. Close Notepad.

LESSON 14

Lesson 14: Expanding the Reach of Your Data 325

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 341: Access Level 1

TOPIC DMerge Access Data with a WordDocumentThus far you have seen how to work with Access data in other applications. In each case, youworked with the data as it is found in Access, but that isn’t always ideal. In this topic, youwill selectively work with Access data in exactly the way needed to create a personalized letterin Word.

Suppose you have a database of employee information stored in Access. The data includesemployee names and addresses, among many other pieces of information. If the HumanResources department wanted to mail a personalized letter out to each employee, they couldprint out a report showing employee names and addresses and then rekey that information intothe Word document with the text of the letter. This would be tedious and time-consuming, butit would get the job done. However, thanks to Office Links, there’s a much easier way ofmerging Access data with Microsoft Word—one that eliminates the unnecessary retyping of theinformation.

How to Merge Access Data with a WordDocumentProcedure Reference: Merge an Access Table or Query with an Existing WordDocument

To merge an Access table or query with an existing Word document:

1. In the database window, select the table or query.

For smoother merging, check field names in the Access table or query to be certain that theyaren’t longer than 20 characters and that they do not contain spaces or special characters.

2. Choose Tools→Office Links→Merge It With Microsoft Office Word.

3. Choose to link your data to an existing Word document, and then select thedocument. Click OK.

4. Locate your Word document and click Open.

5. Click Next: Write Your Letter.

6. Add merge fields to your document, as desired.

7. Click Next: Preview Your Letters and review the resulting merged letters.

8. Click Next: Complete The Merge.

LESSON 14

Microsoft® Office Access 2003 - Level 1326

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 342: Access Level 1

ACTIVITY 14-4Merging Access Data with a Word Document

Data Files:

• Expand.mdb

• CustomerLetter.doc

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 aWord file (CustomerLetter.doc) containing the letter. He knows that the customer names andaddresses are stored in your database, so he has asked if there is a way you could help auto-mate 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 How You Do It

1. Start the Office Link Wizard to

merge tblCustomer with

CustomerLetter.doc.

a. If necessary, from the list of tables,select tblCustomer.

b. Choose Tools→Office Links→Merge It

With Microsoft Office Word.

c. Verify that Link Your Data To An Existing

Microsoft Word Document is selected,

and then click OK.

LESSON 14

Lesson 14: Expanding the Reach of Your Data 327

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 343: Access Level 1

d. To launch the Mail Merge Wizard in Word,select the CustomerLetter file, and then

click Open.

LESSON 14

Microsoft® Office Access 2003 - Level 1328

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 344: Access Level 1

2. In the Write Your Letter step of thewizard, add mail merge fields for

the customer’s name, address, city,

region, country, and postal code.

a. In the Mail Merge pane, in the SelectRecipients 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 thetoolbar.

Do not click the similar looking More Items buttonin the Mail Merge pane.

c. To add the CustomerName field to theletter, select CustomerName and then

click Insert.

d. Close the Insert Merge Field window.

e. Press Enter. Click the Insert Merge

Fields button again.

f. To add the Address field to the letter,select Address and click Insert.

LESSON 14

Lesson 14: Expanding the Reach of Your Data 329

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 345: Access Level 1

g. Close the Insert Merge Field window.

h. Add merge fields for the City, Region,

Country, and Postal Code fields. Sepa-

rate the City and Region fields with a

comma and a space.

i. Add a merge field for the CustomerName

field after the greeting and before the

comma in the letter.

3. Use the Mail Merge task pane to

preview your letters. Look at let-

ters for both U.S. and Canadian

customers.

Be sure to use the Mail Merge task paneto preview your letter. Do not use PrintPreview.

a. In the Mail Merge task pane, click Next:

Preview Your Letters. The letter to yourfirst customer is displayed. Verify that

the merge fields have been replaced

with customer information from the first

record in the table.

LESSON 14

Microsoft® Office Access 2003 - Level 1330

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 346: Access Level 1

b. To find a Canadian customer, in the MailMerge task pane, click the Find A Recipi-

ent link . The FindEntry dialog box displays.

c. In the Find text box, type Canada and

click Find Next.

d. Verify that the first Canadian customer

is shown. Click Cancel.

LESSON 14

Lesson 14: Expanding the Reach of Your Data 331

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 347: Access Level 1

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 MergeTo Printer dialog box displays, giving youthe option to print all of the letters, thecurrent record only, or a range of letters.Click Cancel.

c. Save your document as

MyCustomerLetter. Close Word.

d. Close Access.

Lesson 14 Follow-upCreating reports and queries in Access harnesses the power of your data, but suppose youwould like to take that data beyond Access? Whether you would like to add data to a Worddocument, draw on data as a mail merge source, or use Excel to analyze your data, OfficeLinks make it possible. You can expand the reach of your data further by exporting it in vari-ous formats for use in other applications.

1. When might you use the Analyze It With Microsoft Office Excel Office Links option?

2. How might you take advantage of the Merge It With Microsoft Office Word Office Linksoption in your work?

LESSON 14

Microsoft® Office Access 2003 - Level 1332

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 348: Access Level 1

Follow-upIn this course, you explored the concept of the relational database and accomplished varioustasks using the basic features and components of Access 2003. In addition, you worked withtables to store, modify, and report on data; you created new queries, forms, and reports; andyou modified existing queries, forms, and reports. You have also begun to prepare for the moreadvanced Access courses and have completed the first step toward obtaining your MicrosoftOffice Specialist certification.

What’s Next?The Microsoft® Offıce Access 2003 - Level 1 course introduced you to the basics of the Access

Microsoft® Offıce Access 2003 -Level 2.

FOLLOW-UP

333

application and prepared you to go to the New Horizons course,

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 349: Access Level 1

Microsoft® Office Access 2003 - Level 1334

NOTES

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 350: Access Level 1

Microsoft Office SpecialistProgram

Selected New Horizons courseware addresses Microsoft Office Specialist skills. The followingtables indicate where Access 2003 skills are covered. For example, 1-3 indicates the lesson andactivity number applicable to that skill.

Core Skill Sets and SkillsBeing Measured

Access 2003:Level 1

Access 2003:Level 2

Access 2003:Level 3

Access 2003:Level 4

Create Access Databases

Creating databases usingDatabase Wizard

2-1

Creating blank databases 2-2

Create and Modify Tables

Creating tables using TableWizard

2-3

Modifying table properties orstructure

2-4, 2-5, 2-6,3-1

Define and Modify Field Types

Creating Lookup fields 3-3

Changing field types 2-5

Modify Field Properties

Changing field properties todisplay input masks

3-2

Modifying field properties fortables in Design view

3-1

Create and Modify One-to-Many Relationships

Creating and modifying one-to-many relationships

2-7

Enforce Referential Integrity

APPENDIX A

APPENDIX A

Appendix A: Microsoft Office Specialist Program 335

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 351: Access Level 1

Core Skill Sets and SkillsBeing Measured

Access 2003:Level 1

Access 2003:Level 2

Access 2003:Level 3

Access 2003:Level 4

Enforcing referential integrityin a one-to-many relationship

2-7

Create and Modify Queries

Creating and modifying Selectqueries using the SimpleQuery Wizard

4-3

Creating and modifyingCrosstab, unmatched, andduplicates queries

2-1, 2-3

Create Forms

Creating forms using theForm Wizard

5-3

Creating AutoForms 5-2

Add and Modify Form Controls and Properties

Modifying form properties 5-5, 5-6, 5-7,5-8

Modifying specific form con-trols (e.g., text boxes, labels,bound controls)

5-5, 5-6, 6-5 6-1

Create Reports

Creating reports 6-1, 6-2 7-1, 7-6

Add and Modify Report Control Properties

Adding calculated controls toa report selection

6-4 7-4

Create a Data Access Page

Creating data access pagesusing the Page Wizard

1-1

Enter, Edit, and Delete Records

Entering records into adatasheet

2-2

Find and Move Among Records

Using navigation controls tomove among records

2-1, 2-5

Import Data to Access

Importing structured data intotables

3-4

Create and Modify Calculated Fields and Aggregate Functions

Adding calculated fields toqueries in Design view

4-5

Using aggregate functions inqueries (e.g., AVG, COUNT)

4-6

Modify Form Layout

Aligning and spacing controls 5-6, 5-7

APPENDIX A

Microsoft® Office Access 2003 - Level 1336

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 352: Access Level 1

Core Skill Sets and SkillsBeing Measured

Access 2003:Level 1

Access 2003:Level 2

Access 2003:Level 3

Access 2003:Level 4

Showing and hiding headersand footers

6-1

Modify Report Layout and Page Setup

Changing margins and pageorientation

7-5

Aligning, resizing, and spac-ing controls

7-3

Format Datasheets

Formatting a table or queryfor display

1-4

Sort Records

Sorting records in tables, que-ries, forms, and reports

2-3 5-1, 7-1

Filter Records

Filtering datasheets by form 4-1

Filtering datasheets by selec-tion

2-4 4-1

Identify Object Dependencies

Identifying object dependen-cies

7-5

View Objects and Object Data in Other Views

Previewing for print 2-7

Using Datasheet, PivotChart,Web Page, and Layout view

1-4 2-5 1-1, 1-3, 2-5

Print Database Objects and Data

Printing database objects anddata

2-7 1-4

Export Data From Access

Exporting data from Access(e.g., Excel)

8-3

Back Up a Database

Backing up a database 7-2

Compact and Repair Databases

Using Compact and Repair 7-3

APPENDIX A

Appendix A: Microsoft Office Specialist Program 337

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 353: Access Level 1

Microsoft® Office Access 2003 - Level 1338

NOTES

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 354: Access Level 1

Microsoft Office SpecialistProgram

Selected New Horizons courseware addresses Microsoft Office Specialist skills. The followingtables indicate where Access 2003 skills are covered. For example, 1-3 indicates the lesson andactivity number applicable to that skill.

Core Skill Sets and SkillsBeing Measured

Access 2003:Level 1

Access 2003:Level 2

Access 2003:Level 3

Access 2003:Level 4

Create Access Databases

Creating databases usingDatabase Wizard

2-1

Creating blank databases 2-2

Create and Modify Tables

Creating tables using TableWizard

2-3

Modifying table properties orstructure

2-4, 2-5, 2-6,3-1

Define and Modify Field Types

Creating Lookup fields 3-3

Changing field types 2-5

Modify Field Properties

Changing field properties todisplay input masks

3-2

Modify field properties fortables in Table Design view

3-1

Create and Modify One-to-many Relationships

Creating and modifying one-to-many relationships

2-7

Enforce Referential Integrity

APPENDIX B

APPENDIX B

Appendix B: Microsoft Office Specialist Program 339

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 355: Access Level 1

Core Skill Sets and SkillsBeing Measured

Access 2003:Level 1

Access 2003:Level 2

Access 2003:Level 3

Access 2003:Level 4

Enforcing referential integrityin a one-to-many relationship

2-7

Create and Modify Queries

Creating and modifying Selectqueries using the SimpleQuery Wizard

4-3

Creating and modifyingCrosstab, unmatched andduplicates queries

2-1, 2-3

Create Forms

Creating forms using theForm Wizrd

5-3

Creating auto forms 5-2

Add and Modify Form Controls and Properties

Modifying form properties 5-5, 5-6, 5-7,5-8

Modifying specific form con-trols (e.g., text boxes, labels,bound controls)

5-5, 5-6, 6-5 6-1

Create Reports

Creating reports 6-1, 6-2 7-1, 7-6

Add and Modify Report Control Properties

Adding calculated controls toa report selection

6-4 7-4

Create a Data Access Page

Creating data access pagesusing the Page Wizard

1-1

Enter, Edit, and Delete Records

Entering records into adatasheet

2-2

Find and Move Among Records

Using navigation controls tomove among records

2-1, 2-5

Import Data to Access

Importing structured data intotables

3-4

Create and Modify Calculated Fields and Aggregate Functions

Adding calculated fields toqueries in Query Design View

4-5

Using aggregate functions inqueries (e.g., AVG, COUNT)

4-6

Modify Form Layout

Aligning and spacing controls 5-6, 5-7

APPENDIX B

Microsoft® Office Access 2003 - Level 1340

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 356: Access Level 1

Core Skill Sets and SkillsBeing Measured

Access 2003:Level 1

Access 2003:Level 2

Access 2003:Level 3

Access 2003:Level 4

Showing and hiding headersand footers

6-1

Modify Report Layout and Page Setup

Changing margins and pageorientation

7-5

Aligning, resizing, and spac-ing controls

7-3

Format Datasheets

Formatting a table or queryfor display

1-4

Sort Records

Sorting records in tables, que-ries, forms, and reports

2-3 5-1, 7-1

Filter Records

Filtering datasheets by form 4-1

Filtering datasheets by selec-tion

2-4 4-1

Identify Object Dependencies

Identify object dependencies 7-5

View Objects and Object Data in Other Views

Previewing for print 2-7

Using datasheet, PivotChart,Web page and layout view

1-4 2-5 1-1, 1-3, 2-5

Print Database Objects and Data

Printing database objects anddata

2-7 1-4

Export Data From Access

Exporting data from Access(e.g., Excel)

8-3

Back Up a Database

Backing up a database 7-2

Compact and Repair Databases

Using Compact and Repair 7-3

APPENDIX B

Appendix B: Microsoft Office Specialist Program 341

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 357: Access Level 1

Microsoft® Office Access 2003 - Level 1342

NOTES

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 358: Access Level 1

Due to classroom setup constraints, some labs cannot be keyed in sequence immediately fol-lowing their associated lesson. Your instructor will tell you whether your labs can be practicedimmediately following the lesson or whether they require separate setup from the main lessoncontent. Lesson-level lab setup information is listed in the front of this manual in the coursesetup section.

LESSON 1 LAB 1Examining the Microsoft Northwind.mdb Database

Activity Time:

10 minutes

Data Files:

• Northwind.mdb

Scenario:The consultant that installed your Access application and developed the company’s databaseshas suggested to your manager that you practice using the program before actually workingwith the company’s real data. He suggested opening and touring the Microsoft Northwind.mdbdatabase, which comes as part of the application.

1. If necessary, launch Access.

2. Search for and locate the Northwind.mdb database.

3. Open the Northwind database and display the Database window. Close the taskpane. At the Welcome screen, click OK. Close the Main Switchboard.

4. Open the Customers table and examine the table in Datasheet view.

5. Examine the table in Design view.

LESSON LABS

LESSON

LABS

Lesson Labs 343

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 359: Access Level 1

6. Close the table, and then close the database.

LESSON 2 LAB 1Working with Data in Tables

Activity Time:

10 minutes

Data Files:

• UseForms.mdb

Scenario:Imagine that you work as a data entry person for the GSC Corporation and you have justreceived a new customer’s information. Before the customer can place an order they need tobe added to the company’s database. To add the customer, you need to open the UseForms.mdb database and input the necessary data.

1. In the UseForms.mdb database, use the frmGSCCustomers form to add the fol-lowing 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

2. Close the form.

3. In the tblCustomers table, verify that the new customer’s data was addedcorrectly.

4. Close the table and the database; do not save your changes.

LESSON

LABS

Microsoft® Office Access 2003 - Level 1344

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 360: Access Level 1

LESSON 3 LAB 1Examining the Northwind.mdb Database RelationshipsWindow

Activity Time:

10 minutes

Data Files:

• Northwind.mdb

Scenario:To reinforce your understanding of table links and relationships, the consultant also suggestedthat you examine the Northwind.mdb database’s Relationship window and open several tablesand subdatasheets to familiarize yourself with their use in a larger database environment.

1. Search for and locate the Northwind.mdb database.

2. Display the Relationships window.

3. Right-click in the header of the Orders table and choose Table Design to displaythe table in Design view.

4. Display the table in Datasheet view.

5. Open several of the Customer record’s subdatasheets to examine the ordersthey have placed.

6. Close the subdatasheets, close the table, close the Relationships window, andthen close the Database window.

LESSON

LABS

Lesson Labs 345

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 361: Access Level 1

LESSON 4 LAB 1Creating 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 infor-mation about each book, each order placed, and each customer. In this activity, you will createseveral queries to answer business-related questions, such as the following:

• Which books have sold?

• Which book orders have been for 250 or more books?

• How many sales transactions were recorded by the sales rep whose ID is EN1-22?

• Which transactions did sales rep EN1-22 have on August 16, 2001?

• How much did each individual book order cost?

The Solution BookBiz file is a completed file of this activity. You can compare your results to this file.

1. Open the BookBiz database.

2. Imagine that you would like to see a listing of which books have sold. Use theQuery Wizard to display data from both the BookOrders and Books tables. Fromthe BookOrders table, add the SalesId, Date, and Quantity fields. From the Bookstable, add the BookNumber and BookPrice fields.

3. Indicate that you want to see the Detail records.

4. Give your query the title of MyBookSales

LESSON

LABS

Microsoft® Office Access 2003 - Level 1346

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 362: Access Level 1

5. Run the query.

6. Next, suppose you want to view only a portion of the records. First, you want toview all of the orders that were for a quantity of 250 or greater. Use criteria toselect just the records you want. Record the number of records that satisfythis 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 thiscriteria: _____________.

Next, you want to know how many of the sales records for sales rep EN1-22occurred on 8/16/2001. Enter the appropriate criteria. Record the number ofrecords that satisfy this criteria: _____________.

Save your revised query as MySelectBookSales and close it.

7. Next, you’ll create a query that answers the question, “How much did each indi-vidual book order cost?” Create a query in Design view that includes theBookOrders table and the Customers table. Add the CustomerName, Quantity,and BookNumber fields to the design grid. Sort the query records byCustomerName. Run the query and view the results.

8. Return to the query’s Design view and add the Books table to the query. Fromthe Books table, add the Title field to the design grid.

9. Create a field that calculates the total price each customer owes for each bookorder. (Multiply the Quantity field from the BookOrders table by the BookPricefield from the Books table.) Change the default calculated field name toOrderCost

10. Run the query and, before closing it, save it as MyBookCosts

11. Close the BookBiz database.

LESSON

LABS

Lesson Labs 347

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 363: Access Level 1

LESSON 5 LAB 1Creating 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 referto customer orders. You’ll need to include customer information, as well as order details. Usethe Form Wizard to quickly create a basic form and then modify the form you created.

The Solution BreadBiz file is a completed file of this activity. You can compare your results to this file.

1. Open the BreadBiz database.

2. In the BreadBiz database, use the Form Wizard to create a form based on theCustomers and OrderDetails tables. From the Customers table, add all the fieldsto the selected field list. From the OrderDetails table, add all the fields to theselected fields list.

3. Specify that you want to view the information in the form by Customers.

4. Use the Datasheet layout. Choose a form style you like. Save the form asMyCustomers and save the subform as MyOrderDetails Subform

5. Customize the appearance of the form by selecting, sizing, aligning, and mov-ing controls.

6. Save the modified form design and view the form.

7. Close the form and close the BreadBiz database.

LESSON

LABS

Microsoft® Office Access 2003 - Level 1348

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 364: Access Level 1

LESSON 6 LAB 1Creating and Modifying Reports

Activity Time:

20 minutes

Data Files:

• PersonnelBiz.mdb

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 theReport Wizard to create a phone list report based on a query. You will also work in Designview to make some modifications to a report that focuses on the employee payroll.

The Solution PersonnelBiz file is a completed file of this activity. You can compare your results to this file.

1. Open the PersonnelBiz database.

2. In the upcoming days, the company parking lots are being repaved and you’ll needto notify employees by calling them as necessary. Use the Report Wizard to cre-ate a printed phone list report based on the ParkingLot query.

• Add the following fields: FirstName, LastName, ParkingLot, and Phone.

• View your data by Employees.

• Group the report based on the ParkingLot.

• Sort by the FirstName field in ascending order.

• Select the Tabular layout and Corporate style for the report.

• Name the report MyPhoneList

• Preview the report.

Close the report.

3. Suppose you already created another report and want to complete it by enhancingits appearance. In EmployeePay report’s Design view, apply the Soft GrayAutoFormat to change the look of the report.

4. You want to add a field that calculates the annual salary. Under the Annual Salarylabel control, create a field that multiplies Weekly Hours, Hourly Pay Rate, and52. Delete the default label for the control and align the text box control asnecessary. Change the format of the new calculated control so that it printsthe values in Currency format with zero decimal places.

5. Change the format of the text control in the Page Footer section that containsthe Date function from Short Date to Long Date.

LESSON

LABS

Lesson Labs 349

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 365: Access Level 1

6. Save the revised report as MyEmployeePay

LESSON 7 LAB 1Planning a Simple Human Resources Database

Activity Time:

10 minutes

Scenario:You are responsible for designing your company’s Human Resources database to track employ-ees and their related information, including personal data, department, pay rate and benefits,and parking lot assignment. Following the database design process, you need to create anappropriate design plan that includes a statement of purpose, a list of appropriate tables, andthe fields in each table with primary and foreign key assignments.

The SolutionDatabaseDesign.doc file in the LessonLabSolutions folder is a completed file of this activity. You cancompare your results after each step to this file.

1. Based on the assignment you have been given, write an appropriate statement ofpurpose for this database.

2. After looking at the available sources of data and discussing this project with thevarious users and stakeholders, you’ve decided you need to include the followingfields: Name, Address, City, State, Zip, WorkPhone, DateHired, Hours, PayRate,Health, ParkName, ParkFee, and DeptName. Using this field list, organize thefields into logical tables.

3. Using the normalization guidelines, normalize your list of tables by moving,splitting, or adding fields as necessary. Include any additional fields that willbe needed to uniquely identify each record in each table and to relate thetables together.

4. Designate fields to be used as primary and foreign keys for each table.

LESSON

LABS

Microsoft® Office Access 2003 - Level 1350

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 366: Access Level 1

LESSON 8 LAB 1Creating a Database and Adding Tables

Activity Time:

15 minutes

Scenario:You have a database design for a simple Human Resources database that stores informationabout employees, their pay and benefits, parking lots, and departments. Using this design planyou now need to create the database and its related tables.

The SolutionMyHR.mdb file in the LessonLabSolutions folder is a completed file of this activity. You can compareyour results to this file.

1. Create and save a new blank Access MDB file named MyHR.

2. Using the design plan, use the Table Wizard to create a table namedtblEmployees. Use the Employees sample table in the Business section. Afterthe wizard is finished, open the table in Design view and set the field size ofthe DeptCode field to 4.

3. Use Design view to create a table named tblPayAndBenefits with the followingspecifications:

• 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).

LESSON

LABS

Lesson Labs 351

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 367: Access Level 1

4. Use Design view to create a table named tblParking with the following specifi-cations:

• A ParkCode field with a data type of AutoNumber.

• A ParkName field with a data type of Text and a field size of 50.

• A ParkFee field with a data type of Currency.

5. Use Design view to create a table named tblDepartments with the followingspecifications:

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

6. Establish the appropriate relationships between the tables. Enforce referentialintegrity between them.

LESSON 9 LAB 1Streamlining Data Entry and Maintaining Data Integrity

Activity Time:

15 minutes

Data Files:

• PersonnelOffice.mdb

Scenario:You have been asked to improve the PersonnelOffice database. You decided to start by modify-ing the design of the tblPayAndBenefits table to streamline data entry and maintain dataintegrity. First, you’ll assign field properties to several fields in the table. Then, using the InputMask Wizard, you’ll add a new field to this table to store social security numbers. To furtherfacilitate data entry, you’ll also change the ParkingLotCode field to a Lookup list by using theLookup Wizard.

The SolutionPersonnelOffice.mdb file, located in the LessonLabsSolutions folder, is a completed file of thisactivity. You can compare your results to the tblPayAndBenefits table in this file.

1. In the PersonnelOffice database, open tblPayAndBenefits and view the fieldsand records.

2. Change the design of the table so that data entry is required in these threefields: EmpID, Dept, and Hours.

LESSON

LABS

Microsoft® Office Access 2003 - Level 1352

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 368: Access Level 1

3. Change the design of the table so that an entry in the Hours field is valid onlyif it is over 15. If a value of 15 or less is entered, display a text message thatreads: Number of hours worked must be greater than 15.

4. Change the design of the table so that the PayRate field has a default value of11.

5. In this same table, add a new Text field for SocialSecurityNumber. Use thestandard input mask for social security numbers.

6. Create a Lookup column for the ParkingLotCode field. Specify that the Lookuplist be based on the values in tblParkingInfo. Display the ParkingLotCode andParkingLot fields as columns in the Lookup list. Store the value from theParkingLotCode field.

7. In Datasheet View, enter values in a new record. Experiment by leaving somevalues null where they are required. Attempt to move to the next record andrespond to the error messages, as necessary.

LESSON 10 LAB 1Finding Data with Filters and Joins

Activity Time:

15 minutes

Data Files:

• GourmetShop.mdb

Scenario:You run a Gourmet Foods Shop that supplies gourmet foods to other retailers. When reviewingyour product line and pricing structure, you need to create and apply filters to display only thedata 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 onlythose orders from customer number 245 after 8/31/2001. You also need to display related datafrom multiple tables so you will use query joins to display the products ordered with therelated Rep and OrderID number for each order. You also need a query that displays theOrderID, Quantity, and Customer names for each order that included a Grilling Sauce product.

The SolutionGourmetShop.mdb file, located in the LessonLabsSolutions folder, is a completed file of this activity.It includes the finished queries for this activity

1. Open the GourmetShop database. Open the tblProducts table.

LESSON

LABS

Lesson Labs 353

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 369: Access Level 1

2. Use a Filter By Selection to display only those products that are SaladDressings. Remove the filter. Your results should include six records.

3. Use a Filter By Selection to display only those products with a price of $6.50.Remove the filter. Your results should include three records.

4. Use a Filter By Form to display only those products that are either GrillingSauces or have a price of $6.00. Remove the filters and close that table. Yourresults should include five records, as one product fits both criteria.

5. Open tblOrders. Use an Advanced Filter to display orders by customer number245 after 8/31/2001. Then remove all filters. Your results should include 13records.

6. Create a query named qselRepProducts that for each Order displays the Repnumber, the Order Number, the Quantity, and the Product name.

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

LESSON 11 LAB 1Creating Flexible Queries

Activity Time:

15 minutes

Data Files:

• MusicShop.mdb

Scenario:You are in charge of training at The Music Shop. You keep track of the courses offered toemployees, the employees who have registered for the courses, and available rooms by usingthe MusicShop database. You have decided to improve your queries by making them flexible.First, you want to know how many students are registered for each course; and, beyond that,you want to see the top five courses, in terms of students enrolled. Second, you want to beable to enter a student ID and get a listing of all the courses for which that student isregistered.

The SolutionMusicShop.mdb file, located in the LessonLabsSolutions folder, is a completed file of this activity. Itincludes the finished queries for this activity.

LESSON

LABS

Microsoft® Office Access 2003 - Level 1354

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 370: Access Level 1

1. Open the MusicShop database. Review the tables to become familiar with thedata they contain.

2. Open qselCourseRegistration, which shows students who are registered for eachcourse.

3. In the query results, show the count of students registered for each course.

4. Sort the datasheet so that the highest count is displayed first.

5. Display the records for only the top five courses according to the count value.

6. Save the revised query as qselMyTop5Courses.

7. Open qselStudentRegistration which lists student information along with coursesthey are registered for.

8. Change this into a parameter query that prompts for student ID.

9. Save the revised query as qselMyStudentRegistration.

10. Test the query with sample student IDs (for example, 1640 or 4944).

LESSON 12 LAB 1Creating a Form that Combines Data from Two Tables

Activity Time:

15 minutes

Data Files:

• TrainingCenter.mdb

Scenario:As head of training at The Music Shop you use the TrainingCenter database to track studentsand courses. You need a quick way to look up course attendees by course and modify theiraddresses 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 willalso enhance the appearance and usability of the form by adding a title, graphic elements, anda command button that enables a user to find a record.

The SolutionTrainingCenter.mdb file, located in the LessonLabsSolutions folder, provides examples of possiblesolutions for the main form and subform for this activity.

LESSON

LABS

Lesson Labs 355

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 371: Access Level 1

1. In the TrainingCenter database, use the Form Wizard to create a form with asubform.

2. To create the main form use the Form Wizard. Select tblCourseSchedule as thedata source and choose fields for the main form including CourseCode,StartDate, Instructor, and other relevant course data. Save the form asfrmMyCourseSchedule.

3. With your new form open in design view, create the subForm using the Subform/Subreport Wizard. Select qselStudentAttendance as the data source andchoose fields for the subform including LastName, FirstName, Address,HomePhone, and others as desired. Use the CourseScheduleID field as the linkfield. Save the subform as fsubMyStudentSubform.

4. Enhance the appearance of the form by adding a title and using the line andrectangle tools to set off and group controls.

5. Add a command button to search for a record and name it Find Record.

LESSON 13 LAB 1Customizing Your Reports

Activity Time:

20 minutes

Data Files:

• ClothesShop.mdb

Scenario:You work for a small clothes manufacturing business and you use the ClothesShop database totrack customers, products, and orders. You need to create a report that details customer orderinformation. The report will be based on a query called qselCustomerOrders that draws datafrom several tables in this database. In your report, include all the fields from the query andgroup the customers by state. Under each state, you’ll also want to show totals for quantityand order totals for that state. For convenience, you’ve been asked to show the quantity soldtotals for each date at the end of this report.

The SolutionClothesShop.mdb file, located in the LessonLabsSolutions folder, provides an example of a possiblesolution for this activity.

LESSON

LABS

Microsoft® Office Access 2003 - Level 1356

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 372: Access Level 1

1. Open the ClothesShop database. Use the Report Wizard to create a new reportbased on qselCustomerOrders query. Include all of the fields in this report.

2. Rather than grouping by ProductID, group customers by State. Within eachgrouping, sort the customers by the OrderDate.

3. Include summary values to total Quantity and OrderTotals.

4. Lay out the report in Landscape orientation. Choose a format and style for thereport. Use an appropriate title for the report, such as rptCustomerOrders.

5. Identify some of the things that you can improve about your data layout,depending on which report style you chose.

6. Fine-tune the report design by customizing the Caption, Text Align, and CanGrow properties of the controls that call for those specifications. Adjust thewhitespace and page breaks, as necessary, to improve the layout.

7. Using the Subform/Subreport Wizard, add a subreport to the Report footer thatwill display the total quantity sold each day. Use qselQuantityByDate as thedatasource and do not define a link field between the subreport and the mainreport. Fine tune its appearance and placement on the main report as desired.

LESSON 14 LAB 1Using Access Data in Other Office Programs

Activity Time:

15 minutes

Data Files:

• ClothesShop.mdb

Scenario:At The Clothes Shop, your colleagues have requested that you provide the total productsordered data as a Word document. They said they would also like to see the data as a pie chartas well. And they will need the data in text format in order to later import it into anotherapplication.

The SolutionMyTotals.xls, SolutionMyTotals.doc, and SolutionMyTotals.txt files, located in theLessonLabsSolutions folder, are completed solutions for this activity.

LESSON

LABS

Lesson Labs 357

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 373: Access Level 1

1. Open the ClothesShop database and review the qselTotProdOrd query andrptTotProdOrd reports.

2. Publish rptTotProdOrd with Word. Save the Word document as MyTotals.doc.

3. Analyze the qselTotProdOrd query in Excel.

4. Create a 3-D exploded pie chart as a new sheet.

5. Save the Excel spreadsheet as MyTotals.xls.

6. Add the chart to the end of the MyTotals Word document by choosing Insert→Object in Word. Select the Create From File tab and browse to the MyTotals.xls file.

7. Export the data in qselTotProdOrd to a text file. Delimit the data with asemicolon.

LESSON

LABS

Microsoft® Office Access 2003 - Level 1358

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 374: Access Level 1

SOLUTIONS

Lesson 1Activity 1-1

1. 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 house-hold 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 purchasinginformation.

3. Which of the following is representative of a relational database?

a) Note card

✓ b) Library file system

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

✓ c) Redundancy

d) Ease of management

e) Power

Activity 1-2

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

✓ a) New

✓ b) Open

c) Save

d) Cut

✓ e) Microsoft Office Access Help

f) Undo

g) Code

✓ h) File Search

SOLUTIONS

Solutions 359

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 375: Access Level 1

Activity 1-3

4. Match the type of Access object with the description of the function(s) that itperforms.

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

Activity 1-4

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

Lesson 2Activity 2-1

2. How many fields are displayed in the form?

Nine.

3. What field is highlighted by default?

CustomerID.

4. How many records are in the table?

Fourteen.

SOLUTIONS

Microsoft® Office Access 2003 - Level 1360

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 376: Access Level 1

Activity 2-2

3. How many records are in the table?

a) 12

b) 13

c) 14

✓ d) 15

Activity 2-3

4. How is the table sorted?

✓ a) By OrderID

b) By ItemNum

c) By Quantity

Activity 2-6

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

No.

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

No. It came from more than one table.

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

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

Lesson 3Activity 3-1

2. According to the Relationships window, how many tables are connected in this data-base?

a) One

b) Three

✓ c) Five

d) Seven

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

a) One

✓ b) Two

c) Three

SOLUTIONS

Solutions 361

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 377: Access Level 1

d) Four

4. How many have more than two links?

✓ a) One

b) Two

c) Three

d) Four

5. In the Relationships window, to which table(s) is the tblNotes table linked?

✓ a) tblComputers

b) tblDepartments

c) tblEmployees

d) tblManufacturers

e) tblNotes

Activity 3-2

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

✓ a) Primary key

b) Foreign key

c) Primary and foreign key

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

a) Primary key

✓ b) Foreign key

c) Primary and foreign key

4. In the tblComputers–tblNotes relationship, in which table is AssetTag a primary key?

a) tblComputers

b) tblNotes

c) Neither

✓ d) Both

SOLUTIONS

Microsoft® Office Access 2003 - Level 1362

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 378: Access Level 1

Lesson 4Activity 4-1

3. How many records are now displayed?

a) 7

b) 12

✓ c) 19

d) 25

Activity 4-3

2. How many records are displayed?

a) 11

b) 21

✓ c) 23

d) 32

7. How many records are displayed?

a) 5

✓ b) 10

c) 15

d) 20

Activity 4-4

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

a) 12

b) 14

c) 17

✓ d) 19

e) 35

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

✓ a) 35

b) 12

c) 19

d) 17

e) 60

Activity 4-5

3. What is Rob Abbott’s weekly pay?

SOLUTIONS

Solutions 363

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 379: Access Level 1

a) 56

b) 250

✓ c) 760

d) 2,500

Lesson 5Activity 5-1

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

a) Your boss

b) Your co-worker

✓ c) The user

d) The consultant

2. In Design view, which section of a form would typically contain page numbering infor-mation?

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

Activity 5-2

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

4. True True or False? New records can be added to the table with the AutoForm youcreated.

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

Activity 5-5

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

✓ a) Address text box

b) Postal Code label

✓ c) Postal Code text box

SOLUTIONS

Microsoft® Office Access 2003 - Level 1364

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 380: Access Level 1

d) Region label

Lesson 6Activity 6-1

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 eachpage. The column headings would also be printed. The data is easy to read with eachrecord arranged horizontally in a grid.

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

There are no totals, and there is no formatting. In addition, the data is split across twopages.

5. How does the AutoReport compare to the printed datasheet?

The fields are arranged in a vertical column. An extra blank line separates each record.There’s no heading, date, or page numbers. The report is eight pages long.

Activity 6-3

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.

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

Activity 6-7

2. Why are there blank pages between the printed pages?

a) There is not enough text on the pages.

b) The font is too large.

SOLUTIONS

Solutions 365

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 381: Access Level 1

c) The margin setting is too narrow.

✓ d) The margin setting is too wide.

4. Why are these settings causing the blank pages?

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

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

You could:

• Decrease the width of the lines and then decrease the width of the report in Designview.

• Change the report to Landscape orientation.

• Make the margins smaller.

Lesson 7Activity 7-1

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

5 Enter sample data, review for possible maintenance problems, and revise the tabledesign 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.

Activity 7-2

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

Answers will vary somewhat, but should be something like: “The database will hold infor-mation on the company’s inventory of computers and their assignment to employees.”

2. What is wrong with this statement of purpose: “The database will have tables for com-puters, personnel, manufacturers, product sales, salaries, and company suggestions.”

✓ a) The statement of purpose should not attempt to list specific tables.

✓ b) The statement of purpose is too broad.

c) There is nothing wrong with this statement of purpose.

3. What is wrong with this statement of purpose: “The database will allow the user togenerate reports that list the computers used by each employee, as well as queriesthat sort records by the date the computer was purchased and the manufacturer of thecomputer.”

SOLUTIONS

Microsoft® Office Access 2003 - Level 1366

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 382: Access Level 1

✓ a) It doesn’t discuss the scope of information to be included in the database.

✓ b) It doesn’t mention or imply how its information will be related.

✓ c) It discusses specific features (queries and reports) that you would like to seeprovided.

d) There is nothing wrong with this statement of purpose.

Activity 7-3

1. What pieces of data from the sample ticket do you think should be included in yourdatabase?

✓ a) Date computer acquired

✓ b) Manufacturer name

✓ c) Asset tag number

✓ d) Department of employee

2. What other sources of data might you use for determining what data should beincluded in the database?

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

Activity 7-4

1. What additional data will you need to include about each employee?

✓ a) Name

b) Salary

c) Date of birth

✓ d) Computers assigned

✓ e) Manager of employee

2. What additional fields will you need to include in the database to enable the TechnicalServices manager’s weekly reports and the Finance manager’s monthly report?

✓ a) Warranty coverage

✓ b) Purchase price

c) Software games included

d) Number of current files on the computer

Activity 7-5

1. Based on the information you have now, which two tables would be minimally requiredfor this database?

a) Computers and Notes

✓ b) Computers and Employees

c) Computers and Departments

d) Employees and Departments

SOLUTIONS

Solutions 367

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 383: Access Level 1

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, six of them could go in a Computers table.

Activity 7-6

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 forthe last name.

c) It should include the last name data only.

d) Nothing, it is fully normalized as it is.

2. True or False? Since the Department field holds repeated values, a Departments tableshould hold those values.

✓ True

False

3. True or False? Since not all records have an entry in the Note field, strict adherence tonormalization guidelines would require the note field be moved to a separate table.

✓ True

False

4. What can be done to normalize the data in the Manufacturer field?

a) The entries should be in all lowercase.

b) The entries should be in all uppercase.

✓ c) Since it has repeated entries, there should be a Manufacturers table to hold thatdata.

d) Nothing, it is fully normalized already.

5. If you chose to not normalize the data in the Manufacturer field in this way, that wouldbe an example of denormalizing the data.

6. What needs to be done to normalize the Warranty field’s data?

a) It should be a text field.

b) Because some check boxes are not checked, that data belongs in a separate table.

✓ c) Nothing, it is fully normalized already.

Activity 7-7

1.

SOLUTIONS

Microsoft® Office Access 2003 - Level 1368

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 384: Access Level 1

The Address field does not contain the smallest meaningful values.

2. Based on the data shown, which additional fields would you need to add to normalizethis data?

✓ a) City

✓ b) State

✓ c) Zip Code

d) Country

3.

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.

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 asingle person was assigned to a third project, you would have to add two more fields tothe 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.

The Phone field contains unnecessarily repeated values that rely on a non-key field.

7. What data maintenance problem does this cause?

You would need to edit the phone numbers in more than one record.

8. True or False? You could normalize this data by moving the ProjectManager and Phonefields into a second but related table.

✓ True

SOLUTIONS

Solutions 369

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 385: Access Level 1

False

Activity 7-8

1. Which field in the Employees table would be best as a primary key?

a) EmployeeLastName

b) EmployeeFirstName

c) DeptCode

✓ d) A new field, EmployeeID

2. In which table should the EmployeeID field appear as a foreign key field?

a) Departments

✓ b) Computers

c) Manufacturers

d) Notes

3. The DeptCode field should be the primary key field for the Departments table.

4. Which table should have DeptCode as a foreign key field?

✓ a) Employees

b) Computers

c) Manufacturers

d) Notes

5. The AssetTag field can serve as a primary key field for both the Computers and Notestables.

6. If you were to add a ManufacturerID field to serve as the primary field for the Manufac-turers table, what other table should have a ManufacturerID field as a foreign key?

a) Employees

b) Departments

✓ c) Computers

d) Notes

Lesson 8Activity 8-1

2. The initial description of this template looks promising. Which of your planned data-base tables seem to match to the information listed?

✓ a) Employees

✓ b) Departments

✓ c) Manufacturers

✓ d) Computers

SOLUTIONS

Microsoft® Office Access 2003 - Level 1370

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 386: Access Level 1

e) Notes

Activity 8-4

2. What is the default Field Size for the AutoNumber data type?

a) Byte

✓ b) Long Integer

c) Decimal

d) Currency

Activity 8-5

2. Referring to your database diagram, you see that the next field, ManufacturerID is aforeign key field. What data type and field size must it therefore have?

a) AutoNumber and Byte

b) Number and Byte

c) AutoNumber and Long Integer

✓ d) Number and Long Integer

6. Because PurchasePrice is a field with financial data, what datatype would likely bebetter than number?

a) Text

✓ b) Currency

c) Yes/No

d) Memo

Activity 8-7

3. The tables in the Relationships window are arranged in alphabetical order by default.

5. What sort of relationship is there between the tblDepartments and tblEmployees tablesand why?

a) There is a one-to-one relationship because for every department record there will beone employee record.

✓ b) There is a one-to-many relationship because for each department record there couldbe many employee records.

c) There is a one-to-many relationship because for each employee record there couldbe many department records.

7. In the Edit Relationships window, what kind of relationship is given as the Relationshiptype?

a) One-to-One

✓ b) One-to-Many

c) Many-to-One

d) Many-to-Many

9. What sort of relationship is there between the tblComputers and tblNotes tables

SOLUTIONS

Solutions 371

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 387: Access Level 1

and why?

✓ a) There is a one-to-one relationship because for each computer record there will be atmost one note record, and vice-versa.

b) There is a one-to-many relationship because for each computer record there couldbe many note records.

c) There is a one-to-many relationship because for each note record there could bemany computer records.

Lesson 9Activity 9-1

7. A default value of 40 is displayed in the Hours field.

Lesson 10Activity 10-1

2. How many records matched the filter?

a) 13

✓ b) 14

c) 15

d) 20

5. How many records matched this filter?

a) 3

b) 5

✓ c) 6

d) 7

7. How many records match either salesperson en1-20 or have a country of Canada?

a) 6

✓ b) 8

c) 10

d) 12

Activity 10-2

3. How many records match both criteria?

a) 2

SOLUTIONS

Microsoft® Office Access 2003 - Level 1372

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 388: Access Level 1

b) 3

c) 4

✓ d) 5

Activity 10-3

2. 2900 records are in the query results.

3. True or False? The reason this many records appear is because no join between thetables has been established, so each record from tblBookProject is combined with eachrecord from tblBookSales.

✓ True

False

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

6. Only books with sales are displayed. How many records for such books are in theresult?

a) 29

b) 90

✓ c) 100

d) 2900

8. All the records from tblBookProject are displayed. Only the matching records fromtblBookSales are displayed. How many results are displayed?

a) 29

b) 100

✓ c) 108

d) 2900

Activity 10-4

4. True or False? Books that lack sales will not appear because this is an equi-join and nota left-outer join.

✓ True

False

Activity 10-5

1. In order to design a query to display supervisor names for each employee, which twofields in tblSupervisors will need to be related?

a) Id and LastName

✓ b) Id and SupervisorId

SOLUTIONS

Solutions 373

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 389: Access Level 1

c) Dept and SupervisorId

d) LastName and SupervisorId

Lesson 11Activity 11-1

2. 14 records are included in the query results.

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

Activity 11-2

2. There are 100 total records returned by this query.

3. There are 3 records with a customer of Allendale Books and a book title of “ImprovingYour Tennis Game.”

6. There are now 81 total records displayed by the query.

7. There is now 1 record with a customer of Allendale Books and a book title of “Improv-ing Your Tennis Game.”

Activity 11-4

4. How many records satisfy the three criteria you set with parameters?

a) 10

b) 12

✓ c) 15

d) 20

Activity 11-5

2. True or False? For books with part numbers that begin with 31 or 34, the prices rangefrom $25.95 to $45.95.

✓ True

False

4. There are 12 records that have a part number that begins with either 31 or 34.

7. What is the new range of prices for books with part numbers beginning with 31 or 34?

a) $25.95 to $45.95

SOLUTIONS

Microsoft® Office Access 2003 - Level 1374

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 390: Access Level 1

✓ b) $27.25 to $48.25

c) $30 to $50

8. What would happen to the values in the BookPrice field if you ran the query again?

a) Nothing, they would remain the same because they have already been increased by 5percent.

✓ b) The values in the BookPrice field in the underlying table would again be increased by5 percent.

c) The previous prices would be reinstated: the 5 percent increase in price would berevoked.

d) An error would result.

Activity 11-6

4. 4 records are displayed by this query.

7. The tblBookProject table had 26 records before the append query was run. How manyrecords does it have now?

a) 26

b) 29

✓ c) 30

d) 33

Lesson 12Activity 12-5

5. True or False? Although the CustomerID field is not found in the subform, because thetblCustomer and tblBookSales are related, the data in the CustomerID field in the mainform will be used for the CustomerID data in the related table as well.

✓ True

False

SOLUTIONS

Solutions 375

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 391: Access Level 1

Lesson 13Activity 13-1

5. What are some things you could improve about the data layout?

Captions, widths, and alignment could be improved.

6. What are some things you could improve about the pagination? For example, is there alot or a little white space? Where do pages break?

There is too much white space under the text box controls in the Detail section. Data isgrouped by book title. Groups are broken from one page to the next. It would be better ifyou could control where the pages break.

7. What are some things you could improve about the summary data in each group andthe end of the report?

The summary information for each group indicates the number of detail records in thegroup 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 ison the last page of the report; it indicates the grand total of the number of books sold.

Lesson 14Activity 14-3

3. True or False? The headings for each column of data were not exported with thevalues.

✓ True

False

4. True or False? When a value was empty (null) a space is placed between the two semi-colons that delimit this field from the previous and next fields.

True

✓ False

5. In order for this exported data to be optimally used by another application, whichcharacter must not appear in the data?

a) Comma

✓ b) Semicolon

c) Space

d) Ampersand

SOLUTIONS

Microsoft® Office Access 2003 - Level 1376

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 392: Access Level 1

AAccess environment, 5

Access objects, 8

action queries

adding, 232, 236, 239

append queries, 230

creating, 231, 232, 235, 236, 239

defining, 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 field, 158

AutoReport, 96

creating an, 96

BBetween... And operator, 224, 227

blank databases

creating, 152

blank values, 134

Boolean

See: conditional operator

business rules, 131

Ccalculated field, 63, 108

Can Grow control property, 285, 286

Can Shrink control property, 285

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

Ddata

creating an Excel chart, 317

exporting, 317, 321, 322, 323

INDEX

INDEX

Index 377

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 393: Access Level 1

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 field property, 172, 174

delete queries, 231, 239

denormalization, 134

design enhancements, 278

Design view, 13

Eexisting data

reviewing, 124

exporting, 317, 321, 322, 323

expression, 61

Expression Builder, 62

Ffield, 2, 12

Field list, 245, 279

field name, 13

field names, 132

field properties, 13, 172, 174

modifying, 173, 174, 217, 220

setting, 173, 174, 217, 220

Field Size property, 158

filter

removing a, 28

Filter By Form technique, 192, 193, 194

Filter By Selection technique, 192, 193, 194

Filter Excluding Selection technique, 192

filters

creating an advanced filter/sort, 193

finding data, 193, 194, 196

removing, 194

using criteria, 193, 194, 196

Force New Page property, 290

foreign key, 41, 42

foreign key fields, 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

justified, 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 field property, 172, 174

formatting palettes, 246, 248

Formatting toolbar, 245, 246, 248, 279

forms

adding a command button, 267

designing, 246, 247, 248

GGroup Footer section, 291

Group Header section, 291

grouped controls, 247

HHeight control property, 285, 286

Hide Duplicates control property, 285

Iicon, 5

inner joins, 198, 202

Input Mask field property, 177

Input Mask Wizard, 178, 179

INDEX

Microsoft® Office Access 2003 - Level 1378

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 394: Access Level 1

input masks

adding, 179

creating, 179

defining, 177

Jjoin lines, 198, 206

creating, 201, 202, 209

joins, 198, 199, 205, 206, 208

changing the type, 201

creating, 201, 202, 209

defining, 198

removing, 201

query joins

justified form, 73

KKeep Together property, 290

LLike operator, 223, 225, 227

list boxes, 254, 256

logical operator

See: conditional operator

lookup lists

creating, 185

defining, 183

using, 185

Lookup Wizard, 185

MMailing 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

defining, 222

Nnaming conventions, 9

navigation bar, 12

normalization, 133, 134

Oobjects, 8

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

Pparameter queries

creating, 224, 225, 227

defining, 222

running, 224, 225, 227

prefix, 28

primary key, 41, 42

primary keys, 139

setting, 154

prompt messages, 224

Properties dialog box, 245, 279

Qquery, 8, 27

adding a calculated field, 63

Select query, 50

Query Design toolbar, 51

query joins, 198, 199, 205, 206, 208

changing the type, 201

creating, 201, 202, 209

defining, 198

Rrecord, 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

filtering, 193, 194, 196

grouping, 280, 281

sorting, 280, 281

updating, 231, 232

recordset

INDEX

Index 379

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 395: Access Level 1

displaying a, 28

referential integrity, 165, 166

relational database, 2, 3

relational databases

designing, 120

determining fields, 128

eliminating potential problems, 133

relationships between tables, 38

Relationships window, 38, 166

Remove Filter button, 194

removing, 201

report, 8

adding a calculated field, 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 fields, 295

moving controls, 295

summarizing data, 294, 295

troubleshooting, 291

using enhancements, 278, 285, 286

Required field property, 172, 174

Ssection 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

expanding a, 44

finding data in a, 44

Subform/Subreport Wizard, 270, 271, 301

subforms, 269, 270

adding, 271

creating, 270

subreports, 300

adding, 301

creating, 301

summary fields, 294, 295

Ttab 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 fields, 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 field property, 217

troubleshooting, 291

Uunbound controls, 247

unique records, 216

Unique Records field property, 217

unique values, 216

Unique Values field property, 217, 220

update queries, 229, 231, 232

VValidation Rule field property, 172, 174

Validation Text field property, 172, 174

value, 2

INDEX

Microsoft® Office Access 2003 - Level 1380

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 396: Access Level 1

WWidth 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

ZZoom dialog box, 224

INDEX

Index 381

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y

Page 397: Access Level 1

Microsoft® Office Access 2003 - Level 1382

NOTES

Refe

renc

e M

ater

ial

Plea

se D

o No

t Cop

y