Vous êtes sur la page 1sur 157

And€rsCIr1 Sofr-Teach

STLINENT' WORKtsOOK

ACCESS 2
FORWINDOWS
Andcrson Soft-'feach 289-,+50

ii'i+'' "' :i|lt


!1'
'':)4:;
.i!!:?r.l iriri
.l::9 iil;::"'

,ri'...'' -,' l
:i: . ::"." .i, "

:i1,it t r+- -. .it

nh. - i-rl
''4. :

li : .ri {il!.ii.r:.ii,
..
.:j!.. .1i ..i..

t*t. .iili! tir .;,li


aai ;'*tr

hiame
Table of
Contents
Getting Started.. ........... L

Introduction .............. ...................... 2


You Will Need ....,.........2
Course Components............... .........2
Installing the SmartTrainer Software... ............. 3
Installation Types ......... 3
Preparing the Computer.............. ...................... 3
Starting the SmartTrainer Software .................. 4
Taking This Course Without the CD-ROM .......................4
Special Note......... .........4

Lesson I Exploring Access ..........5


Introduction .............. ...................... 7
Lesson Objectives .........7
Before You Start ........... 8
1-1 Database Concepts .............. 9
l-2 Starting Access ................. 11
1-3 Opening a Database File........... ..........12
l-4 Identiffing Access Objects ................. 13
In Practice: Getting Help ......... ..... 16
1-5 Closing and Exiting .......... 18
Additional Exercises ..................... 19

continued...
Tiile #289-450
Table of Contents continued...

Lesson 2 Working in Tables ......21


..............
Introduction ....................23
Lesson Objectives .......23
Before You Start .........24
2-l Opening a Table ,...............25
2-2 Moving Through Records ...................26
2-3 Editing Records ..,....,........29
2-4 Adding Records ................ 30
2-5 Deleting Records .............. 31
2-6 Closing a Table ...,.............32
In Practice: Previewing and Printing a Table .................. 33
Additional Exercises ..................... 35

Lesson 3

continued...
Title #289-450
11
Table of Contents continued..,

Lesson 4 Finding and Sorting Data ......49


Introduction .............. .................... 51
Lesson Objectives ....... 51
Before You Start .........52
4-l Finding Records ................ 53
4-2 Sorting Records ................ 55
In Practice: Applying a Filter ...... 56
Additional Exercises ..................... 58

Lesson 5 Using Queries .............59


Introduction .............. .................... 61
Lesson Objectives ....... 6l
Before You Start .........62
5-1 Changing Criteria ............. 63
5-2 Arranging Fields ............... 66
5-3 Saving and Closing a Query ...............67
5-4 Deleting Objects ............... 68
5-5 Printing a Query..... ........... 69
Additional Exercises ..................... 70

continued...
Title #289-450 111
Table of Contents continued...

Lesson 6 Viewing and Printing Reports........ ........71


Introduction.............. .................... 73
Lesson Objectives .......73
Before You Start .........74
6-1 Previewing a Report .........75
6-2 Identif,iing Elements of the
Report Design Window ....77
6-3 Printing a Report.... ........... 78
Additional Exercises .....................79

Lesson 7 Und0rstanding Database Design ............81


Introduction.............. .................... 83
Lesson Objectives ....... 83
- Before You Start......... .................. 84
7-I Creating a New Database File .............................. 85
7-2 Importing Tables from Another Database ............ 88
Additional Exercises ..................... 89

continued...
Title #289-450
IV
Table of Contents continued...

Lesson 8 Creating a Table .........91


Introduction .............. .................... 93
Lesson Objectives ....... 93
Before You Start .........94
8-1 Creating a New Table ....... 95
8-2 Saving the Table ............... 99
8-3 Entering Data......... ......... 100
8-4 Changing Field Column Width ........ 101
In Practice: Using the Table Wizard..... .......I02
Additional Exercises ................... 104

Lesson 9 Customizing Tables............. ....105


Introduction .............. .................. 107
Lesson Objectives ..... 107
Before You Start ....... 108
9-1 Specifying Data Types .... 109
9-2 Setting Field Properties ......... ........... 111
9-3 Creating an Input Mask ..I14
In Practice: Creating an Index ...117
Additional Exercises ................... 119

continued...
Title #289-450
Table of Contents continued...

Lesson 10 Understanding Table Relationships....................l2l


..............
lntroduction ...........,...... 123
Lesson Objectives .....123
Before You Start .......124
10- 1 Viewing Database Relationships ............ ............ 125
I0-2 Adding Tables to the Relationships Window .....I29
Additional Exercises ................... 130

Lesson 1L Establishing Table Relationships ....... ..131


Introduction .............. .................. 133
Lesson Objectives ..... 133
Before You Start .......134
I - I Creating a One-to-Many Relationship................ 35
1 1

In Practice: Using Cascade Delete ............... 138


I I -2 Creating a Many-to-Many Relationship ............. I 40
A,dditional Exercises ................... 143

continued...
Title #289-450
vl
Table of Contents continued...

Lesson 12 Designing Select Queries ........145


Introduction .............. .................. 147
Lesson Objectives .....147
Before You Start ....... 148
l2-I Selecting a Table to Query ...............149
l2-2 Adding Fields to the Query .............. 151
l2-3 Viewing the Dynaset ............... ......... 153
I2-4 Sorting Records .............. 154
l2-5 Specifying Criteria .......... 156
12-6 Setting Criteria for a Hidden Field ... 158
In Practice: Creating a Calculated Field ...... 160
Additional Exercises ................... 164

Lesson 13 Designing Multiple-Table Queries .......165


Introduction .............. .................. 167
Lesson Objectives .....167
Before You Start ....... 168
13-1 Joining Tables ................. 169
l3-2 Creating a Multi-Table Query .......... 170
13-3 Creating an Outer Join.......... ............ 171
Additional Exercises ................... 173

continued...
Tirle #289-450 vll
Table of Contents continued...

Lesson 14 Using Form Wizards. ..............175


Introduction .............. .................. 177
Lesson Objectives ..... I77
Before You Start ....... 178
l4-l Creating a Form .............. 180

ffiilffi',Yi,'1,:*:llll*: :: :::: :::::: ::: ::: ::I:;

Lesson 15 Designing Forms ......191


Introduction .............. .................. 193
Lesson Objectives ..... 193
Before You Start .......194
15-1 Accessing the Toolbox ............... ...... 196
I5-2 Creating a Combo Box .......... ........... 198
15-3 Moving and Resizing Controls .........201
In Practice: Using a Combo Box .......... ...,...204
l5-4 Working with Headers and Footers ..205
15-5 Creating an Expression............ .........207
Additional Exercises ................... 210

continued...
Tifle #289-450
vlll
Table of Contents continued...

Lesson 16 Enhancing Forms .....211


..............
Introduction ..................2I3
Lesson Objectives .....2I3
Before You Start .......214
In Practice: Exploring Enhanced Forms ......2I5
16-l Adding Graphics to a Form ........".....216
16-2 Changing Object Layers ...................219
16-3 Changing Text Style .......220
Inserting a Graphic ...224
Additional Exercises ......,............226

Lesson L7 Using Report Wizards ............227


Introduction .............. ..................229
Lesson Objectives .....229
Before You Start .......230
l7-l Creating a Report ............232
In Practice: Using AutoReport ..238
Additional Exercises ...................239

continued...
Title #289-450
ix
Table of Contents continued...

Lesson 18 Designing Reports............. ......241


Introduction.............. .,................243
Lesson Objectives .....243
Before You Start .......244
18-1 Editing Report Design ....245
l8-2 Working with Sections ............. ........249
l8-3 Combining Reports .........254
Additional Exercises ...............,...256

Lesson 19 Designing Graphs in Reports..............................257


Introduction .............. ..................259

;:H::9:lTlllil
19-1
::: : ::
::: ::: :: :::::
Graphics
Copying and Pasting
:: iZZ
.........261
Wizard
I9-2 Using the Graph ...................263
1,9-3 Viewing aGraph .............265
............... ...........267
I9-4 Adding Data Labels
Additional Exercises ................... 268

continued...
Title #289-450
Table of Contents continued..,

Lesson 20 Designing Parameter Queries......... ......269


Introduction .............. ..................271
Lesson Objectives .....271
Before You Start .......272
20-I Creating a Parameter Query..... .........273
20-2 Prompting for Multiple Criteria ........275
In Practice: Controlling Dialog Box Sequence............ ..278
Additional Exercises ................... 280

Lesson 21 Creating Action Queries.. .......281


Introduction .............. .................. 283
Lesson Objectives .....283
Before YouStart .......284
2l-l Creating an Update Query ................ 285
Additional Exercises ................... 288

continued...
Title #289-450 x1
Table of Contents continued...

Lesson 22 Advanced Select Queries ........289


Introduction .............. ..................29I
Lesson Objectives .....291
Before You Start .......292
22-l Calculating Totals for A11 Records ...293
22-2 Setting "Group By" Fields ................295
22-3 Specifying Criteria for Total Fields ..296
22-4 Calculating Averages ......297
22-5 Extracting Unique Values ..........,......299
Additional Exercises ...................302

Lesson 23 Using Query Wizard: Crosstab Query ..............303


..............
Introduction .................. 305
Lesson Objectives ..... 305
Before YouStart ....... 306
23-l Creating a Crosstab Query ................ 307
Additional Exercises ...................3I2

continued...
Title #289-450
xll
Table of Contents continued...

Extra for Experts:......... ..........313


Before You Start ....... 315
Creating an Unbound Control.. ... 316
Creating a Macro ...... 318
Inserting a Macro ......322
Defining a Module ....324

Congratulations .......325

Glossary .....327

Index ..........331

xllt
Exploring Access
Lesson One

Introduction Lesson Objectives


In this lesson, you will review database concepts By the end of Lesson One, you will be able to:
and learn what a relational database is. You will . Start Access
start the Access progf&ffi, open an Access database
and explore the database window.
. Open a Database

This lesson also introduces you to the six objects . Identiff Access Objects
that make up an Access database. . Get Help
Finally, you'll use the Help feature to look up . Close and Exit Access
information about the Access program. Then, you
will close the database and exit the Access program.

Tiile #289-450
Lesson One Before You Sturt

Before You Start


To practice the skills in this lesson using the CD-ROM, perform steps 1 through 4 only.

If practicing the skills in this lesson without the CD-ROM, perform steps 5 and 6 only. The practice
files must be installed on your hard disk in a subdirectory called C:\AST. If they are not, you will
need to install them before continuing. Refer to the section titled "Taking this Course Without the
CD-ROM" on page 4 in the Getting Started section for instructions on how to do this.

Step by Step To get hands-on practice using the CD-ROM:


1 Start: the SmartTrainer sofh'vare
Note: For instructions on how to start the SmartTrainer software,
refer to page 4 in the "Getting Started" section.

2 Choose:

3 Select: Lesson 1- Exploring Access


(listed in the Available Standard Lessons list box)

Choose:
Notice: The first skill in the lesson plan begins playing in the "Try
It" mode-
Note: lf you've just completed the "Show Me" segment of a skill,
you can switch to the "Try lt" mode by choosing the START button
under the words "Try lt" in the enlarged Playback Controlwindow.

To get hands-on practice without the CD-ROM:


5 Start: the Windows program (if necessary)
6 lnstall: the practice files to the C:\AST subdirectory on your
hard disk if necessary
Note: lf the subdirectory C:\AST does not exist, you will need to
install the practice files before continuing. lf you do not have the
practice files, please call Anderson Soft-Teach Multimedia Support
at 800-399-3844 to request a copy of these files.

Tirle #289-450
Lesson One skiu 1-1

Database Concepts
In this skill, you will become familiar with database concepts.

Database: A database is a collection of related information, or data.


Examples of a database include telephone books, checkbooks, employee lists,
customer mailing lists, and so on.

Paper Database: Any database, such as a telephone book, that exists on paper.

Electronic Electronic databases store data electronically, such as a file on your computer, and
Database: allow you to manage data easily. For example, you can store very large amounts of
information and you can quickly extract and rearrange that data.

Relational A relational database allows you to organize and analyze data stored in related
Database: tables. It stores and retrieves information according to relationships you define.

Access: Access is an electronic relational database system used to collect, retrieve, and
present data. Access allows you to work with data in several formats including
tables, customized entry forms, reports, and queries.

Table: A table is a collection of data about a particular subject. This data is presented in
columns (called fields) and rows (called records). All the data in a table should
describe the subject of the table. For example, one table might store employee
information, while another table would contain customer information.

Field: A field is a category of information. It could be employee last names, street address-
es, or phone numbers.

Record: A record is a collection of information about one person, thing, or event. It could be
all the information about one employee, or details about one product.

Cell: The intersection of a column and row is called a cell. Cells contain the individual
values in a table.

Field

Record

(Cont.)
Tirle #289-450
Lesson One skilt 1-1

Database Concepts
(Continued)

Forms: Forms provide a convenient layout for entering, changing, and viewing records in a
database.

Reports: You can use a report


to present your data
on the printed page.
Reports allow you to
show totals and
grand totals across a
set ofrelateddata,
print mailing labels,
and so on.

Queries and A query is a question you ask about the data in your database such as "Which employees
Dynasets: work in the eastern sales region?" The data that answers the question can be from one or
several tables. The query brings the information together in a set of records called a
ttdynaset.tt

SourceTable

Dynaset

EMP38
EMP83
.-E-lt.P_-89
EMP31
Etdff"g:
EMP14

Tiile #289-450
10
Lesson One skill 1-2

Starting Access
To view and work with an Access database, you must first start the Access program.

In this skill, you will start the Access program.

Step by Step 1 Double-click: on the Microsoft Office program group


to open it (if it is not already open)
la{rl
l,{ (r 6 I

Microsoft
0ffice

Note: Once the Microsoft Office program group is opened, you


will see this Microsoft Access application icon in the window.
The Microsoft Office program group may also contain other
icons.

W
Microsoft
Access

2 Double-click: on the Microsoft Access application icon


Notice: The MS Access Cue Cards window appears. This
window gives you the option of viewing cue cards about Access
before you get started.

3 Double-click: the Control-menu box ffi for the MS Access Cue


Cards window (to close it)
4 Maximize: the Access window (if necessary)
Note:To maximize a window, click on its
Maximize Uox ffi in the upper-right corner of the window.

Title #289-450
t1
Lesson One skiu 1-3

Opening a Database File


When you open a file, it resides in your computer's temporary memory. You can only have one
database file open at a time in Access.

In this skill, you will open an Access database file.

Step by Step Examine: the Microsoft Access window


Notice: There are two active menu options on the menu bar.
There are four active buttons and several inactive buttons on the
Standard toolbar.
Menu options

Click: ffi tne Open Database button


Notice: The Open Database dialog box appears, asking for the
name of the file you want to open.

Note: A dialog box is a window that appears temporarily to


request or supply information. Many dialog boxes have options
you must complete before Access can carry out a command.

Examine: the Driyes list box


Notice: The current drive is drive C. lf it is not, then change to
drive C by clicking on the arrow next to the Drives list box and
selecti ng C: Hard_Disk.

4 Double-click: ftl c:\ (in the Directory list box)


5 Double-click: fu asr (in the Directory list box)
Notice: A list of database files appears in the Filename list box)

Double-click: on w&a_1.mdb (in the File Name list box)


Notice: The W&A_1.MDB database file is opened and appears
on your screen. Most of the buttons on the toolbar are now
active.

Tips and Wfim,,Opbning .file i.:you. cau.,atso..click,,oncb:.oa.ftelfilen0me,.afid choose,:the,,Opefi:co S


Techniques button- You can also acieii the Open Database dialog box by selecting the File menu and
choosing the Open Database command.

To open more than one Access database file, you must run another copy of the Access program.
By mnning muftiple copies of Aicess, you can: open as many database files as your computer's
tl...stofEr

Title #289-450
t2
Lesson One skiu 1-4

Identifying Access Obj ects


The Access program window contains all the components of the Access program, along with the
elements that are common to all Windows applications.

In this skill, you will use the diagram below to familiarize yourself with the different parts of the
Access program window.

Step by Step Examine: the Access screen

Control-menu box

Position: the mouse pointer over the buftons on the toolbar


Notice: ToolTips show the function of each button.

(Cont.)
Tirle #289-450
t3
Lesson One skiu 1-4

Identifying Access Objects


(Continued)
An Access database is a collection of objects, not just a single table of data. Each database file
contains tables, as well as queries, forms, reports, and other objects that help you use the information
in the database. The term "object" is also used to describe anything that you can select and manipu-
late as a unit, such as a graphic object or picture within your database.

All these objects


are contained in
the database file,
W&A 1,MDB.

The six major objects that make up an Access database are tables, queries,forms, reports, macros,
and modules. Each object group is organized in the Database window, as shown below. To switch
between object groups, click on the group's object button.

Object buftons

(Cont.)

Title #289-450 t4
Lesson One skiu 1-4

Identifying Access Objects


Step by Step Follow the steps below to view the objects contained in this database:
(continued)
1 Select: the Table object button (if necessary)
Notice: This database contains five tables.
2 Select: the Query object button
Notice: This database contains four queries.

3 Select: the Form object button


Notice: This database contains five forms.

4 Select: the Report object button


Notice: This database contains two reports.
5 Select: the Macro object button
Notice: This database contains zero macros.
Note: A macro is a set of instructions that you create to
automatically carry out a task or series of tasks. Macros are
introduced in the Extra for Experts exercises of this course.

6 Select: the Module object button


Notice: This database contains zero modules.
Note: Modules are units of code written in the Access Basic
language. You can write and use modules to automate and
customize your database in very sophisticated ways. Modules are
defined in Volume 4 of this course.

Tips and Yaul:C :lal$o:::$w-itbfi.. etweeu,,o,$jedt:ig-r.-ofip$:,u$.lw..th.0,,,\riew,,trr.enu,,

Techniques

Titl€ #289-450
t5
In Pructice: Gettins H,

When you have questions concerning the commands and topics in Access, you can receive help from
the Help button on the toolbar, or the Help menu on the menu bar. Clicking on the Help button
allows you to select the part of the screen, menu item, or the button you want to learn about. When
you select Help on the menu bar, you can choose from a list of Help commands that let you access
information in different ways. There's even a feafure called Cue Cards that will walk you through
tasks as you work.

In this skill, you will practice using the Access Help feature.

Step by Step 1 Click: ffi tne Help bufton


Notice: The mouse pointer changes to the Help button symbol.

2 Click: ffi tne Print button


Notice: A Help window appears with information about printing in
Access.

3 Select: the File menu in the Help window


4 Choose: Exit
Notice: This closes the Help window.
5 Select: tn Help menu
Notice: A list of Help commands appears.

6 Choose: Cue Cards


Nbtice: The MS Access Cue Cards window appears with a list of
options from which to choose.

7 Click: ffil see r quick ouerriew


Notice: A list of options aP7ears.

8 Click: [l*tl Daraheses

Notice: An overview of databases appears.

I Choose: t

Notice: Additional information about databases appears.

(Cont.)

Tiile #289-450 16
In Practice: Gettins HeI,

Step by Step 10 Choose: l


(continued)
Notice: You are returned to the main Cue Cards menu.

11 Double-click: the Gontrol-menu box ffi


for the MS Access Cue
Cards window (to close it)

Tips and tld ffiU*a[11 CI*'.$nie6. to choosb, Take some ffiF..tlaiuti$..8xFffiedt


wiih the Help commands to see which type of help is most beneficial to you.
Techniques
To access Cue cards, rou ffi rn" a"r* Otno", on rO*,ootbur.
"un "*
",r" "t,ru
When using Cue Cards, you can move backward and forward through the cards by choosing the
Babk and Neii Uuttohs. You can return to the main menu by chooiing Mend or you can close,
th" Cue Cards it any time by double-ciickrng on the Cue Cards Conlrol-menu box,

t7 Tiile #289-450
Lesson One skilt 1-5

Closing and Exiting


When you have finished working in Access, you can close your database and exit the Access pro-
gram. Closing the database file removes the copy of the file from your computer's temporary
memory.

When you exit Access, you will return to the Windows desktop.

In this skill, you will close the W&A-l.MDB database and exit Access.

Step by Step 1 Double-click: the Gontrol-menu box ffi for the


Database:W&A_1.MDB window
Notice: The database file is closed.
2 Select: he File menu
Notice: A tist of Fite commands appears. Some commands are
followed by an ellipsis (...) and one command is followed by an
arrow.
Note: Commands followed by an ellipsis open a dialog box and
require additional information to complete the command.
Commands followed by an arrow contain a submenu of additional
options.

3 Choose: Exit
Notice: You have exited the Access program.

Tips and YoucanalsopiessAlt+F4toexittheAccessprogl4m.


Techniques
''''
You qan also exit Access by double-clicking on tn" Controt-*enu box for the Access progiam
*indow. '

Title #289-450
18
Lesson One

Additional Exercises
After performing the skills in this lesson, you may want some additional practice. Below are some sugges-
tions for activities you can try on your computer, along with some questions to check your comprehension of
the material covered in the lesson.

ACTIVITIES TO TRY:
1. Start the Access program and open the W&A-1.MDB database.

2. Identify the following parts of the screen: Toolbar, Status bar, Object buttons.

3. Practice moving between object groups.

4. Practice using the Help button to access help on various features of Access.

5. Exit the Access program.

OUESTIONS:

1. What are some advantages of an electronic database over a paper database?

2. What are some examples of forms that are currently used in your workplace?

3. Explain the difference between a query and a dynaset.

Title #289-450
19
Working in Tables
Lesson Two

Introduction Lesson Objectives


The information in an Access database is stored By the end of Lesson Two, you will be able to:
in one or more tables. From these tables you ' Open a Table
can create custom entry forms, queries, and
reports.
. Move Through Records

In this lesson, you will open an existing table


. Edit Records
and practice moving through records. You will . Add Records
then edit records, add and delete records, and
close the table.
. Delete Records

Finally, you will learn to preview your table, . Close a Table


change print settings, and print the table. . Preview and Print a Table

23 Tiile #289-450
Lesson Two Before You Start

Before You Start


To practice the skills in this lesson using the CD-ROM, perform steps 1 through 4 only.

To practice the skills in this lesson without the CD-ROM, perform steps 5 through 8 only.

Step by Step To get hands-on practice using the GD-ROM:


1 Start: the SmartTrainer software
Note: For instructions on how to start the SmartTrainer software,
refer to page 4 in the Getting Started section.

3 Select: Lesson 2- Working in Tables (listed in the Available


Standard Lessons list box)

4 Choose:
Notice: The first skill in the lesson plan begins playing in the "Try
It" mode.
Note: lf you've just completed the "Show Me" segment of a skill,
you can switch to the "Try lt" mode by choosing the START
button under the words "Try lt" in the enlarged Playback Control
window.

To get hands-on practice without the CD-ROM:


5 Start: the Access program
6 Double-click: the Control-menu box ffi on the MS Access Gue
window (to close it)
Gards
7 Maximize: the Access window (if necessary)
Note: To Maximize a window, click on its Maximize Uox ffi in
the upper-right corner of the window.

8 Open: the W&A-2.MDB file (in the AST subdirectory,


located in the root directory of your hard disk)
Note: lf the subdirectory C:\AST does not exist, you will need to
install the practice files before continuing. To install the practice
files, refer to the section titled "Taking this Course Without the
CD-ROM" on page 4 of the Getting Started section.

Title #289-450
24
Lesson Two skill 2-1

Opening a Table
To work with the data in a table, you must open the table. When you first open a table, it is dis-
played in Datasheet view. Datasheet view allows you to enter, edit, and remove records from your
tables.

In this skill, you will open the Employees table.

Step by Step 1 Select: the Table object button (if necessary)


2 Click: ffi Emptoyees (to select it)
3 choose: NF-ffi|
Notice: The Employees table is opened and appears in
Datasheet view.
Note: You can also double-click on an Access object to open it.

Title #289-450
25
Lesson Two skill 2-2

Moving Through Records


You have two views available when working in tables, Datasheet view and Design view. Datasheet view
is for adding, editing,-or deleting data. Design view is for modifying the design of your table.

The information in a table is divided into fields and records. To work with this information, you will need
to move from one field to the next within a record, and from one record to the next within a table.

In this skili, you will examine the Employees table in Datasheet view and practice moving through
the records in that table.

Step by Step 1 Maximize: the Employees table window


2 Examine: the table
Notice: The table is divided into columns and rows of information.
The columns represent fields and each row contains information
about a different record.

Edil Vic!, Fgrmat flecords Y{indow Ee

MP10 Sellers iJodi Trainer i36TSamaritanDrive LosGatos :CA


MP12 lshemood :Ddvid Admin.Assistent :231 MarinwoodDr. Los6atos :CA
MP13 Brown iMon€ ' Shipping Cierk . ASS StraOy Oat S1, M! Vlqw CA

MP16 DeMarco Marthe


: Rep.
Account :234 Scot Blvd. Helena
MPIB Sanchez :Glotid AccountingCle*:z8g4Ddveskeet Cupertino
EMPIs Friai6ili Ktlhy
I cJnsultant : 3€7 Dr.
LomiAlta 59ryyy91e

EMPiI . 6indq1 Jgs-eph Admin. Assistant 4swilnul.gllgql Cp.ppbelf


EMP22 Brumfield Faymond Developet 356 El Camino Dt. Ftemont
EMP25 Flanagin Lori Ptoduct Supetvisot 456MasolAve. SanJose

Hichdrd Deyqlopg1 The table window


aMF2S Scalbqpvgh :
.
I Ave.
237 lJriv€rsity cuFertino
EMP3 Zuniqa Endy
: Vice President 1324 oceanAve. Santa Clara contains vertical and
EMP30 Michem i Sonid Developet
Developer 23 Shady Lane
Shddy Ldne
I Los Gatos
EMP3.1 . C1row Cindy
. Fep- 824 ElueberyAve
Ac€ount Elueberryl NewYork horizontal scroll bars.
EMP32 Bellatoti Miliqn Developet. .3Qf.D-q{a,zp-.811
Qpy.el-qPfl 357 DeAnza Blvd. Los GElra
r

EMp:l ii;i; 'D;ueH


AJcountins CIerh. :.9{8 Q*.S-!t-e.et
EMP35 McChesney Georsid Rep
Markeing .;4!f C94i9h
EMP37 lkagdmi Christy
i Developa !11
EMP38 Liakam Eill
: FeP.
Account
.
21

The Status bar reads The Record Number box and navigation buttons are located at
"Datasheet View." the bottom of the screen. This table contains 80 records.

Examine: the menu bar and toolbar


Notice: The menu bar now contains menus for working with
tables, and the toolbar displays buttons used to work in tables.

(Cont.)

Title #289-450
26
Lesson Two skiu 2-2

Moving Through Records


Step by Step Viewing the Record Selector:
(continued)
4 Examine: the first record in the table
Notice: The Record Selector contains an arrow, indicating that
this record is the current, or active, record. The first field entry in
this record, EMP1, is highlighted, indicating that it's selected.

Field Selector

5 Examine: the Record Number box


Notice: ttreadsffi

Navigating with the Keyboard:


6 Press: @ (the Tab key) twice
Notice: The third field entry, Craig, is selected.

7 Press: U (the Down Arrow key) four times


Notice: The last name for the second record is highlighted. An
arrow now appears in the record selector for the second record
and the Record Number box reads "Record: 5 of 80."

Navigating with the Record Number Box:


8 Highlight: the number 5 in the Record Number box
9 Type: 50
10 Press: mr*l (the Enter key)
Notice: You are moved to the 50th record, EMP67.

(Cont.)
Title #289-450
27
Lesson Two skilt 2-2

Moving Through Records

Step by Step Navigating with Buttons:


(continued)
11 Examine: the Record Navigation buttons
Previous Record Last Record

First Record Next Record

12 Click: ffi the Next Record button


Notice: The insertion point moves to the next record.

13 Click: ffi the Previous Record bufton


Notice: The insertion point moves to the previous record.

14 Click: ffi the Last Record button


Notice: The insertion point moves to the last record, record 80.

'15 Click: ffi the First Record button


Notice: The insertion point moves to the first record in the table,
record 1.

16 Click: anywhere in the table (to place the insertion point)

Tips and
Techniques Records, Go To; fo move to the f,rst, last, next, previous, or new record.
End key: To move to the last field of a record.
Home key: To move to the first cell in a record,
and press the End or Home key: To move to the beginning or end of a cell.
Click in a cell::::::::::::::::::::::::::::::::::
Ctrl+End key: To move to the last field of the last record.
Ctrl+Home key: To move to ine grst field of the first record,
Click in a cetl and niess,,Ciil+Home or Ctd+End: T0.*o+e,td fie..Hgi-nnine br,.end:of,a cell,

Title #289-450 28
Lesson Two skiil 2-3
Editing Records
Making changes tothe records in a table is easy. You can select the record and retype the entry, or
edit any part of the cell's contents.

When you deselect the record, your changes are automatically saved.

In this skill, you will edit records in the Employees table.

Step by Step '1 Double-click: in the Title field of record 6 (to select Developer)
2 Type: Trainer
Notice: ffre ffi
symbot appears in the record selector. This
indicates that record 6 is being modified, but the changes have not
been saved.

3 Click: after the word "Samaritan" in the Address field of


record 2 (to place the insertion point)

Notice: ffre ffil symbotdisappears. The change was saved.

4 Press: the space bar


Notice: ffie ffi symbol appears in the record selector.

5 Type: Ave.
6 Click: bnywhere outside record 2
Notice: The change is made and the W symOol is removed from
the record selector. Your changes are automatically saved when
you deselect the record.

7 Scroll: right until you can see the Notes field (use the
horizontal scroll bar) ffi
8 Click: in the Notes field of record 7
(it reads "Martha has been...")
I Press: tcshiiil + E] (the Zoom key)
Notice: The Zoom window appears. You can now see the entire
note.

10 Type: - - She will manage the Montana territory.


11 Choose: |W?.iii$# | (to close the Zoom window)
12 Click: anlruhere outside the record (to save the changes)

Title #289-450
29
Lesson Two skiu 2-4
Adding Records
To add new records te an existing table, you simply move to the end of the table and add the record.
Each table has a blank record at the end of the table. To move to the blank record at the end of the
table, use the New button on the toolbar.

In this skill, you will add one new record.

Step by Step Adding records to the end of a table:

1 Click: ffi tne New button (on the toolbar)


Notice: The insertion point is moved to a new record. The
Record Number box reads "Record: 81 of 81."

2 Type: EMP98

Notice: ffie ffi symbolappears in the Record Setector.

3 Press: tTa65l (to move to the Last Name field)


4 Type: Langley
5 Complete: the record as shown below
Xll*irit'Sil$$i*i*iilHiiill:fit$iiii$$6tirfi:r$'fltrrii1ill:il:ii$ri{I$fi$$lilS{iH|$iNl$!l$.\\iiilllrrl*ltl$it\:"\\$
EMPS8 i Lanqlev iMike ,Trainer

Note: When you entered the phone number and date, a format
called an "input mask" appeared. This is designed to automate
data entry. You can learn how to add an input mask in skill 9-3
of this course.

Press: tkFGl
Notice: You are moved to a new, blank record.

Tips and You can also choose Records. Dak Entry to open a data entry sheet for entering records. A data
entry sheet allows you to enter records wiihout viewing all the existing records. Afler entering
Techniques
records using the data entry shee! you can click the Show All Records button ffi to view all
records^ You can close the Data Entry table without showing all records. Access will
automatically update the table and save your changes.
If the Data Entry command is not availabte, choose Records, Allow Editing.

Choosing Show AII Records sorts the table according to your current sort specifications. Ifyou
have not set any sort specifications, the table is sorted on the Primary key.

Title #289-450
30
Lesson Two skiu 2-s
Deleting Records
Eventually, you will need to delete records. For example, if an employee leaves the company, you
might choose to remove their record from the Employees table.

The first step in deleting a record is to select it.

In this skill, you will delete one record.

Step by Step '1 Click: ffi the First Record button


2 Click: on the Record Selector of record 4 (EMP13)
Notice: The entire record is selected.

3 Press: loetl (tne Delete key)


Notice: A message appears warning you that you've iust deleted
one record.

4 Press: tEnter=l
Notice: The record is removed from the table.

Tips and You can also choose Edit, Cut to remove records. Uping the Cut command stores a copy of the
record in the computer's clipboard. Using the Delete key removes the record permanently.
Techniques
To seieei ail the:mco-l&,,in a:::ttb-1b,::,alick::on:tfte::Sbl€ct:rAll:.Rebbfdsirbufion;
in..theuppei;left,,comei.oftthe tei

Title #289-450
31
Lesson Two skill 2-6

Closing a Table
When you've finished working with a table, it's a good idea to close it. Having too many objects
open at one time can use up your computer's available memory. This can make working in Access
less efficient.

You learned that Access automatically saves records when you deselect them. Therefore, you can
close your table without saving, and any changes you've made to your records will be saved.

In this skill, you will close the table.

Step by Step 1 Choose: File, Close


Notice: The Employees table is closed and you are returned to
the Database W&A_2 window.

Tips and $Uu.;[rfi*..Aanuiu'ciic* ur*+,Conu.ffififiiu[4ffi rut.lHe$ffiibre"s t'ble ro close it.


Techniques

Title #289-450
32
In Practice: Previewins and Printins a Tuble

You can send a table to the printer by choosing the Print command or clicking on the Print button.
You can also preview your work before sending it to the printer. This allows you to determine how
your table will look on the printed page.

If you don't like the way your table looks in the Preview window, you can change the print settings in
the Print Settings dialog box. For example, you can change the page orientation of the printed table,
adjust margins, and select a printer.

In this skill, you will preview the table, change print settings, and print the table.

Step by Step Previewing the Table:


CD-ROM Users: skip step 1 below. The "Try lt mode will
@ automatically open the database file when you select this skill.
1 Open: the W&A_2.MDB database
2 Open: the Customers table
3 Click: ffi tfre Print Preview button
Notice: The Preview window displays a full-page view of the
Customers table. The table is displayed vertically on the page.
This is called Portrait orientation.

Examine: the Page Number box (at the bottom of the screen)
Notice: ttreadsffi
Click:
'ffi the Next Page button
Notice: The last five fields of this table overflow onto page 2.

Changing Page Orientation:

6 Click: ffi tne Print Setup bufton


Notice: The Print Setup dialog box appears. The Orientation

O Pottrait
O Land*cape

Click: O Land*cape (to select the Landscape option)

(Cont.)

Title #289-450
JJ
In Pructice: Previewins and Printing a Thble

Step by Step
(continued)
sChoose:l*ffi l-ilffi
S-j-j-$.$$i'iiri$$

Notice: The table is now displayed horizontally on the page. This


is referred to as Landscape orientation. Now, only one field
overflows onto page 2.

Changing Margins:

I Click: ffi tne Print Setup button


Notice: The margins at the bottom of the dialog box are set to one
inch.

10 Double-click: on 1.000 in the Left margin box


11 Type: .5
12 Press: Tab
13 Type: .5

14 Press: tEnter=l
Notice: The Customers table now fits on one page.

Printing the Table:

15 Click: ffi tne Print button


Notice: The Print dialog box appears. You can print All records, a
Selection, or selected pages. The default is to print All records.

16 Choose: L l
Notice: The table is senf to the printer.

17 Click: ffi tne Close Window bufton (to close the Preview
window)
Notice: You have returned to the table.

18 Close: the Customers table


Note: The changes you make in the Print Setup dialog box are
temporary. The original settings will be returned when you close
the table, or database.

Tips and You can also print a taUte by selecting it in the Daiabase window, and clicking the Print button.
Techniques When previewing a table, you can use the Zoom button to get a closer view of your data. You
.un tfr"n use the scroli butt to view different areas oithe page'

You can ulro ouiput a copy of the table to u Mi.roroft Word fiIe, an Excel file, o, u tnti"ro*oft

**i: rJl..ili*$ii#,. *.. lffiffif-,1ffi :,,o;. ilie preview tootuar

Title #289-450 34
Lesson Two

Additional Exercises
After performing the skills in this lesson, you may want some additional practice. Below are some sugges-
tions for activities you can try on your computer, along with some questions to check your comprehension of
the material covered in the lesson.

ACTIVITIBS TO TRY:
1. Open and preview other tables in the W&A-2.MDB database. (If using the CD-ROM, open and preview
other tables in the W&A-1.MDB database.)

2. Practice moving through the records in a table.

3. Practice adding and deleting records.

QUESTIONS:
1. Give an example of when you would use the Data Entry table to add records.

2. When does using the Record Number box make more sense than using the Navigation buttons?

- 3. How do you save changes to an editedrecord?

4. What happens when you press the Shift+F2 key combination?

5. Why would you need to adjust margins?

Title #289-450
35
Using Forms
Lesson Three

Introduction Lesson Objectives


Tables are a good way to view several records at By the end of Lesson Three, you will be able to:
a time. However, to focus on individual records, a Open and View a Form
or to present your data using a custom layout that
you design, you can use a form or report" a Edit Records

Forms provide a convenient layout for entering,


a Add Records
viewing, and changing records in a database. a Delete Records
Forms are usually linked to a table that contains a Close a Form
the data with which you want to work. When you
make changes to the records in your form, the a Use Undo
table is automatically updated. Likewise, if you
edit records in your table, any forms created from
that table are also changed.

There are three views for working with Forms:


Form view, Design view, and Datasheet view.

will work with an existing form.


In this lesson, you
You will view and edit data, add and delete
records, and close the form.
Lesson Three Before You Sturt

Before You Start


To practice the skills in this lesson using the CD-ROM, perform steps 1 through 4 on1y.

To practice the skills in this lesson without the CD-ROM, perform steps 5 through 9 only.

Step by Step To get hands-on practice using the CD-ROM:


1 Start: the SmartTrainer sofhvare
Note: For instructions on how to start the SmartTrainer software,
refer to page 4 in the Getting Started section.

2 Choose:

3 Select: Lesson 3- Using Forms (listed in the Available


Standard Lessons list box)

Choose:
Notice: The first skill in the lesson plan begins playing in the "Try
It" mode.
Note: lf you've just completed the "Show Me" segment of a skill,
you can switch to the "Try lt" mode by choosing the START button
under the words "Try lt" in the enlarged Playback Control window.

To get hands-on practice without the CD-ROM:


lf Necessary:
5 Start: the Access program
6 Close: the MS Access Cue Cards window
7 Maximize: the Access window

To Open the Practice File for this Lesson:


8 Open: the W&A-3.MDB file (in the AST subdirectory, located
in the root directory of your hard disk)
Note: lf the subdirectory C:\AST does not exist, you will need to
install the practice files before continuing. To install the practice
files, refer to the section titled "Taking this Course Without the
CD-ROM" on page 4 of the Getting Started section.

Maximize: the Database window

Titla #289-450
40
Lesson Three skia 3-1

Opening and Viewing a Form


Forms are one of the most efficient tools for entering data. With a form, you can view all of the
fields for one record at a time. Each field can be arranged in the order that best suits your data entry
needs. You enter data into a form while in Form view. To modify the design of your forms, you
must change to Design view. The Form Design window allows you access to all the controls and
objects and tools used to customize your forms.

In this skill, you will open the Employees form in Form view and then change to Design view where
you'll examine the Form Design window.

Step by Step Opening into Form View:


'1 Select: the Form object button
Notice: This database has five forms.
2 Double-click: g Emptoyees (to open the Employees form)
3 Examine: the form
Notice: This form contains allthe fields from the Employees
table. Each field has a label and a text box for entering data.
The form also contains a header and footer.

You can modify


field labels. This
field labelwas
shortened from
"Employee lD" to
'tD.'

The form window


contains vertical
and horizontal
To select a scroll bars.
record, click in the These scroll bars
Record Selector allow you to scroll
through the form
window. You
must use the
Record Navigation
buttons to move
between records.
The Status ba
reads "Form View"
Record Number box and Navigation buttons for moving through records.

Click: ffi the Last Record button


Notice: The Employee form contains the record you added to the
Employee table in the last /esson.

(Cont.)

Title #289-450
4l
Lesson Three skiu 3-1

Opening and Viewing a Form


Step by Step Examine: the View buttons on the toolbar
(continued) Notice: The Form button is depressed, p?'is:.,.
and the status bar reads, "Form View." .
There are three views to choose from: lffifi Datasheet
Design, Form, and Datasheet. Form

Switching to Design View:

6 Click: ffi ttre Design View button


Notice: A Toolbox appears. These tools are used to design and
modify forms.
Note: lf the Toolbox appears above the horizontal ruler, click and
drag the edge of the Toolbox onto the form. lf the Toolbox does
not appear, choose View, Toolbox.

7 Drag: the title bar of the Toolbox to the right side of the
screen (to move it out of the way, if necessary)
8 Examine: the Form Design window
Note: You may have to scroll down to see the footer section.

This is an expression that


the form to display the
contents of the First Name
and Last Name fields.
Each object in the Design
window has its own "control,"
which is surrounded by a thin,
gray border. Controls allow
you to work with each object
in your form individually.

Switching to Form View:


9 Click: ffi the Form View button

Title #289-450 42
Lesson Three skill 3-2

Editing Records
To make changes to a record, simply move to a field's text box and edit its contents. To save the
changes, move to a new record. The changes are automatically saved.

In this skill, you will edit the information in record 3.

Step by Step 1 Move to: record 3 (the employee named David lsherwood)
2 Press: @3times
Notice: The Title text box is highlighted.

3 Type: Account Rep.


Notice: fne ffi symbot appears in the record selector,
indicating that this record is being modified.

4 Click: in the Region text box


Notice: The status bar reads "For sales employees only." This
status bar text was added to the Region field when the form was
designed. It reminds whomever is entering data that this field is
for sales employees only.

5 Type: West
6 Click: ffi the Next record button
Notice: You are moved to the next record. Ihe ffisymbo/
disappears from the record selector, indicating that the changes
to record 3 are saved.

Tips and You can use the Page Up and Page Down keys to move from one record to another in
Techniques forms. You can also move between iecoids using the Next, PreviouS, LaSt, and First
comnands on the Records, Gc To menu.

Iitle #289-450
43
Lesson Three skia 3-3

Adding Records
Adding records in a form is very similar to adding records in a table. When you add a record to a
form, the record is automatically added to the table from which the form was created.

In this skill, you will add a new record to the Employees form'

Step by Step Click: N the New button


Notice: A blank entry form appears. The insertion point is located
in the lD field text box.

2 Type: EMP99

3 Press: Fafsl
4 Type: Morgan
5 Type: Paficia mhl
Notice: The name Patricia Morgan appears at the top of the form.
This form contains an "expression" that tells Access to add the first
and last name to the top of this form.

Gomplete the form as shown below:

Click: Nl the Next Record button


Notice: The new record is saved and you are moved to a new blank
entry form.

Tips and You can also move to a blank entry form by clicking on the Last Recoid navigation button, and
thenclickingontheNe1tRec1do1o'*in"''.o'n:o,^.-
Techniques
You can also add'recofds to a form by choosing Fonra Data Entry:

Title #289-450
44
Lesson Three skia 3-4

Deleting Records
Deleting records in a form is very simiiar to deleting records in a table. When you delete a record in
a form, the record is automatically removed from the table that was used to create the form.

In this skill, you will delete a record from the Employees form.

Step by Step 1 Move to: record 67 (the Employee named Todd Verner)
Note: A quick way to move to record 67 is to highlight the record
number in the Record Number box, type 67, and press Enter.
Notice: This is record 67 of 81.

2 Click: in the Record Selector (at the left edge of the form)
Notice: The record selector becomes a darker shade of gray,
indicating that this record is selected.

3 Press: @ (or. click the Cut button)


Notice: A message appears, warning that you've just deleted 1

record.

4 Choose: F,ffiSl
Notice: The record is removed. There are now B0 records.
Note: Peter Leavesley is now record number 67.

Tips and Sometimes recoids cannot be deleted beCause the"table has a one-to-manJ relafionship with
another table. That means that each record appeari onty on"" in "one" table, and can appear in
Techniques
"many" records in the other table. This type of relationship usually enforces,referential
integnty. This means that the "many" table can only use data ttrat exrsts in the "ouel' table, and
you cannot delete any records from the "one" table thai are being used in the "many" fable.
you witt leam more about table relationships and referential integnty in Volume Z of thii
course.

Tirle #289-450
45
Lesson Three skilt 3-5

Closing a Form
When you have finished using your form, close it. Each open Access object requires some of your
computer's memory, so it's a good idea to close objects if you're not working with them.

In this skill, you will close the Employees form.

Step by Step 1 Double-click: the Gontrol-menu box ffi tor the Employees fonn
window
Notice: The Employees form is closed and you are returned to
the Database window.

Tips and V6u


fffi ats6.blo'sb.. Eiifi
..*,i1.$$*tf..enousiuUmtCI.crosii
Techniques

Title #289-450
46
In Practice: Usins Undo

If you make in a field, you can undo that change using the Undo command.
a change to a value
Choosing Undo again will undo your undo.

To restore several changes made within one field, choose the Undo Current Field/Record button a
single time. Choosing the Undo Current Field/Record button a second time will undo all changes
made to the entire record. However, once you have moved to a new record and saved your changes,
the Undo command will not work.

In this skill, you will practice using the Undo command to restore changes made to a form.

- Step by Step 1 Open: the Customers form


2 Double-click: in the Contact Title field (to highlight "Owner")
3 Type: President
4 Click: ffi tne undo button
Notice: The contact title is restored.

5 Click: ffi tne Undo button (again)


Notice: The change is restored.

6 Double-click: "One" (in the Address field)


7 Type: Two
Note: You can undo this by clicking the Undo button.

B Press: ' @*@ (to move to the end of the Address field)
I Type: light Street

10 Click: ffi tne Undo button


Notice: The words "light Street" are removed but the word "Two" is
not changed. Using Undo only reverses your most recent change.

11 Click: ffi the Undo Current Field/Record button


Notice: The entire field is restored. lt now reads "One Beacon."

12 Click: ffi tne Undo Cunent Field/Record button (again)


Notice: Clicking this button a second time has restored the entire
record. The contact title is restored to "Owner."
13 Close: the Customer form

Tips and $i.in, tableS.....' You lan.,.alSo, uSE..the .S3baFe,,lk€y tcilundQ


changes.
Techniques
;;;;";t After you move to u n"* r""ord, your changes are saved una.un ro* be undone'

Title #289-450
47
Lesson Three

Additional Exercises
After performing the skills in this lesson, you may want some additional practice. Below are some sugges-
tions for activities you can try on your computer, along with some questions to check your comprehension of
the material covered in the lesson"

ACTIVITIES TO TRY:
1. Open the Category form and move between records.
2. Examine the Form Design window.
3 View the Category Form in Datasheet view.
4. Close the Category form.

QUESTIONS:
1. Explain the difference between the Undo command and the Undo Cunent Field/Record commands.
-

2. What is the name used to describe the elements in the Form Design window that allow you to work with
individual objects in your form?

3. Name two ways to move between records in Form view.

Title #289-450 48
Finding and Sorting Data
Lesson Four

Introduction Lesson Objectives


Suppose you need to get in touch with an employee By the end of Lesson Four, you will be able to:
at home. That person is the only employee who . Find Records
can answer an important technical question. You
know the first name, but can't remember the last
. Sort Records
name or employee ID number. You can quickly . Apply a Filter
locate this information using the Find command.

Sometimes organizing your data alphabetically


can help you to locate information. With Access,
you can group records in ascending ordescending
order using the Sort command.

In this lesson, you will learn to find and sort the


records in your database.

51 Title #289-450
Lesson Four Before You Start

Before You Start


To practice the skills in this lesson using the CD-ROM, perform steps 1 through 4 only.

To practice the skills in this lesson without the CD-ROM, perform steps 5 through 9 only.

Step by Step To get hands-on practice using the CD-ROM:


1 Start: the SmartTrainer software
Note: For instructions on how to start the SmartTrainer software,
refer to page 4 in the Getting Started section.

2 choose: lffirliruii,H*ffia*i
l,i*Hf,slf .i*i\Ni'!iilii'''''i'liiiiili'iritr

3 Select: Lesson 4- Finding and Sorting Data (listed in the


Available Standard Lessons list box)

4 Choose:
Notice: The first skill in the lesson plan begins playing in the "Try
It" mode.
Note: lf you've just completed the "Show Me" segment of a skill,
you can switch to the "Try lt" mode by choosing the START button
under the words "Try lt" in the enlarged Playback Control window.

To get hands-on practice without the CD-ROM:


lf Necessary:
5 Start: the Access program
6 Close: the MS Access Cue Cards window
7 Maximize: the Access window

To Open the Practice File for this Lesson:


8 Open: the W&A-4.MDB file (in the AST subdirectory, located
in the root directory of your hard disk)
Note: lf the subdirectory C:\AST does not exist, you will need to
install the practice files before continuing. To install the practice
files, refer to the section titled "Taking this Course Without the
CD-ROM" on page 4 of the Getting Started section.

I Maximize: the Database window

Tirle #289-450
52
Lesson Foar skiu 4-1

Finding Records
You can use the Find command to quickly locate records in a table or in a form. You can tell Access
to look for an exact'value, such as a name, or you can use a wildcard character to search for parts of
values. A wildcard character is a placeholder that represents anything and everything. For example,
you can use "L*s" to find all records that start with the letter "L" and are followed by anything. You
can use "EMP9#" to look for alltwo digit employee numbers that begin with nine. See the Tip and
Techniques at the end of this skill for more information on wildcard characters.

In this skill, you will find records in a table and in a form.

Step by Step 1 Open: the Employees table


2 Click: ffi tne Find button
Notice: The Find in field dialog box appears.

3 Type: Carmen

4 Click: O AI Fietds (to select it)


Notice: The dialog box title bar now reads "Find."

5 Choose: l- il
Notice: The name, Carmen, is highlighted in record number 30.
I are not included in the "Try lt" audio
@ CD-ROM Users: steps 6, 7, &
coach.

6 Choose: l$l, 1

7 Click: once in the horizontal scroll bar (to display the Home
Phone field)
Notice: Carmen Washington works in Product Development and
her phone number is (408)446-2374.

8 Click: ffi tfre Find button


I Choose: M,ffi
Notice: Access has reached the last record and hasn't found
another occurrence of "Carmen."
l.-
10 Choose: ls.TlHffiN
(to end the search)

11 Choose: lilrniittiii$ffiN
tdi$tsrid$dsiw
12 Close: the Employees table
13 Select: the
- Form object button
14 Open: the Employees form

(Cont.)
Title #289-450
53
Lesson Four skiu 4-1

Finding Records
Step by Step 15 Click: in the Date Hired text box
(continued) '16 Click: ffi tne Find button
17 Type: 2H94
Note: the "*" wildcard character tells Access to find any date
within the month of February, '1994.

18 Click: O Currsnt Field (to select it)


Note: To see more of the form, move the dialog box by dragging its
title bar.

19 Choose: ffiii#i--B$if,
Notice: Access has found Karen Chow, hired on 2/7/94.

20 Choose: l...W#SsR
Notice: Access has found Mark Stevens, hired on 2/15/94.

21 Choose: ti. #ffi.,


Notice: Access has reached the last record and hasn't found any
other matching records.
ffi
22 Choose: liL+riltiiiiiiiitrl
I
23 Choose: lil.i. ,..1'|,i,ii,i

Tips and In step 17, if you ised2ll#194, you would have only searched for days with 2 digits. You
would not have found 217/94. Likewise, searching for 2/#194 would not have found 2115194.
Techniques
.,::,.. AClq $,:{i$ds: * ,':'.:
L*ng Ling #th 5th
Levering 8th
Leka Travel and Trading ith 128th
Paul[lao] Pauli (but not Paula or Paulo)
Sm?th Smith
SmYth

You Can also tell ecces$..to.s h..fi0nr.Y,ouf iasertion.pojnt.,pttsitica::Up tlrough r,ecofds,,,This


can be done by choosing the Up option in the Find in Field dialog box. It takes Access longer
to search all fields than it does to search the current field.

Title #289-450 54
Lesson Four skiu 4-2

Sorting Records
As your database grows, you will need to control the order and type of data that you view on screen.
One way to do this is by sorting data. You can sort data in both tables and forms. When you use the
Sort buttons, Access sorts your database alphanumerically in either ascending or descending order.

In this skill, you will sort the Employees form by last name. Then, you will sort the Employees form
by date hired, in descending order'

Step by SteP 1 Click: in the Last Name field text box


2 Click: W the Sort Ascending button
3 Press: the Page Down key several times
Notice: The records are sorted alphabetically by last name.

4 Click: ffi the Datasheet View button


5 Click: anywhere in the Date Hired field
Note: You will need to scroll to the right.

6 Click: ffi tne Sort Descending button


Notice: The table is sorted by hire date, listing the most recent
hires first.

7 Close: ihe Employees form

Tips and ,ordef,.of.yb ;data' Eabh.tinre.y.ou.,iffi..h'.,tab,.tre.,ai:,fo.thb


records are sorted according to the primary key field.
Techniques
To sort on more than one field, or to specify criteria that asks for specific records, you must use
the Filter window. as described in "Applying a Filter" on the next page.

Title #289-450
55
In Pructice: A ins s Filter
When sorting data, you can order records by a single field, or by a combination of fields. For
example, the telephone book is sorted by last name, and then by first name. In Access, you can sort
your records by multiple fields using the Filter window.

The Filter window also allows you to specify criteria that tell Access which records you want to
view. For example, you can set criteria that will only display sales consultants. Once you have
created a filter, you can save it as a query.

In this skill, you will sort by multiple fields. Then, you will create a filter that displays only consult-
ants. Finally, you will save this filter as a query called "Sales Consultants."

Step by Step 1 Select: the Table object button


2 Open: the Employees table
3 Click: anlruhere in the Title field

4 Click: ffi tne Sort Ascending button


Notice: The table is sorted alphabetically by title

5 Click: ffi tne Edit Filter/Sort button


Notice: The Filter window is opened.

6 Examine: the Filter window


Notice: These settings tellAccess to sort by the Title field in
Ascending order.

Field list

Filter grid

7 Drag: the FirstName field from the Field list to the Field
cell in the second column of the Fifter grid
B Click: in the Sort cell of the FirstName column
9 Click: ffi the drop-down arrow
10 Select: Ascending

11 Click: ffi tne Apply Fitter/Sort button


Notice: The table is sorted by title, and within title by first name,

(Cont.)

Title #289-450 56
In Practice: Annlvins a Filter

Step by Step 12 Click: ffi tne Edit Filter/Sort button


(continued)
13 Click: in the Criteria cell of the Title column
14 Type: Consultiant IEnter=l
Notice: Quotation marks appear around the word Consultant.

15 Click: ffi tne Apply Filter/Sort button


Notice: Only consultants are listed.

16 Click: ffi ttre Print button

17 Choose: l.ffi.$*s-N
Notice: Your list of consultants is being printed.

18 Click: ffi tne Edit Filter/Sort button

19 Click: ffi tne Save button


Notice: The Save As Query dialog box appears.

20 Type: Sates Consultants tEnGr.-'l

21 Click: ffi tne Apply Filter/Sort button


'Notice: You are returned to the table. It is still sorted.

22 Choose: ffi tne Show All Records button


Notice: All 80 records are shown.

23 Close: the EmPloYees table


24 Select: the Query object button
Notice: The query "sales Consultants" is added to the list. This
query requests a list of consultants found in the Employees table.
lf consultants are added or removed from the Employees table,
this query will produce a current list of consultants.

Tips and ilg{s,,


,T;'i[Aicn.rot.ietoidi.ihat.ubet.fiuiUpta,.ifii.erib;..su 1,av,.G.o .,Sr,iAccti..Manag$rst
Techniques you would rype: In(Consuliants, Sr. Acct. llianager$ in the Criteria cell for the Title field,

ff1]]'.T"ll, ,, ,,*,,* to using the Filter window, r.,,;'"r"- on", gr.u,", flexibilitv
eueries are saved as database objects. Filters, on the other hand, need to be set up manually
each time you use them.

Title #289-450
57
Lesson Four

Additional Exercises
After performing the skills in this lesson, you may want some additional practice. Below are some sugges-
tions for activities you can try on your computer, along with some questions to check your comprehension of
the material covered in the lesson.

ACTIVITIES TO TRY:
l. Open the Customers form. Find the customer ID "SFIT." What is the name of the contact for this
company?

2. Search for all the records with a (408) area code.

3. Change to Datasheet view and sort the form in ascending order by contact title.

4. Create a filter that sorts the datasheet by contact title, and then within contact title, by company name.

OUESTIONS:
1. Name some situations that would require a descending sort vs. an ascending sort.

2. What are some situations in your business that would require sorting by multiple fields?

3. Give one reason why you would save a filter as a query.

Title #289-450
58
Llsing Queries
Lesson Five

Introduction Lesson Objectives


A query is a question that you ask about the data in By the end of Lesson Five, you will be able to:
your database, for example, "Which employees in this a Change Criteria
table work in the Sales Department?"
a Arrange Fields
The question is asked by speciffing criteria in the
Query Design window. The query brings together the a Save and Close a Query
records that meet the criteria in a set of records called
o Delete Objects
a "dynaset""
a Print a Query
Keep in mind that a query is a question about data, not
the data that answers that question. The question is
asked to the current data in the table(s). Therefore,
each time you run the query, you get up-to-date
information.

There are several different types of queries you can


create in Access. The most common type of query is
called a Select Query.

In this lesson, you will learn about select queries by


viewing and modifying an existing query. In Volume
2 of this course, you will design new queries, and in
Volume 4 you will explore some of the advanced
features ofqueries.

6l Title #289-450
Lesson Five Before You Start

Before You Start


To practice the skills in this lesson using the CD-ROM, perform steps 1 through 4 only'

To practice the skills in this lesson without the CD-ROM, perform steps 5 through 9 only.

Step by Step To get hands-on practice using the CD-ROM:


1 Start: the SmartTrainer software
Note: For instructions on how to start the SmartTrainer software,
refer to page 4 in the Getting Started section.

2 Choose:

3 Select: Lesson 5- Using Queries (listed in the Available


Standard Lessons list box)

Choose:
Notice: The first skill in the lesson plan begins playing in the "Try
It" mode.
Note: lf you've just completed the "Show Me" segment of a skill,
'you can switch to the "Try lt" mode by choosing the START button
under the words "Try lt" in the enlarged Playback Controlwindow'

To get hands-on practice without the CD-ROM:


lf Necessary:
5 Start: the Access program
6 Close: the MS Access Cue Cards window
7 Maximize: the Access window

To Open the Practice File for this Lesson:


8 Open: the W&A-S.MDB file (in the AST subdirectory, located
in the root directory of your hard disk)
Note: lf the subdirectory C:\AST does not exist, you will need to
install the practice files before continuing. To install the practice
files, refer to the section titled "Taking this Course Without the
CD-ROM" on page 4 of the Getting Started section.

Maximize: the Database window

Tiile #289-450 62
Lesson Five skia 5-r
Changing Criteria
Your tables and forms act like master lists of information. They are usually a comprehensive
collection of information about one subject, such as a customer list, employee list, orders, products,
and so on.

Queries allow you to extract information from these lists, without affecting the integrity of the
original data. Queries act as filters that collect records meeting specified criteria. The extracted
records are stored in a table called a "dynaset." The query produces an up-to-date dynaset each time
you run the query, so your dynasets always contain current information. There are several types of
queries, but the most common type of query is called a Select Query.

In this skill, you will view the dynasets produced by two select queries and modify the criteria in
this query so that it asks for records with a "Region that equals West."

Step by Step Note: Steps 1 through 3 are not included in Try lt.
Viewing the Source Table:
1 Open: the Employees table
Notice: This table contains B0 records with 10 fields.

2 Close: the Employees table

Viewing Dynasets:
3 Select: {he Query object button
Notice: There are currently five queries in this database. When
you open a query, it automatically produces a dynaset based on
the table or form used to create the query.

4 Open: the Sales Team query


Notice: This dynaset was also created from the Employees table.
It disptays five of the ten original fields, and only shows records of
sales employees.

ldentifying Elements of the Query Design Window:


Note: To view a query, you must change to Design view.

5 Click: ffi tfre Design View button


Notice: The Query Design window is displayed. This window is
divided into two panes. The upper pane lists the tables used to
create this query. The lower pane contains the Query-by-example
PBE) grid. The QBE grid determines which information will
appear in the dynaset. Dynasets are shown in Datasheet view'

(Cont.)
Titls #289-450
63
Lesson Five skilt 5-1

Changing Criteria
Step by Step Examine: the Query Design window
(continued) Notice: The Query Design window contains menu commands and
buttons for working with queries. The QBE grid is divided into
rows and columns. The columns contain the fields that you
choose to include in the dynaset. The rows allow you to sort the
dynaset, show or hide each field, and specify criteria.

Thisqueryusedthe
Employees table
as its source of
data

Field list

OBE Grid

An X in the Show box


tells Access to display
this field in the dynaset This query sorts the
dynaset alphabetically,
in ascending order, by
Region

Click: the right scroll arow ffi for the QBE grid
Notice: This query also includes the Title field. The Show box is
deselected. This field will not appear in the dynaset.
Note: Although the Title field will not display in the dynaset, it is
being used to determine which records will be included. This is
called "specifying criteria on a hidden field."

Choose: t (to close the Zoom dialog box)

(Cont.)

Title #289-450
64
Lesson Five skill s-I
Changing Criteria
Step by SteP Ghanging Griteria:
(continued)
I Click: in the Criteria cell of the Region field
10 Type: West Gnter*.ll
Notice: Access automatically added quotation marks around the
criterion. This query now asks Access to collect all the records in
the Employees table with a Title that equals "Account Rep." 9I
"Sr. Acct. Manager," ans! with a Region that equals "West."

11 Click: ffi ttre Run button


Notice: The query is run and a new dynaset shows only those
records that match the new criteria.

Tips and #Uil il4An{ ffii* *+ ffi,:uat$tl;i utffin,ito *o tn" q""y.,


Techniques

Title #289-450
65
Lesson Five skia 5-2

Arranging Fields
You can use the QBE grid to add, remove, or hide fields in a dynaset. You can also arrange the
order in which fields appear in the dynaset.

In this skill, you will hide the FirstName field, so that it does not appear in the dynaset. You will
then move the Extension field so that it appears next to the LastName field.

Step by Step Click: ffi ttre Design View button

2 Click: in FirstName field Show box E (to deselect it)


3 Position: the mouse pointer in the column selector of the
Extension column column selector

Notice: The mouse pointer changes to a down-pointing arrow.

Click: in the column selector of the Extension column


Notice: The entire column is selected. Now that the column is
selected, you can move the column by dragging its column
selector.

Position: the mouse pointer in the column selector of the


Extension column
Click & drag: to the left without releasing the mouse button
Notice: A black border shows you where the column will be
positioned when you release the mouse button.

Position: the black border between the LastName and


FirstName columns, and release the mouse button
Notice: The Extension column is moved.

Click: ffi tne Run button


Notice: The FirstName field is hidden, and the Extension field
appears before the Region field.

.
Tips and d.:bv''r6 iuf. pmtfielas (fiom left to right)r Accbss borts:,by.,the1.fitst
field tliii inCludes a sort specification. ,It then sorts within that field by the next field that
Techniques qontainsaso't:'ip.iifi*ution,andsoon'.......'....'..'''

Tiile #289-450
66
Lesson Five skia 5-3

Saving and Closing a Query


After modiffing a query, you can save your changes by choosing File, Save, or by clicking the Save
button. Saving youi changes will replace the existing query.

If you want to save your modified query under a new name, without replacing the original QuerY,
you must use the Save Query As command.

In this skill, you will save the modified query as a new object by the name of "Western Sales
Team."

Step by Step 1 Choose: File, Save Query As...


Notice: The Save As dialog box appears.

2 Type: Western Sales Team tEnter=l


Notice: The title bar now reads "Western Sales Team."

3 Close: the Western Sales Team query


Notice: The new query was added to the list of query obiects.
The Sales Team query is also included. lt has not been
changed.

Tirle #289-450
67
Lesson Five skill s-4

Deleting Objects
Deleting objects, such as tables, queries, forms, and reports is easy. You simply select the object in
the database window and press the Delete key.

In this skill, you will delete two query objects.

Step by Step 1 Select: the Western Sales Team query


2 Press: @
Notice: A message asks you if you want to delete this query.

3 Press: tEnE=]
Notice: The Western Sales Team query is removed from the list
of query objects.

4 Select: the Sales Consultants query


Note: lf the Sales Consultants query does not exist, then skip
steps 4 through 6.

5 Press: @
6 Press: IEilerA

Tips and V deXete]igue*s;aUts;,iifoffi ;,. d,rcpcs|ithesameway,


Techniques

Title #289-450 68
Lesson Five skia 5-5

Printing a Query
You can print queries, tables, forms, or reports from the Database window.

In this skill, you will print the Sales Team query.

Step by Step 1 Select: the Sales Team query (if necessary)

2 Click: ffi the Print button


Notice: The Print dialog box appears.

3 Choose: l.s,

Notice: The Sales Team queryis senf to the printer.

69
Lesson Five

Additional Bxercises
After performing the skills in this lesson, you may want some additional practice. Below are some sugges-
tions for activities you can'try on your computer, along with some questions to check your comprehension of
the material covered in the lesson.

ACTIVITIES TO TRY:
1. Open a query and identify the elements of the Query Design window.

2. Create and save a query that shows only employees who live in Los Gatos. Name the query "Los Gatos
Employees."

3. Practice modifying the criteria in the Los Gatos Employees query to display related groups of data.
Include a sort on multiple fields.

4. Rearrange the fields in the Employee List query'

5. Delete the Los Gatos Employees query object.

OUESTIONS:

1. What is the name of the area where you specify fields and criteria for a query?

2. What determines the sort order in a query sorted by multiple fields?

3. What happens to a field in a query when you deselect its Show box?

Titl€ *289-450
70
Viewing and Printing Reports
Lesson Six

Introduction Lesson Objectives


Tables, forms, and queries are effective ways to By the end of Lesson Six, you will be able to:
view and analyze data on your computer. But, a Preview a Report
when it comes to presenting data, you will want to
create a report. With reports, you can group
a Identiff Elements of the Report
information into categories, present summary Design Window
information, and show totals and grand totals a Print a Report
across an entire set ofrecords.

A report is much like a form, except that it gives


you greater control over how data appears when
printed.

This lesson will introduce you to reports. You


will preview and print a report, and examine the
underlying controls of a report in Design view.

In Volume 3 of this course, you will design,


modi$, and enhance reports.

73 Tiile #289-450
Lesson Six Before You Stsrt

Before You Start


To practice the skills in this lesson using the CD-ROM, perform steps 1 through 4 only.

To practice the skills in this lesson without the CD-ROM, perform steps 5 through 9 only.

Step by Step To get hands-on practice using the CD-ROM:


1 Start: the SmartTrainer software
Note: For instructions on how to start the SmartTrainer software,
refer to page 4 in the Getting Started section.

2 Choose:

3 Select: Lesson 6- Viewing and Printing Reports (listed in


the Available Standard Lessons list box)

Choose:
Notice: The first skill in the lesson plan begins playing in the "Try
It" mode.
Note: lf you've just completed the "Show Me" segment of a skill,
you can switch to the "Try lt" mode by choosing the START button
under the words "Try lt" in the enlarged Playback Control window.

To get hands-on practice without the CD-ROM:


lf Necessary:
5 Start: the Access program
6 Close: the MS Access Cue Gards window
7 Maximize: the Access window

To Open the Practice File for this Lesson:


I Open: the W&A_6.MDB file (in the AST subdirectory, located
in the root directory of your hard disk)
Note: lf the subdirectory C:\AST does not exist, you will need to
installthe practice files before continuing. To installthe practice
files, refer to the section titled "Taking this Course Without the
CD-ROM" on page 4 of the Getting Started section.

Maximize: the Database window

Title #289-450
74
Lesson Six skill 6-1
Previewing a Report
Although you can print data directly from tables, dynasets and forms, reports give you greater
control over how yotrr data is printed. With the power and control of a report, you can produce
presentation-quality reports with minimum effort.

For example, reports allow you to:


. Specify which fields you want printed
. Sort records

' GrouP records

. Calculate summary information


. Control layout and appearance

The items on a report (or form) that display or print data are called "controls." With a control, you
can display data from a fie1d, the results of a calculation, titles, graphs, and pictures. You can even
display another graph or rePort.

Reports

+rcEl
M

ffit #

(Cont.)
Ti{e #289-450
75
Lesson Six skiu 6-1

Previewing Reports
Step by Step Previewing a Report:
(continued) Note: Reports are used to output your data to paper. Access
provides an easy-to-use preview feature that can be accessed
from the database window. After previewing your report, you can
either make necessary changes or send it to the printer.

1 Select: the Report object button


Notice: There are two reports in this database.

2 Select: the Customer Phone List report


3 choose: ffi=---$ffi
Notice: The Preview window is open and the title bar reads
'Report: Customer Phone List." When the mouse pointer is
positioned in the Preview window, it appears as a magnifying
glass.

4 Click: ffi the Next Page button (to move to page 2)

5 Click: ffi tne Zoom button


Notice: You are shown a full-page view of the report.
6 Click: anywhere in the Preview window
Notice: You are shown a close-up view of the report.
Note: The Zoom button and magnifying glass will toggle you back
and forth between full-page and close-up views.

Tips and
Techniques diililild ffi, $e,r ..sefifi u*t*u *r"t* i{tr'e n"p"tt *indo*, on.*'[ e..# $u*p,,uiai[g
box, which is where you specify your printer type, the page dimensions, page orientation, and

While in the Access window. t;; ; output a copy of your ,.fn ,o Microsoft Excel, Mi-

,roroi Wora, o, ruficrosoft fufuit uring the following buttons on the toolbart
milffi

Title #289-450 76
Lesson Six skiu 6-2

Identifying Elements of the Report Design Window


To modify the design or layout of a report, you must switch to Design view. The Report Design
window is divided iirto five or more sections. There are sections for the Report Header and Footer
which appear at the top and bottom of the report, sections for the Page Header and Footer which
appear at the top and bottom of every page, and a section for the detailed information in the report.
Each element that will appear in the report has its own "control." These controls allow you to
select, modify, move, and delete the objects in a report.

In this skill, you will view the Report Design window.

Step by Step Click: ffi tfre Close Window button


Notice: The Preview window is closed.

Choose:
Notice: The status bar reads "Design View" and the Report
Design window appears.

Examine: the Report Design window


Note: lf the Toolbox is obstructing your view of the Report
Design window, move the Toolbox by dragging its title bar.

Menus and buttons


for working with
reports

Controls used for


working with
objects in Design
view

Each section has its


own set of rulers
which can be
turned on and off
using the View,
Ruler command.

Tools used to add, create and modify objects in a report


This Toolbox can be opened or closed using the View, Toolbox command.

Title #289-450
77
Lesson Six skilt 6-3
Printing a Report
Although you can print your tables, forms, and dynasets, the preferred output for data is a report.
Printing reports in Access is simple.

In this skill; you will print the Customer Phone List report.

Step by Step 1 Click: ffi tne Print Preview button

2 Click: ffi tfre Print button


Notice: The Print dialog box appears. The Print Range option is
set to print All

Choose: lHffiffiffiUNN\SNl
ry
Notice: The report is printed.

Click: ffi tne Cbse Window button


(to close the Print Preview window)
Close: the Report window

Tips and ,+ i iair .ffi$i$Eisfffie'$i#**1ffi1ffir


Techniques
Chposing SamBle:Preview only displays a sample of your fields and records- To see your
as''itwiuappealw'h#prinled;youmustusePrintPreyiew..

Tifle #289-450
l8
Lesson Six

Additional Exercises
After performing the skills in this lesson, you may want some additional practice, Below are some sugges-
tions for activities you can try on your computer, along with some questions to check your comprehension of
the material covered in the lesson.

ACTIVITIES TO TRY:
1. Examine the Mailing Labels report in Design view.

2. Print a copy of the Customer Phone List report.

QUESTIONS:
i. List three types of reports that you can create using Access.

2. What are some examples of reports that you might need to produce?

3. Why would you preview a report before printing it?

Titl€ #289-450
79
rl-,,rnderstanding Database Design
Lesson Seven

Introduction Lesson Objectives


In Volume 1 of this course, you learned about the By the end of Lesson Seven, you will be able to:
objects that make up an Access database. You . Create a New Database File
worked with tables, forms, queries, and reports.
. Import Tables from Another Database
Although you might never have to create a new
database from scratch, y ouw i I I work with and add
new objects, such as tables, forms, queries, and
reports, to an existing database' Understanding
the basic principles of database design will make
leaming to work in Access much easier. It will
also help you to preserve the integrity of the
database with which you're working.

In this lesson, you will be introduced to the


principles of database design.

83 Title *289-450
Lesson Seven Before You Sturt

Before You Start


To practice the skills,in this lesson using the CD-ROM, perform steps I through 4 only.

To practice the skills in this lesson without the CD-ROM, perform steps 5 through 7 only.

Step by Step To get hands-on practice using the CD-ROM:


1 Start: the SmartTrainer software
Note: For instructions on how to start the SmartTrainer software,
refer to page 4 in the Getting Started section.

2 Choose:

3 Select: Lesson 7- Understanding Database Design


(listed in the Available Standard Lessons list box)

Choose:
Notice: The first skill in the lesson plan begins playing in the "Try
It" mode.
Note: lf you've just completed the "Show Me" segment of a skill,
you can switch to the "Try lt" mode by choosing the START button
under the words "Try lt" in the enlarged Playback Control window.

To get hands-on practice without the CD-ROM:


lf Necessary:
5 Start: the Access program
6 Close: the MS Access Cue Cards window
7 Maximize: the Access window
Note: There is no practice file to open for this lesson.

Title #289-450
84
Lesson Seven skiu 7-1

Creating a New Database File


When you design database, first break down the information you want to keep as separate subj ects, and
a
thentell Accesshowthe subiects are relatedto each other, so thatAccess canbring the rightdatatogether
when you need it.

There are a few steps that you should follow when planning your database.

1. Determine the Purpose of Your Database

Decide which information your database will store. Will it contain only sales information, or
will it include information across every department of your company?

2. Determine the Tables You Need

Once you know the purpose of your database, divide it into separate subjects, such as
Employees, Orders, Products, Customers, and so on. Each subj ect will be a table in the database.
Take into consideration how the data is going to be entered and/or updated. Is someone going
to be entering data from a paper form, while on the phone, etc.? This may determine the order
of your fields.

3. Determine the Fields You Need

Talk to the people who will be using the database. Be sure to include only fields that relate to
each other. Avoid adding unnegessary fields. It's also important to avoid having too many fields
in one table. Large tables can usually be broken down into smaller, related subcategories.

4. Determine the RelationshiPs

Look at each proposed table before you create the database, and decide how the data in one table
relates to the data in another table. Add fields to tables or create new tables to clarify the
relationships, as necessary.

5. Refine Your Design

Enter some sample information into your tables to see if you get the results you want. Make
adjustments to the design as needed. Think of your initial design as a rough draft that you can
refine later. Experiment with sample data and prototype reports and queries. The best way to
find errors in a database design is to begin using it. It's easy to change the design ofyour database
as you're creating it. However it becomes very difficult to make changes to tables after they're
filled with data, you've created your forms, queries, and reports, and users are on-line using the
database.

(Cont.)
Tiile #289-450
85
Lesson Seven skill 7-1
Creating a New Database File
(Continued)
Common Design Problems:

There are several common problems that occur when designing a database. If you come across
one or more of the following warning signs, you might want to reevaluate your database design.

. You have one database with a large number of fields that don't relate to the same
subject.
. You have many fields in a table that are left blank. This usually means that the fields
belong in another table.
. You have alarge number of tables that contain the same fields. Try consolidating all
information relating to a single subject.

Note: Designing a large database is a complex project. For more information on database design, refer
to your Access fJser's Guide. There are also several books available on database design principles. It's
a good idea to talk to someone who has designed relational databases, and to talk to the people who will
eventually use your database.

(Cont.)

Tirle #289-450
86
Lesson Seven skia 7-1

Creating a New Database File


Step by Step Creating the New Database:
(continued) Note: After planning your database, you are ready to begin a
new database file.

Click: ffi tne New Database button


Notice: The New Database dialog box appears. The file name
dbl.mdb is highlighted in the File Name text box.
Note: File names can be no longer than B characters and can't
contain spaces. Access automatically adds the .MDB extension.

2 Type: mydb
3 Double-click: 6' c:\ (in the Directories list box)

4 Double-click: m a*t (in the Directories list box)


Notice: The current directory is now C:IAST

Choose:
Notice: Access opens a new database window. The title bar
reads "Database: MYDB." There are currently no obiects in this
database.
Note: When you create a database, Access automatically creates
a second file with the same name, but with an .LDB extension. This
file is used by Access to store locking information. Although you
don't need to keep the .LDB file when you back up or copy a
database, you should never delete it while the database is open in
a multi-user environment.

Title #289-450
87
Lesson Seven skiu 7-2
Importing Tables from Another Database
When creating a new database, you may want to import a table (or other object) that exists in
another database. This can avoid hours of unnecessary data entry.

In this skill, you will import a copy of the Employees table from the W&A-7.MDB database file.

Step by Step 1 Click: ffi the lmport button


Notice: The lmport dialog box appears. The Microsoft Access
Data Source is selected.

2 Choose: N:ffiFj,ffifl
Notice: The Select MicrosoftAccess Database dialog box appears.
The File Name list shows all the Access files in the current directory.
Note: Make sure your current directory is C:\AST.
3 Double-click: the W&A 7.MDB file
Notice: fne mport Objects diatog box appears. The object type is
set to Tables and the Structure and Data option is selected.

4 Select: Employees (from the list of objects)

5 Choose: ffi$
Notice: A message appears telling you that the Employees table
was successfully imported.

6 choose: |$,{ffi'ffi,ffil

T Choose: ffiW*i$ (to close the lmport objects dialog box)


Notice: The Employees table appears in the database window.

Tips and
Techniques
ln addition to Access objects;.,y6; oan i rt o$ebts ,from. sereral..otbbr,applications, such,,as
Microsoft Excel, Lotus l-2-3. and other spreadsheet applications.

You can also export Acebs$:::objects to oth ::ACcesS,dat*bases;,af,d,.to bther applicttions. ,,

Title #289-450
88
Lesson Seven

Additional Exercises
After performing the skills in this lesson, you may want some additional practice. Below are some sugges-
tions for activities you can try on your computer, along with some questions to check your comprehension of
the material covered in the lesson.

ACTIVITIES TO TRY:
1. Create a new database file and import several objects from the W&A-7.MDB database.

2. Export a table from your new database file to the MYDB.MDB database.

OUESTIONS:
1. Name some things you should consider before beginning your database design.

2. What are some signs that you should reevaluate your database design?

Title #289-450
89
Creating a Table
Lesson Eight

Introduction Lesson Objectives


Now that you have an understanding ofthe objects By the end of Lesson Eight, you will be able to:
that make up an Access database, it's time to begin . Add, Describe, and Delete Fields
creating objects of your own.
. Save the Table
The foundation for your database is the table or
collection of tables that contains your data" So, in
. Enter Data
this lesson, you will learn to create a new table. . Change Field Column Width
First, you will create a new table that contains . IJse the Table Wizard
information about the classes offered by Walker
& Associates. You will then create a second table
using the Table Wizard. The Table Wizard walks
you step-by-step through the creation of your
table, and allows you to customize your table
along the way.

93 Title #289-450
Lesson Eight Before Yoa Start

Before You Start


To practice the skills in this lesson using the CD-ROM, perform steps 1 through 4 only.

To practice the skills in this lesson without the CD-ROM, perform steps 5 through 9 only.

Step by Step To get hands-on practice using the CD-ROM:


1 Start: the SmartTrainer software
Note: For instructions on how to start the SmartTrainer software,
refer to page 4 in the Getting Started section.

2 Choose:

3 Select: Lesson 8- Creating a Table (listed in the Available


Standard Lessons list box)

4 Choose:
Notice: The first skill in the lesson plan begins playing in the "Try
It" mode.
Note: lf you've just completed the "Show Me" segment of a skill,
you can switch to the "Try lt" mode by choosing the START button
under the words "Try lt" in the enlarged Playback Control window.

To get hands-on practice without the GD-ROM:


lf Necessary:
5 Start: the Access program
6 Close: the MS Access Cue Cards window
7 Maximize: the Access window

To Open the Practice File for this Lesson:


8 Open: the W&A-8.MDB file (in the AST subdirectory, located
in the root directory of your hard disk)
Note: lf the subdirectory C:\AST does not exist, you will need to
install the practice files before continuing. To install the practice
files, refer to the section titled "Taking this Course Without the
CD-ROM" on page 4 of the Getting Started section.

Maximize: the Database window

Title #289-450
94
Creating a New Table
To create a new table, you must either open a new Table Design window, or use the Table Wizard.

The Table Design window lets you add, remove, modify, and customize the fields in your table. To
open a new Table Design window, use the New Table button.

In this skill, you will begin a new table, add fields to your new table, and delete one field.

Step by Step Creating a New Table:


1 Select: the Table object button (if necessary)

Choose: I.liirililrirfi
Lllll;;iliilt
i$iliillfl

Notice: The New Table dialog box appears. You have the
choice of creating a new table with, or without, the Table Wizard.
-

Click:
l.lew Table

Notice: A new Table Design window appears. The title bar


reads "Table: Tablel." The Status bar reads "Design View. FO =
panes. F1 = Help."
,Switch
Examine: the Table Design window
Upper Pane

Field Selector'

TheTable Designwindow
is divided into two Panes.
The upper pane contains
the grid used to add fields.
The lower pane disPlaYs
the Field properties of the
active field. There are
currently no fields, so the
Field Properties area is
blank.
The description in the
lower pane will change
depending on the location
of the insertion point.

Lower Pa (Cont.)
Tille #289-450
95
Lesson Eight skiu 8-1

Creating a New Table


Step by Step Adding Fields:
(continued)
5 Type: Class Name tTnter=l
Notice: The word "Text" along with an arrow appears in the Data
Type cell. The data entered in this field will be text values. This is
the default data type. The lower pane displays the default field
properties for the new field.

6 Click: ffi the arrow beside the Data Type "Text"


Notice: A list box with several data types appears.

7 Click: in the second Field Name cell (below Class Name)


Notice: The insertion point is placed in the cell.
I Type: Department
I Press: E (to move to the next Field cell)
10 Type: lnstructor g
11 Type: Location
12 Type: Unib Q
13 Type: Date GnteIJl
14 Click: anyrhere in the Class Name cell
15 Click: ffi the lnsert Row button
Notice: A blank row is added above the Class Name field and
the insertion point is positioned in the blank row.

(Cont.)

Title #289-4s0 96
Lesson Eight skilt 8-1
Creating a New Thble
Step by Step 16 Type: Class lD IEnter*l
(continued)

Adding a Description:
17 Click: in the Description cell of the Location field
18 Type: Enter the City name.

Deleting a Field:
19 Click: in the Field Selector 6 to the left of "Units"
Notice: The Units field is selected.

20 Press: lpelm
Notice: The Units field is removed.

Setting a Primary Key:


Note: Access works most efficiently if you specify a "primary key."
The primary key consists of one or more fields that uniquely identify
each record you store in a table. A primary key is often an lD number
or code, since this type of value is always different for each record.
For example, in this table, the Class lD field will contain a different
value for each record, since no two classes can have the same lD.
'You
will make this field the primary key. When you specify a field as
the primary key, Access automatically creates an index for this field.
This index helps speed up queries and other operations.

21 Click: anyrhere in the Class lD field


22 Click: ffil the Set Primary Key button
Notice: Ihe ffi symbol appears in the Field Selectorforthe Class lD
field.
Note: lf you do not set a primary key, Access will ask you if you want
it to set one for you when you close the table. lf you let Access set
the primary key, itwilladd a newfield, called lD, to the top of yourfield
list. lt will set the Data type to "Counter," which numbers records
consecutively. You will learn more about data types in the next lesson
of this course.

(Cont.)

97 Tiile #289-450
Lesson Eight skill 8-1

Creating a New Table


Step by Step 23 Examine: the lndexed property text box
(continued) Notice: The I ndexed propefi text box now reads "Yes (No D u plicates)."
This means that the Class lD field is indexed and cannot contain more
than one record with the same value. This is called a unique index.
You will learn more about indexing fields in the next volume of this
course.

Tips and faCh time,you open a table;,,it,;g r.Lmatically sprted ih aseending,:oider,by its primW kW
Techniques

Tirle #289-450 98
Lesson Eiqht skiu 8-2

Saving the Table


To save your new table, you can choose the File, Save command, or you can click on the Save
button. Access will prompt you for a name to give your table.

In this skill, you will name the new table "Classes."

Step by Step 1 Click: ffi the Save button


Notice: The Save As dialog box appears. The default name is
"Table1""

2 Type: Classes mter.-'l


Notice: The title bar changes to read "Table: Classes." The
table is saved.

Tips and Vou ian ilso access the Save As dialog box by choosing File, Save As. " , :

:.
Techniques Object names can be up to 64 characters lcng and can contain any number of letters, oumbers,
and spaces, and special characiers except a period (.), an exclamation mart 1l;, i backquote
characGi ('). and bracketi ([ ]),

Tirle #289-450
99
Lesson Eight Skill 8-3

Entering Data
When you have finished designing your new table, and you have saved it, you can change to
Datasheet view and 6egin entering your data.

In this skill, you will change to Datasheet view and add one record to the table.

Step by Step Click: ffi tne Datasheet View button


Notice: You are now in Datasheet view. The table contains the
six fields you added. The insertion point is positioned in the first
cell of Record 1.

Type: Pc101 fam


Notice: You are moved to the Class Name field.

Type: lntroduction to Personal Computers tTa65l


Notice: The class name is too wide to fit in this field

Complete: the record as shown below

Tips and f0 ]uan drdl.ifis..fi- $;llfilatA,'EfiJ l0 $fifl:: r.enief.'nbw,f $f i

Techniques

Title #289-450 100


Changing Field Column Width
The column width determines how much data you can display in a field. The amount of data that
can be entered into a column is controlled by field size. The default field size for text is 50 charac-
ters. When you first create a table, your field columns are set to display the width of 18.8 charac-
ters. You can change the width of a field column by dragging the column borders, or by choosing
the Format, Column Width command.

In this skill, you will change the width of two columns.

Step by Step Position: the mouse pointer on the border between the
Class Name and Department field headers
Border
,,
v
Notice: The mouse pointer changes to a thick bar with a two'
headed arrow.

Click & drag: the border about one inch to the right
Notice: When you release the mouse pointer, the Class Name
field is widened.
Note: lt may take a few tries to make it the size you want'
Position: the mouse pointer on the border between the
Class lD and Class Name field headers
Double-click:'on the border
Notice: The Class lD field is automatically adiusted to fit the
widest entry.

Choose: File, Close


Notice: You are prompted to save your layout changes before
closing.

Choose:
Notice: You are returned to the Database window' The Classes
table was added to the list of table obiects.

Tips and ib.,,cnobse,iho,,Besi rii,biiibil'6$;ch6osi Fb*au,,cdu.nm::widffi;irBe$tiFit;


Techniques fne nita column width contiois how much of a single record you can see at one time. Field size,
on the other hand, controls the number of characters that can actually be entered into the cell.
:fUg,,O6ituit],Cl6i6,:sfie,differS'Adpi*ficg:,onithg,t#-e,,bfdatq ! ] 'isell(n
:ii5]'Stoted:i ers;
etc');

Tirle #289-450
101
In Prsctice: Usins the Thble Wizard

The Table Wizard guides you through the steps of building a table. It offers examples and sugges-
tions for your table design and allows you to customize your table as you build it.

The Table Wizard provides templates for both business and personal tables. Suppose you are
buying home owner's insurance and need to store data about your household inventory. The Wizard
has a built-in table already set up to do this.

In this skill, you will use the Table Wizard to create a new table.

Step by Step 1 Select: the Table object bufton (if necessary)


l_
2 Choose: l,i$li .iitlililrill
li:Ir'ffi!Ef*1is$
Notice: The New Table dialog box appears.

t--_;---1
I'J\ |
I E:::lt? I

Click: Table l#izald*


Notice: ln a few seconds, the Table Wizard appears.

Click: O Personal (to select it)


Notice: The list of Sample Tables changes.

CD-ROM Users: the "Try lt" audio coach prompts you to choose your
own selecfions while using this Wizard. Regard the
remaining ln Practice steps as suggestions only.

(Cont.)
Title #289-450
t02
In Prsctice: Usine the Tsble Mzurd

Step by Step 5 Select: Household lnventory (in the Sample Tables list)
(continued) Notice: The field HouseholdlnvlD is highlighted in the Sample Fields
list.

6 Click: ffi ttre Add field button


Notice: The field is added to the "Fields in my new table" list.

7 Double-click: {'!'t'.,..1.t3".!:l -.-.,,, *jl (in the lower-right corner)

B Type: Item#
I Click: in the Fields in my new table list
Notice: HouseholdlnvlD is replaced with ltem#. Thefield ltemName
is selected in the Sample Fields list.

10 Click: ffi tne Add field button


Notice: The field ltemName is added to the list.

11 Double-click: Description (in the Sample Fields list)


Notice: The field Description is added to the list.

12 Add: the following fields to the list: Manuracturer


Model
SerialNumber
PurchasePrice

13 Choose:
Notice: The Table Wizard prompts you to name your table. You can
choose to set a primary key yourself , or have Access do this for you.
The default is to let Access sef the primary key.

14 Choose: ffifl (to accept the suggested name and have Access
set the primary key)
Notice: Your new table is not related to any of the tables in your
database.

15 Choose:
Notice: The Table Wizard is ready to create your table. You can
choose to modify the table design, enter data directly into the table,
or enter data into the table using a form the Wizard creates for you.

16 Choose:
Notice: The table is created and you are placed in Datasheet view.
You can now enter your data. The first cell in the ltem# field reads
"Counter." Access automatically made this the primary key and used
the Counter data type. This data type will number each value in this
field consecutively.

17 Close: the table


Title #289-450
103
Additional Exercises
After performing the skills in this lesson, you may want some additional practice. Below are some sugges-
tions for activities you can try on your computer, along with some questions to check your comprehension of
the material covered in the lesson.

ACTIVITIES TO TRY:
1. Use the Table Wizard to create a new table.

2. Use the Table Design window to modify your new table.

QUESTIONS:
1. Why would you create a new table without using the Table Wizard?

2. Explain the function of the primary key field.

3. Explain the difference between field column width and field srze.

Title #289-450 104


Custornizing Tables
Lesson Nine

Introduction Lesson Objectives


Once you've created tables, you can make it easier By the end of Lesson Nine, you will be able to:
to store, manipulate, and enter data into them. . Specify Data Types
Access provides several ways to customize your
tables, making them easier to work with. This
. Set Field Properties
lesson leads you through some of the options . Create an Input Mask
available that control the characteristics of your
data and fields. . Create an Index

In this lesson, you will specify a data type for a


field, set a field property, and create an input mask
that speeds up data entry. Also, you'll learn how
to index the fields in your table. Indexes help
Access find and sort data more efficiently.

Title #289-450
r07
Lesson Nine Before You Start

Before You Start


To practice the skills, in this lesson using the CD-ROM, perform steps I through 4 only.
To practice the skills in this lesson without the CD-ROM, perform steps 5 through 9 only.

Step by Step To get hands-on practice using the CD-ROM:


1 Start: the SmartTrainer software
Note: For instructions on how to start the SmartTrainer software,
refer to page 4 in the Getting Started section.

2 Choose:

3 Select: Lesson 9- Customizing Tables (listed in the Available


Standard Lessons list box)

Choose:
Notice: The first skill in the lesson plan begins playing in the "Try
It" mode.
Note: lf you've just completed the "Show Me" segment of a skill,
you can switch to the "Try lt" mode by choosing the START button
under the words "Try lt" in the enlarged Playback Control window.

To get hands-on practice without the GD-ROM:


lf Necessary:
5 Start: the Access program
6 Close: the MS Access Cue Cards window
7 Maximize: the Access window

To Open the Practice File for this Lesson:


8 Open: the W&A_9.MDB file (in the AST subdirectory, located
in the root directory of your hard disk)
Note: lf the subdirectory C:\AST does not exist, you will need to
install the practice files before continuing. To install the practice
files, refer to the section titled "Taking this Course Without the
CD-ROM" on page 4 of the Getting Started section.

Maximize: the Database window

Tifle #289-450
108
Lesson Nine skia 9-1

Specifying Data Types


When a field is added to a table, Access automatically assigns it a data type. A data type determines
what kind of values.are allowed in the field, the amount of storage for the values, the type of opera-
tions that can be performed on the values, and whether or not Access can index or sort the values.
The default data type is "text." However, if a field contains values other than text, you may need to
change the data type. The data type column or the Properties box in the Table Design view is used to
specify data type for a field.

In this skill, you will change the Unit Price data type to Currency.

Step by Step 1 Open: the Order Detaib table


2 Examine: the Unit Price field
Notice: The numbers represent dollar amounts and are left-justified.

Wry
i..r........................... ......i

i60 i
...{.F-.......-. .*-----1
i7 6.5 J
i

l
i{3-5" I
i 65.55 ......1

Click: ffi tne Design View button


Notice: The Order Details table opens in Design view.

Click: in the Data Type cell of the UnitPrice field


Notice: The data type in the UnitPrice field is the default
selection, text. AIso, an arrow appears beside the cell.

Datatype-ieii ffi;
Click: W the arrow beside the Data Type cell
Notice: A list box with several data types appears.

Current data type :IEt


Memo
Number
Data type Date/Time
list box Curency
Counter
Yes/No

6 Select: Currency
Notice: The data type changes to Currency. Also, the Format
property box in the Field Properties section reads Currency.
(Cont.)

Title *289-450
109
Lesson Nine skill 9-1

Specifying Data Types


Step by Step 7 Click: ffi the Save button
(continued)

8 Click: ffi tne Datasheet View button


9 Examine: the Unit Price field
Notice: A dollar sign is added to each entry in the Unit Price field,
indicating dollar amounts.

tffisrEFffil
I .. ...$.7,0.-0-.;
i $60.00 i

, $4soo
I $z,oo
i
I

, $6,50 ]

i $435'00 l
i $65.55 I

Tips and When you change d"t" type, the properties for that field change to the default setting for the
new data type
Techniques
The following ialte determines the correct data type:
Data Type Values Stored
Text Alphanumeric characters
Memo Alphanumeric characte* (usually several sentences or paragraphs)
Number Numeric values (integers or fractional values)
Date/Time Dates and times
Currency Monetary values

record you add


YesA.Io Boolean values
OLE Object OLE objects, graphics, or other binary data

rifle#28s-450 I10
Lesson Nine skill 9-2

Setting Field Properties


Field properties are used by Access when you view and edit data. Field properties allow you to
control the appearance ofdata, prevent incorrect entries, specify default values, and speed up search-
ing and sorting.

In this skill, you will set a field property that requires data to be entered in a field.

Step by Step Setting the Property:

1 Click: ffi the Design View button


2 Click: in the Field Name cell for Quantity
3 Examine: the Fleld Properties for the Quantity field (in the lower
pane of the table Design window)

j[]$r€,,,rt,,,,,,,*r,r,,r,,,::::1i:{r+j}jiiiiiiiititiiiiiririjjti:it.+n#NTiilirritfriiil.

Notice: The Required property box for Quantity is set to "No."


indicates that this field may be left blank.

Click: in the right side of the Required property box


Click here

I
;Flequireil'
r, '':::i:::,. . No I'\
rd

Notice: A list box appears with two choices - Yes and No.

Current setting :!
Yes
List box

(Cont.)

Title #289-450
111
Lesson Nine skia 9-2

Setting Field Properties


Step by Step 5 Select: Yes
(continued)
.ffi:ffiHffi\r\$,$i1a\$.#$.m:
Notice: The Required property for Quantity changes to "Yes." lt is
now required that data be entered in the Quantity field. Cells in this
field cannot be left blank.

Saving the Property:

6 Click: ffi tne Save button


Notice: A Microsoft Access dialog box appears warning that your
changes mightviolate data integrity rules and that existing data may
not be valid for the new rules. Also, Access offers to test existing
data against the new rules.
Note: Because a unit price is now required for each entry in the
Order Details table, Access wants to make sure that all existing
records have a unit price. lf existing records didn't have a unit price,
then the data wouldn't comply with the new property.
Giliffi*-il
7 Choose: tffi.Hffi$
tstEssrs$it
(to continue without testing existing data
against the new rules)

Testing the Property:

8 Click: the Datasheet View button

I Click: ffi tne New button (to add a record)


10 Type: 93 tTbGl
11 Type: Making the Metamorph
12 Press: fTabGl twice (to move to the Unit Price field)
13 Type: 6
Notice: The Quantity field is left blank.

14 Click: anylrhere outside the current record (to complete the


record)
Notice: A Microsoft Access dialog box appears indicating that the
Quantity field can't contain a null value.

(Cont.)

Title #289-450
tt2
Lesson Nine skiu 9-2

Setting Field Properties


Step by Step I '. .. ,..--{-.,. .I
(continued) 15 Choose: li,...30Ki .r,t
lirird$ii&{&id

16 Click: in the Quantity field


17 Type: 1

18 Click: anywhere outside the current record (to complete


the record)
Notice: The record is saved.
19 Close: the Order Details table

Tips and The fcllowing table determines field prope# uses:


Techniques Field Propefly
:::
FieldSiie Adjusts the size of a,,ifext fieldi ot limits the &q$e of,aliowable,.+a es.
in a Number field,

Displays dates and numbers in a certain display format. zuch ai Short


Date or Currency.

DecimalPlaces Displays a certain number of places after the decimal point when
using a format for a Number or Currency field.

InputMask : Displays formarting characters in a field so that they don't have to be


:

Captiori Specifies a label other than the default label (field name) for new
forms and reports.

Default Value Aniofui.ufiy.titt, io u value for a field in fiew #at& tftut


you add to a table. ""*u*
Validation Rlle and Limits data entered in a field to values that meet a ce*ain
requirement.
Validation Text

Required Requires thal data be entered in a field. :

AllowZerolength AUo*, zero-iength strings to be stored in a text oi *"*o nitO.

Indexed :
Speeds up searches on fields that are searched frequently.

Title #289-450
113
Lesson Nine skiu 9-3
Creating an Input Mask
Input masks simplify data entry when the values you enter in a field have the same format. An input
mask automatically displays and enters formatting characters, such as parentheses, in a field so that
they don't have to be typed each time you enter values. Input masks also ensure that the data entered
will fit in the field.
In this skill, you will create an input mask for the Order Date field.

Step by Step Selecting a Field:


1 Open: the Orders table in Design view
2 Click: in the Field Name cell of OrderDate
3 Examine: the Format property box (in the lower pane)
Notice: The format for the OrderDate field is set to Long Date.

4 Click: in the lnput Mask property box (in the lower pane)
Notice: A Build button appears to the right of the lnput Mask propefi
box.

Build
Button

lnet)tiffia$fi #,

Using the lnput Mask Wizard:


5 Click: g the Build button
Notice: The first dialog box of the Input Mask Wizard appears. The
lnput Mask Name list contains predefined masks from which to
choose and a sample of each maskformat is shown below "Example."

(Cont.)

Title #289-450 114


Lesson Nine skia 9-3

Creating an Input Mask


Step by Step 6 Select: Short Date (from the lnput Mask Name list)
(continued)

7 Choose: rffifl
Notice: The next step of the lnput Mask Wizard appears and it
provides the choice of a placeholder.

8 Click: L il (to accept the default)


Notice: This is the last step, and the the input mask will be created.

I Click: lwil
10 Examine: the lnput Mask proper$ box
Notice: The Short Date input mask characters are entered in the
lnput Mask property box.
.
$f,lffijiffS.ffiR\Nid-El.Eslri0jo;- ffi
Note: Mask characters serve as placeholders in a mask. They
indicate the values that can be input, and how the mask is displayed.
.Mask placeholders are replaced when you enter characters in a field.

11 Click: ffi tne Save button


12 Click: ffi tne Datasheet View button

Using an lnput Mask:

13 Click: ffi tne New button (to add a record)

14 Press: tTa6sl 3 times


15 Type: 4115194
Notice: The input mask controls how the text is entered.

16 Press: @
Notice: The format property applies the Long Date format to the
data entered i - riiaav. Apiit i E. 1gg4j

(Cont.)
Title #289-450
115
Lesson Nine skiu 9-3

Creating an Input Mask


Step by Step 17 Press: @
(continued)
Notice: The data entered is removed.

18 Close: the Orders table

Tips and
Techniques Mask Character InterPretatio;r
0

converted to spacesj
L Letter (entry required)
? Letter (entry not required)
A Lefter or digit lentry required)
a Littei or digit (entry not required)
& Any character or space (entry required)
C Any cbaracter or space (entry not required.)

claracter in the input mask--use when you want to include one of the

Title #289-450 116


In Practice: Creating un Index

Speeding up the operations of searching and sorting tables is important when your tables become
large. To do this, Access allows you to create an index for a field, similar to the indexes you find in
books. Access can find data quickly by looking it up in the index instead of searching the entire
database.

In this lesson, you will create an index for a field that contains last names.

Step by Step Open: the Employees table


Notice: The Employees table is sorted by the Employee lD field
alphanumerically in ascending order.

ffiEIl ,Wa-!ke1
EMP10 Sellers
EMP]00 ,Palricia
Ascending EMP] 2 , lsherwood
order EMP'14 , Plumas
EMP.IS : ChiN
EMP]6 DeMarco

Click: ffi tne Design View button


'Notice: The key in the row selector of the EmployeelD field indicates
EmployeelD is the primary key. AIso, in the Properties section,
EmployeelD is indexed "Yes(No Duplicates)."

Eieldr:FiopeiliH*,iii

lize ,,"'.
lietd
u0.....'.,
lorm€t
:t : t.t :r | :..)..1: :::::::. ::: : : : : : : : : :
::::::::::::t.::t))::
,
,',

itnn$la:e*;1';iii;]1i i;iiii
.[eniioniii.ir;rriurii:i.rt. E;pi;r;; iD
:,BFlEu[i\r8l' q......., j..i. F.TB
llll::lii:E
1v[liflari$r.Fu*;giiir ::u
V,stidatiFni.I'e#t....i..ii. :1,:::::il

.n*ilti$d..ti.i.....i...i.i..........
No
*f t*rir .tr€ig,. tteiiuilt: No
,lndErted:l:,i, ::r:::::r::::::r:::rr::: Yes [No DupticatesJ

Primary key index

(Cont.)

II7 Title #289-450


In Practice: Creuting an Index

Step by Step 3 Click: ffi the lndexes button


(continued)
Notice: The lndexes window for the Employees table opens.
There is an index created for the primary key field, EmployeelD.
The index Sort Order is Ascending.

:frittsiy;ii!lit:ili Ygl t::t.t.tl

ufllsle .,.i ,Yes 1....1 he nbme foi this inden Eacfr ir.rije+r can use:up
.l$ii(e.iFlffi ,No l:it:il !:
.: :: fidds^
:,lo:10 ::

The Primary property identilies the EmployeelD field as the primary key. The Unique
property indicates that there can't be any duplicate values in the field. The lgnore Nulls
property indicates that all cells in this field with a null value will be included in the index.

4 Click: in the second lndex Name cell


5 Type: Lbst Name [TnterJl
Notice: An arrow appears on the right side of the Field Name celland
an Ascending sort is entered in the Sort Order cell.

6 Click: SS the arrow beside the Field Name cell


Notice: A list box appears with the field names for the Employees
table.

7 Select: LastName
Notice: The LastName field name is entered in the Field Name cell.

8 Click: ffi tne lndexes button (to close the lndexes window)
I Click: ffi tne Save button
10 Close: the Employees table

Tips and A. iiiildex:]F entr.i:ther:uSei:flo liEnteffi::b:,,ualue:,,that:iaftEa ,,exists,,ih, e gp,pe,fiel


Techniques aaothei.iecord, P1 .:keys..$rc,lauto.lrraticdiy..tssigp€d..A. ..ifidbxl.,.Yod..Cbnlt..ifidax*.field
whose dati rype ir U"*o,oi Couniei. Consider indexing a field if the fo[owing apply: the field's
Aataqyp" itfext, Number, Cqqency, or Date/Time, you:need io search for specific values or ranges
of vatues, or you need 1o store many different values in a field.

Title #289-450
Lesson Nine

Additional Exercises
After performing the skills in this lesson, you may want some additional practice. Below are some sugges-
tions for activities you can try on your computer, along with some questions to check your comprehension of
the material covered in the lesson.

ACTIVITIES TO TRY:
1. Open the Employees table in Design view'

2. Assign a Text data type for the PostalCode field.

3. Change the PostalCode fie1d's Required property to Yes.

4. Create an index for the Region field.

QUESTIONS:
1. What does a data type determine?

2. What do input masks automatically enter in fields?

3. What kind of index is a primary key assigned to?

ll9 Tille #289-450


Llnderstanding
Table R.elationships
Lesson Ten

Introduction Lesson Objectives


The power of Microsoft Access lies in its ability By the end of Lesson Ten, you will be able to:
to find and manage data across multiple tables. . View Database Relationships
Access has this ability once relationships are
established between tables that contain related
. Add Tables to the Relationships Window
data. This lesson focuses on defining and viewing
table relationships.

In this lesson, you will be introduced to


relationships, what they are, how they're used,
and why they work. Next you will view a table
relationship, and then add tables to the
Relationships window.

r23 Tiile #289-450


Lesson Tbn Before You Start

Before You Start


To practice the skills in this lesson using the CD-ROM, perform steps 1 through 4 only.

To practice the skills in this lesson without the CD-ROM, perform steps 5 through 9 only.

Step by Step To get hands-on practice using the CD-ROM:


1 Start: the SmartTrainer software
Note: For instructions on how to start the SmartTrainer software,
refer to page 4 in the Getting Started section.

Choose:

Select: Lesson 10- Understanding Table Relationships


(listed in the Available Standard Lessons list box)

Choose:
Notice: The first skill in the lesson plan begins playing in the "Try
It" mode.
Note: lf you've just completed the "Show Me" segment of a skill,
yeu can switch to the "Try lt" mode by choosing the START button
under the words "Try lt" in the enlarged Playback Control window.

To get hands-on practice without the CD-ROM:


lf Necessary:
5 Start: the Access program
6 Close: the MS Access Cue Cards window
7 Maximize: the Access window

To Open the Practice File for this Lesson:


8 Open: the W&A_1O.MDB file (in the AST subdirectory,
located in the root directory of your hard disk)
Note: lf the subdirectory C:\AST does not exist, you will need to
install the practice files before continuing. To install the practice
files, refer to the section titled "Taking this Course Without the
CD-ROM" on page 4 of the Getting Started section.

Maximize: the Database window

Title #289-450
t24
Lesson Tbn skill 10-I
Viewing Database RelationshiPs
Why Relationships are Used
Once tables are created, relationships can be established between those tables with related information.
Access uses relationships to find and manage associated information stored in the database. In order for
a relationship to be formed between tables, they must have a field in common. Usually it'sthe primary
key of one ofthe tables involved in the relationship. To establish a relationship, click and dra gtheprimary
key fi.eldfrom one table to the related field in another table. The related field is referred to as the foreign
key. In the example below, a relationship has been established between the Customer ID fields in the
Customers table and the Orders table.

These two tables have the Customer lD lield in common:

Primary table

Related table

Foreign key
field

Suppose you want to delete a customer from your database, and you wanted all the orders for that customer
to be deleted as well. Since the two tables are related, deleting a customer's record from the Customers
table will automatically delete associated records in the Orders table.

(Cont.)

Title #289-450
125
Lesson Tbn skilt I0-1
Viewing D atab3f,f"S.tatio ns hip s

Types of Relationsh'ips

There are three types of relationships: one-to-many, many-to-many, and one-to-one.

One-to-Many

A one-to-many relationship is the most common type. In this type of relationship, a record in
the "one" table can have more than one related record in the "many" table. However, a record
in the "many" table has only one related record in the "one" table.

"One" table

enses
BKSD Borko Studios Mellsqa Bo,1ko

One customer can have many orders.. "Many" table

but each order can have only one customer.

Manylo-Many

In a many-to-many relationship, a record in one table can have more than one matching record
in a second table. The second table can also have more than one matching record in the first table.
For example, each order in the Orders table can have many products, and each product in the
Products table can appear in many different orders. To establish a relationship between these two
tables directly, you would need to repeat information over and over again in one of your tables.
This is inefficient and can lead to data entry error.

(Cont.)

Tiile #289-450
t26
Lesson Ten skiu 10-1

Viewin g D ata.b3f,f"S.l atio n s hiP s

The solution is to create a third table that breaks down the many-to-many relationship into two
one-to-many relationships. You put the primary key from each of the two tables into the third
table.

One order can have many products... The "third" table

10 The Management Metamotph


10 Makinq th-e Metamorph
1 ! 0n a Wing and a Prayer
1 2 Cotporate Communication Dynamics

13 Actualierng Self
14 Actualizing Self

and each product can appear on many orders.

One-to-One

This type of relationship is rare. In a one-to-one relationship a record in either table has no more
than one related record in the other table.

"One" table

GloliaFoias iDllectololOpelatlons 87 Bloadway Phitadelp-hia- lPA


Melissa Eorko Director 23 Maqke! St, San Francigco, CA
Jim Halpern Director of Training 2 West Ave. San Mateo iCA

"One" table
Each California customer has one matching record in the Customers table and vice versa

MeJlssg -B,o1ko 23 Mafie-tSt, San Francisco CA


Director of Training 2 West Ave. 5an Mateo Td
Jim Halpern

Referential IntegrifY

Referential integrity is a security feature applied to some relationships. Referential integrity helps
protect the validity of relationships. This protection is applied so that related data isn't accidentally
altered. For example, if referential integrity is enforced in a one-to-many relationship, you can only
add records to the "many" table if the related record exists in the "one" table. Likewise, you can't
delete records in the "one" table if there are related records in the "many" table'

(Cont.)

t27 Title #289-450


Lesson Tbn skill 10-1

Viewing Database Relationships


Step by Step Viewing the Relationships Window:
(continued) Note: When creating orediting relationships in a database it's a good
idea to see the relationships that have already been created. Any
tables or queries that are added to the Relationships window will
automatically have their relationships displayed. This also gives you
an idea of how tables are related.

Click: ffi the Relationships button


Notice: The Relationships window opens.
Examine: the Relationships window
Notice: The Products and Category tables'field lists are shown in the
Relationships window. A join line links the tables. This indicates that
a one-to-many relationship is established between the tables. The
Category table is the "one" side, and the Products table is the "many"
side.

Join line

"many" side

Tips and
Techniques :Relbiiofships..menu,.of.clidk..ttie... ]etl.,Raixiuffis.,bufion,on, itbo1h'nir::,:iTbi,vib*f e,..
relailonships for a specific table, select that table in the Relttibnships windo* and choose the
Show Direct command from the [etaiionships menu or click the Show Direct Relationbhipi
button on the toolbar.

Title #289-450
128
Lesson Ten skill 10-2

Adding Tables to the Relationships Window


at a time'
As a relational database, Access gives you the ability to use data from more than one table
used to
Relationships can be established between tables that have related data. Relationships are
joins in queries,
enforce referential integrity which protects the relationships between tables, create
and display related records in forms and reports.

In this skil1, you will add the Customers and Orders tables to the Relationships window.

Step by Step Click: ffi tne Add rable button

lTffi;.I:
l*'*i* :

Vi*Ytt.::::::i:ijtir:, ] : :. ] ]. l | |: i ! i: : : : i ] ] i: : : : : : : : : : : }

,fi,i"t#ia* fillle$tf ii:iil

,
Notice: The Add Tabte diatog box appears. The Table/Query list box
contains atl the table names for the database. The View section lets
you display only tables, only queries, or both.

2 Select: the Customers table


3 choose: 1*--- 'ilj-ffifl
Notice: The fietd tist for the customers table is added to the
RelationshiPs window'

4 Double-click: the Orders table

5 choose:1.,.-il---....W...---ffi
Notice: The field list for the Orders table is added to the
Retationships window. Also, the primary key field name in the
Customers table is bold.

Close and save the Relationships window.

y"".a11 op* in" ead futte dialog box by choosing Relaiionships, Add Table froni the menu. Yorr
Tips and
can add taLles or queries to the Relalionships window by dragging them from the database window'
Techniques [l liei : bt*:fiu6. ,Rqi[tXO .ffindbwj.s*lebi.fiu.iitl$:$ffi.o$ih$:fie1il.1i#:you.wamdeiet€d;
andiipr.es'S:;Aei*e'

Title #289-450
t29
Lesson Tbn

Additional Exercises
After performing the skills in this lesson, you may want some additional practice. Below are some sugges-
tions for activities you can-try on your computer, along with some questions to check your comprehension of
the material covered in the lesson.

ACTIVITIES TO TRY:
L Open the Relationships window.

2. Add the Employees table to the Relationships window.

3. Delete the Employees table from the Relationships window.

4. Close the Relationships window.

OUESTIONS:
l. For what purpose does Access use relationships?

2. Name the three types of table relationships.

3. What does referential integrity help protect?

rirr6 *28s-4s0 130


Establishing
Table Flelationships
Lesson Eleven

Introduction Lesson Objectives


To establish relationships, the tables involved in By the end of Lesson Eleven, you will be able to:
the relationship must have related data between . Create a One-to-Many Relationship
them. The related data usually resides within the
primary key of one table and within the matching
. {.Jse Cascade Delete
field in the other table. . Create a Many-to-Many Relationship
Once the relationship is established you can use it
to find, add, and change data within the related
tables.

In this lesson, you will create a one-to-many


relationship, test the relationship, and use Cascade
Delete to remove records from the database'
Finally, you will create a many-to-many
relationship.

133 Title #289-450


Lesson Eleven Before You Start

Before You Start


To practice the skills in this lesson using the CD-ROM, perform steps 1 through 4 only.

To practice the skills in this lesson without the CD-ROM, perform steps 5 through 9 only.

Step by Step To get hands-on practice using the CD-ROM:


1 Start: the SmartTrainer software
Note: For instructions on how to start the SmartTrainer software,
refer to page 4 in the Getting Started section.

2 Choose:

3 Select: Lesson 11- Establishing Table Relationships (listed


in the Available Standard Lessons list box)

Choose:
Notice: The first skill in the lesson plan begins playing in the "Try
It" mode.
Note: lf you've just completed the "Show Me" segment of a skill,
you can switch to the "Try lt" mode by choosing the START button
under the words "Try lt" in the enlarged Playback Control window.

To get hands-on practice without the CD-ROM:


lf Necessary:
5 Start: the Access program
6 Close: the MS Access Cue Cards window
7 Maximize: the Access window

To Open the Practice File for this Lesson:


B Open: the W&A_11.MDB file (in the AST subdirectory,
located in the root directory of your hard disk)
Note: lf the subdirectory C:\AST does not exist, you will need to
install the practice files before continuing. To install the practice
files, refer to the section titled "Taking this Course Without the
CD-ROM" on page 4 of the Getting Started section.

I Maximize: the Database window

Tiile #289-450 134


Lesson Eleven skiu 11-1

Creating a One-to-Many Relationship


In a one-to-many relationship, a record from the "one" side of the relationship can have more than
one related record from the "many" side of the relationship, but a record from the "many" side can
have only one related record from the "one" side. To create this type of relationship, you add the
field(s) that make up the primary key on the "one" side of the relationship to the table on the "many"
side of the relationship.

In this skill, you will add the primary key from the Customers table to the Orders table.

Step by Step Click: ffits the Relationships button


Notice: The Relationships window opens.

Click & drag: the primary key field, CustomerlD, from the Customers
table to the CustomerlD field in the Orders table
Notice: When the field is dragged, the cursor changes to a rectangle.
Also, when the field is placed on the related field, the Relationships
dialog box appears.

Examine: the Table/Query and Related Table/Query lists


Notice: The related tables and fields are entered in both lists.
Related Tables

CustomerlD [i*",* CustomerlD

Related Fields

(Cont.)

Tifle #289-450
135
Lesson Eleven skill 11-1

Creating a One-to-Many Relationship


Click: t-;.W$$ffi(toselectit)
Notice: The One To Many option in the lower-left part of the dialog
Step by Step box is automatically selected.
(continued)

Note: Referential integrity helps ensure that relationships between


records are valid, and that related data is not accidentally deleted.

Choose:
Notice: A one-to-many relationship line is drawn between the
Customers and Orders tables. The number "1 " at the Customers end
of the relationship line indicates that one customerfrom the Customers
table can have many orders in the Orders table. The many side of the
relationship is indicated by the infinity symbol. Also, referential
integrity is indicated by the solid bars at each end of the relationship
line.

One{o-many
relationship line

lnfinity symbol

Solid bars indicate referential


integrity enforced

Close: the Relationships window

(Cont.)

Title #289-450 r36


Lesson Eleven skilt I1-1
Creating a One-to-Many Relationship
Step by Step Testing the Relationship:
(continued) Note: Preserving the integrity of the data stored in your database
is a major function of a relationship. The preservation task is the
responsibi lity of referential integrity. Referential ntegrity prevents
i

the accidental alteration of data in your database. Referential


integrity ensures that records in related tables match, which
makes them valid.

7 Open: the Customers table


I Select: the first record
Note: To do this, click ffi the record selector to the left of the
record you want to select.

I Press: @

Notice: ,Access displays a message box indicating the record can'l


be deleted. Referentialintegrity is enforced in this situation because
related records exist in the Orders table.

rffil
10 Choose: l$si$-tdN-E
littd&w
11 Close: the Customers table

Tips and \ lheth*r. oi not, you Uvel rthe Retationshifi s wj


1
i

are automatically saved in the database.


Techniques
Referenrial integri-ry can't be applied to attached tablei from other database forrnats,

t37 Title #289-450


In Prsctice: Usins Cascade Delete

Referential integrity prevents you from deleting or changing records that are related to other records
in another table. However, you might want to delete the shared record from both tables. To do this,
you can use the Cascade Delete feature.

When Cascade Delete is selected, Access will delete records in related tables once you delete records
in a primary table.

In this skill, you will use Cascade Delete to delete records in related tables.

Step by Step Specifying Gascade Delete:

1 Click: ffi the Relationships button


Notice: The R.elationships window opens.

Double-click: the thin section of the relationship line between


the Gustomers table and the Orders table

Double-click here

Notice: The Relationships dialog box appears.


Examine: the lower part of the dialog box

Notice: There are two check boxes for "Cascade Update Related
Fields," and "Cascade Delete Related Records."

4 Click: (to select it)

5 Choose: lffi*,W-]i#Lil,r,l

6 Close: the Relation ships window

{Cont.)

Title #289-450
r38
In Prsctice: Usins Cascade Delete

Step by Step Using Cascade Delete:


(continued) 7 Open: the Customers table
8 Select: the first record
I Press:
Notice: A message box appears indicating the deletion of a record
in the current table (Customers) and additional records in a related
table (Orders).

10 Choose: |ffiil (to save the changes to the related tables)


Notice: The record for Customer lD AFJW is deleted.

11 Close: the Customers table

Tips and Wiign..iou,ie rctscadb,.ffiaata,...$nanleS.ffi{.m..[.,prirnm..tab]4..*ill,1ilsQ.,$e.ruda,..in


Techniques
Tirle #289-450
Lesson Eleven skill 11-2

Creating a Many-to-Many Relationship


Major obstacles in the storage of data are clutter and repetition. A solution to this is to establish a many-
to-many relationship.

To do this, you create a third table that links two related tables. The third table contains the primary key
from the other two tables. A one-to-many relationship is established between the third table and each
related table. This permits records in each of the related tables to call upon multiple records in the other
table. As a result, the need to repeat records in either table is eliminated.

In this skill, you will create a many-to-many relationship between the Orders and Products tables.

Step by Step Click: ffiil the Relationships button

2 Click: ffi tne Add rabte button


3 Double-click: the Order Details table (to add it to the Relationships
window)

4 Choose:

5 Move: the field list for the Order Details table between the
field list for the Orders table and the field list for the
Products table

Move: the field list for the Orders table to the left (to create
more space between it and the Order Details table field
list)
Notice: The join line changes depending onwhereyou placethefield
list.

Move: the field list for the Products table to the right (to
create more space between it and the Order Details table
field list)

(Cont.)

Title #289-450 140


Lesson Eleven skiu 11-2

Creating a Many-to-Many Relationship


Step by Step B Examine: the Orders, Order Details, and Products field lists
(continued) Fields in common Fields in common

Primary key

Notice: The Order Details table contains the primary key from both
the Orders table and the Products table.

Click & drag: the OrderlD field ftom the Orders table to the OrderlD
field in the Order Details table
Notice: The Relationships dialog box appears.

10 Click: ,ffi,iffi(toselectit)
11 Choose: rffin
One-to-many relationship

,.::,,:::,::: Ultltl$ . .,.,.,,::

OrHD
CustomerlD
EmployeelD
0rderDate
Required-byD

Notice: A one-to-many relationship is created between the Orders


and Order Details table. Each order can have more than one entry
in the Order Details table, but each entry in the Order Details table
is only related to one order record in the Orders table.

12 Click & drag: the ProductName field from the Products table to
the ProductName field in the Order Details table
Notice: The Relationships dialog box appears.

13 Click: iHffi(toselectit)

(Cont.)

t4l Tille #289-450


Lesson Eleven skiu 11-2

Creating a Many-to-Many Relationship


Step by Step t-::l
(continued)
14 Choose: tffiffi\Y
lryryt
One{o- many relationship

Notice: A one-to-many relationship is created between the Products


table and the Order Details table. Each product can have more than
one entry in the Order Details table, but each entry in the Order
Details table is related to only one product record in the Products
table.
Note: The creation of two one-to-many relationships using the Order
Details table creates a manyto-many relationship between the
Orders and Products tables. One order record in the Orders table
can contain many products from the Products table, and one product
from the Products table can appear on many records in the Orders
table.

Close and save the Relationships window.

Titls #289-450 t42


Lesson Eleven

Additional Exercises
After performing the skills in this lesson, you may want some additional practice. Below are some sugges-
tions for activities you can try on your computer, along with some questions to check your comprehension of
the material covered in the lesson.

ACTIVITIBS TO TRY:
1. Open the Relationships window.
2. Add the Employees table to the Relationships window'
3. Create a one-to-many relationship between the Employees table and the Orders table using the
EmployeelD field. The Employees table is the primary table.

4. Enforce referential integrity for the relationship between the Employees and Orders table.

QUESTIONS:
1. Why would you create a one-to-many relationship?

2. Describe a situation in which you would apply either Cascade Update or Cascade Delete.

3. What is a major advantage to creating a many-to-many relationship?

143 Tirle #289-450


Designing Select Queries
Lesson Twelve

Introduction Lesson Objectives


Once tables are created and relationships are By the end of Lesson Twelve, you will be able to:
established, your database is ready to be queried. a Select a Table to Query
Querying allows you to extract data stored in the
database.
a Add Fields to the Query

A query is similar to a question. You ask the a Save and View the Dynaset
database a question and you receive an answer in a Sort Records
the form of a dynaset. A dynaset is a set ofrecords
that the query retums. a Specify Criteria

The QBE grid is where you will set up the query a Set Criteria for a Hidden Field
or question that you want Access to act upon' a Create a Calculated Field
Specifying criteria in the QBE grid allows you to
focus your queries on avery specific collection of
data. Access uses the criteria to search the
database and find only those records that match
the criteria specified.

When you enter criteria in the QBE grid they're


called expressions. Expressions can also be used
to create new fields in the QBE grid and.produce
values that don't exist in your database.

In this lesson you will select a table to query,


choose fields to query by, and view the dynaset.
You will also apply a sort. Finally you will
speciff criteria, specify criteria for a hidden field,
and use the Expression Builder to create a
calculated field.

141 Title #289-450


Lesson Twelve Before You Sturt

Before You Start


To practice the skills in this lesson using the CD-ROM, perform steps 1 through 4 only.

To practice the skills in this lesson without the CD-ROM, perform steps 5 through 9 only.

Step by Step To get hands-on practice using the CD-ROM:


1 Start: the SmartTrainer software
Note: For instructions on how to start the SmartTrainer software,
refer to page 4 in the Getting Started section.

2 Choose:

3 Select: Lesson 12- Designing Select Queries (listed in the


Available Standard Lessons list box)

Choose:
Notice: The first skill in the lesson plan begins playing in the "Try
It" mode.
Note: lf you've just completed the "Show Me" segment of a skill,
ypu can switch to the "Try lt" mode by choosing the START button
under the words "Try lt" in the enlarged Playback Control window.

To get hands-on practice without the CD-ROM:


lf Necessary:
5 Start: the Access program
6 Close: the MS Access Gue Cards window
7 Maximize: the Access window

To Open the Practice File for this Lesson:


8 Open: the W&A_12.MDB file (in the AST subdirectory,
located in the root directory of your hard disk)
Note: lf the subdirectory C:\AST does not exist, you will need to
install the practice files before continuing. To install the practice
files, refer to the section titled "Taking this Course Without the
CD-ROM" on page 4 of the Getting Started section.

Maximize: the Database window

Tirle #289-450
148
Lesson Twelve skia 12-1

Selecting a Table to Query


Tables are the major storage object of an Access database. Most of the queries you design are based
on tables.

In this skill, you will select the Order Details table on which to base a query.

Step by Step 1 Click: the Query object button


r....................^**.*,-s.\! r

Choose: Irjiliiii$l#it|ii[$"\l
2 l$tlllllrji:ji,Il
Notice: The New Query dialog box appears
:liiillsi,sntt$)il
I il:Eriill ji l liiili :ll ::!l'l

Click: li#+ tlre New Query button


lrrs$iW#iBl$lil
twg
Notice: The Select Query window opens and the Add Table
dialog box is displayed.

Examine: the Add Table dialog box


Notice: The Table/Query list box contains allthe table names for
the database. Also, in the lower half of the dialog box are the
options for displaying tables, queries, or both.

Clar*es
Cu*tomert
Table names Employee*
Order Detail*
Order*
Ploduct*

(Cont.)
Title #289-450
149
Lesson Twelve skill 12-1

Selecting a Table to Query


Step by Step Double-click: the Order Details table
(continued) Notice: The Order Details table field list is added to the upper
pane of the Select Query window.

Field list

Choose:

Tips and Afid,TCbieu dogUux..*tsu,1*llow$,y .to::idisplgg:.alli.$c,..q$#bq..in.four,,date aSE,,,,Qubties


Techniques can:lilm:rbe,,bes$di:oui.EadlH irqiie.Iy..

Tille #289-450 150


Lesson Twelve skill t2-2
Adding Fields to the Query
Fields store the data within tables. You select fields from the field list to determine the data the query
will display. The fields are added to the QBE grid. The QBE grid determines the layout of the query.
You can add fields to the QBE grid by dragging them, double-clicking them, or selecting them from the
QBE grid"
In this skill, you will add four fields to the QBE grid.

Step by Step Click & drag: the OrderlD field from the Order Details field list to
the first Field cell in the QBE grid
Notice: The OrderlD field is added to the QBE grid.

Field name

t:::::iEis*
'::'::iiiBfii#
SIItHAI:
E;iitqffi
:i,iii!:riii:itlti

QBE grid

Click: in the right side of the second Field cell


Click here

Notice: A field list is displayed for the Order Details table.

Field cell
0rder Details."
0rderlD
ProductName
Field list
Quantity
UnitPrice

(Cont.)
Tirle #289-450
15i
Lesson Twelve skiu 12-2

Adding Fields to the Query


Step by Step 3 Select: the ProductName field
(continued) Notice: The ProductName field is entered in the second Field cell.

4 Click: the Quantity field in the Order Details field list


5 Hold down:
6 Click: the UnitPrice field in the field list
(while still holding down @l
Notice: The Quantity and UnitPrice fields are both selected.

7 Click & drag: the selected fields to the third Field cell in the
QBE grid
Notice: The Quantity and UnitPrice fields are added to the QBE grid
in the third and fourth field cells respectively, and the UnitPrice field
is highlighted.

8 Press: @
Notice: The UnitPrice field is deleted from the QBE grid.

9 Click: ffi tne Save bufton


Notice: The Save As dialog box appears.

10 Type: W&A Order Details tEntera


Notice: The query name appears in the title bar.

Tips and You ian also add fieids toit .QBB;gdd.b#.double'c1ic.ffi.th€$;tbs .'ping eifie-ld.n $:enelo$$d
in qquare brackets i4 a field leil. Ifyou drag the asterisk that appears at the top ofthe field list to
Techniques
a field cell, all the fields in that table will:be added to lhe QBE grid.

Title #289-450
t52
Lesson Twelve skiu 12-3

Viewing the Dynaset


When you save a query, it becomes part of your database. This allows you to view the results of your query
without having to reQreate it each time. To view the results of your euery, you must run the query. You
can run a select query by clicking the Run button, or the Datasheet view button. The results of your query
are displayed in a datasheet called a "dynaset."

In this skill, you will view the dynaset.

Step by Step Click: ffi tn" Datasheet View bufton (to run the query and
view the dynaset)
Notice: The Select Query:W&A Order Details dynaset is displayed.
The query pulls data from the Order lD, Product Name, and Quantity
fields of the Order Details table.

Tips and t+ l Ei: :


:duE$i#fi Eill it$ il fiEil tui* ffi +ffi I Vml*U.. ttse iU l.*i* u#ir*
Techniques ChoosruiiQuW;.,Run,

Title #289-450
153
Lesson Twelve skiil I2-4
Sorting Records
When viewing the dynaset, it often helps if the records are in a pre-defined order. Sorting records is one
way to order records.. Sorting allows you to place records in alphabetic order or in numeric sequence.

To speciff a sort order, you use the Sort cell in the QBE grid. Access allows you to sort by any field that
appears in the QBE grid.

In this skill, you will sort the Quantity field in descending order.

Step by Step 1 Click: ffi tne Design View button


2 Click: in the right side of the Quantity field Sort cell

Sort cell

iii:iiriEH
iiiii.lif,wu
;.,S;fiiiffi
Ef!!#rtiii
ijji:;::iiitii0ti

Notice: Three sort choices are displayed: Ascending, Descending,


and (not sorted).

Ascending
Sort choices D

Select: Descending
Notice: Descending is entered in the Sort cell.

Click: ffi tne Save button

(Cont.)

Title #289-450 rs4


Lesson Twelve skiu 12-4

Sorting Records
Step by Step
(continued) Click: ffi tne Datasheet View button
Notice: The dynaset is displayed. The Quantity field is in
descending order.

q:
'''''''''-.-:-:
70 Cooorate Dunamo Si
77,Ac1ua1i_zrng Selt 9;
.....-...,41-C--o--1p91-a-!-q--f,-,q-mm,q!tqi_o_n.-Qf nenip--**. 7i
26. The Po.,'re1 o_fMylh il
1:
40i Give Me Your Tired Huddled Masses
so, M"t rg ihe MelamorpLr on ti1q"- 1l
li
7_21 Myth
The P_gwer 9f " 7l
85, The Power of Myth . 7i
solA;tuddinq-$eiLseriii,
8$ Actualizing Self
__ -__- ----- -i - ....."8i

Tips and SffiEE$FEciry,,s6ru,,fti:ffi..ihan.lousi.ficldi.rl 0: $$iw,illiisofi::ffi1fiet0.1lg,:mei,$x1icffi,t$ft:,*rst1


Techniques fi$i&.,#iffiin.d$H..ffi .i'cf.ffiffio...of..CIfin..o,ffieot;c iib;q.$ ffii

Titl€ #289-450
155
Lesson Twelve skill 12-s

Specifying Criteria
One of the most powerful features of queries is the ability to limit the dynaset to certain records. You
accomplish this by specifying criteria. To specify criteria, you create an expression. Access uses the
expression to determine which records to display in the dynaset.

To create an expression you can type it in the Criteria cell ofthe QBE grid oruse the Expression Builder.

In this skill, you will specify criteria for the Quantity field by typing in an expression.

Step by Step 1 Click: ffi tne Design View button


2 Delete: the Descending sort in the Sort cell for the Quantity
field
Click: in the Quantity field Criteria cell

iiii;iri:Fi iilr
i1;iiiir1$siri
iiiiiis#ei;ii:l
Click here
]],S1fi*r;eii
:i:i!i....:......Ol'i

Type: >7 El
Notice: The insertion point moves to the "or" cell i n the Quantity field.

Type: =f
Note: The text entered is called an expression. The expression
indicates that Access will search for all the records that have seven
or more products ordered.

Expression

Choose: File, Save As...


Note: Choose File, Save As to save the query by a different name
so as not to overwrite the W&A Order Details query.

Type: Orders wn or More Products Fnter.-.ll

(Cont.)

Title #289-450 1s6


Lesson Twelve skill 12-s

Specifying Criteria
Step by Step
(continued)
Click: ffi tne Datasheet View button
Notice: The Select Query dynaset displays allthe records with seven
or more products ordered.

26, l-he Powp; -ql Myth


_3--Q,A.c-qp]iitng-s-s-lt
40. GG"i'E%,i iGd iiljiEJ Mil;;
sel occupitron ina spirit
60, Makilg the Melamoph 9n D!99 : 7i
......"F-!:-Ih-e.F--ewpr-.q-tMvthA-u-Ciq*-s*e[es. -,..... -- -.-9,
77,A-clua1iii11s Sell
85: T h-e.F-qyt.e_L-e_l_l{y-!h-..

Tips and To set criteria fbr fields with ihe Number, CurrenCy, oi Counter,data types;,,snter thC digits and the
deeimal symbol (if appropriate). You don't need,to:use currency or thousand separator symbols.
Techniques
The followrng:eiample formats will work for entering dates: l8 February 1994; 2/I8l94,l81F.eb-
ig94, Feb lB g4t, #2/'18/94#. When entering text in the Criteria call just tJ.pe the valueS. 'ThC
t'on,'l' or
criteria cell ii
not case sensitive' To furd Yas values, ent€r "Yes,il "True,': "'l " in''the
Criteria cell. To frnd No values,:enter "No," "False," 'loff," or "0.'r : :' '

Tiile #289-450
r57
Lesson Twelve skia 12-6

Setting Criteria for a Hidden Field


Adding field to the QBE grid doesn't require you to display records forthat field in your dynaset. Ifyou
a
decide not to display a field it can still be used to limit the records displayed by specifying criteria for it.
To hide a f,reld, deselect its Show box.

In this skill, you will specify criteria for the UnitPrice field, then hide the field in the dynaset.

Step by Step 1 Click: ffi tne Design View button


2 Double-click: the UnitPrice field in the field list
Notice: The UnitPrice field is added to the QBE grid.

3 Click: in the UnitPrice field Criteria cell


4 Type: <400
5 Delete: the expression in the Quantity field Criteria cell
6 Delete: the expression in the Quantity field "or" cell
7 Choose: File, Save As...

8 Type: Orders w/< $400 Unit Price fEfier.-'l

I Click: ffi tne Datasheet View button


Notice: The Select Query dynaset displays allthe records with a
unit price of less than $400.

(Cont.)

Title #289-450
158
Lesson Twelve skiil 12-6

Setting Criteria for a Hidden Field


Step by Step 10
(continued)
Click: ffi tne Design View button

11 Click: tr the UnitPrice field Show box (to deselect it)

12 Click: ffi tne Save button

13 Click: ffi tne Datasheet View button


Notice: The dynaset still displays all records with a unit price of
less than $400, but the Unit Price field is hidden.

14 Close: the Select Query window


Notice: The new queries are added to the Query obiect |ist.

Tips and ffied..iaDesi$.,*iew,.a..hidderneH:Ebo$..&e.:r.ihtrrr0st..fi*ld


in,the,:QBH,.enld,
Techniques

Title #289-450
r59
In Practice: Creating a Cslculuted Field

Fields in a query aren't limited to the fields from the table on which the query is based. This gives
you great flexibility in designing your queries to perform tasks other than selecting records.

A common task for queries is to perform a calculation. You can add a calculated field by entering an
expression in a field cell or by using the Expression Builder.

In this skill, you will add a field using the Expression Builder that calculates the total price for each
record in the Order Details table.

Step by Step Using the Expression Builder:


the W&A Order Details query in Design view
the UnitPrice field in the field list (to add it to the QBE
srid)
in the Field cell to the right of the UnitPrice field

W the Buitd button


Notice: The Expression Builder dialog box appears. The
insertion point is in the Expression Builder box. Directly below
that are the common operations buttons. The lower half of the
dialog box contains three boxes that provide references and
other expression elements for building expressions.

Expression Builder

References and other


expression elemenls

(Cont.)

Tiile #289-450
160
In Practice: Creating a Calculated Field

Step by Step Entering the Expression:


(continued)
5 Double-click: ffi Tahle*

Notice: A directory tree of all the W&A database table objects


appears.

ffi Order Detail*


Notice: The field names for the Order Details table appear in the
center box.

Double-click: the Quantity field name


Notice: the Order Details table name and the Quantity field name
are entered in the Expression Builder box. Both names are enclosed
in square brackets and an exclamation mark is between them. This
indicates that Quantity field is a field in the Order Details table.

8 Click: ffi the multiplication button


Notice: The multiplication sign is added to the expression in the
Exp re ssio n B u i lder box.

the UnitPrice field name


Notice: The Order Details table name and the UnitPrice field name
are added to the expression in the Expression Builder box. Both
names are enclosed in square brackets. The expression now reads
"Multiply the Quantity field in the Order Details table by the UnitPrice
field in the Order Details table."

-
IOrder Detail*l![Quantity] [Order Details]![UnitPricel

10 Choose: tl
ry
Notice: The expression is partially visible in the field cellto the
right of the UnitPrice field.

tTnter;l
Notice: Access names the new field "Expr|." Following the new
fietd name is a colon and then the expression in brackets"

(Cont.)
Title #289-450
161
In Pructice: Creating u Calculsted Field

Step by Step Naming the Calculated Field:


(continued)
12 Higntignt: thefield name "Expr1" only (do not include the expression
in brackets)
13 Type: Total
Notice: This is the new name for the field that calculates the total price
for each order.

Setting a Field Propefi:

14 Click: ffi tfre Properties button


Notice: The Field Properties sheet for the Total field appears.

15 Click: in the right side of the Format property box


Click here
l,
lF,$tHit'ti1
h

Notice: A list of date, time, and number formats appears with an


example of each.

Format
property
box eneral Date :6/19/34 5:34
Long Date Sunday.June ,
Medium Date 19Jun-94
Short Date 6/19/94
Format types
Long Time i5:34:23 PM
Medium Time 5:34 PM ,
Short Time ]7:34 .
GeneralNumber 3456.789

16 Type: G
Notice: The list scrolls to the Currency selection, and currency is
entered in the Format property box.

17 Close: the Field Properties sheet


1B Choose: File, Save As...

19 Type: Orders dTotal Price t-EfierTl

(Cont.)

t62
n Practice: Creating a Calculsted F,

Step by Step Viewing the Dynaset:


(continued)
20 Click: ffi tn" Datasheet View button
Notice: A Total field is added. lt calculates the total price for each
order.

!qi $Zo!o i

9i $-FQ.7! j
.. "gi $ffi0n l
70.Copol.-a-J,e.Dy_pemo.. Si . $.s]*ru..l
^ .
gi
i7,A_clqaflging Sell .. $_8.3,Qp.__
4j C-o,1pg1are C-ggrpu11iggJlo11 Dy''111gmicq 1l $45.50
26 The Power oI Myth $52 50

21 Close: the Select Query window

Tips and ffiilmE$-.rffiffi, &,:tantt,ffi'.[haqe$]ii'.1vffie iffidt,,ep$ r:iiil.i$i:efI$uffi$ifid$iiiirf #.(


make changes to the fields inCtuAeA in a calculated field the calcllated field will:;be,.updatqd to
Techniques reflect those changes. :
Lesson Twelve

Additional Exercises
After performing the skills in this lesson, you may want some additional practice. Below are some sugges-
tions for activities you can.try on your computer, along with some questions to check your comprehension of
the material covered in the lesson.

ACTIVITIES TO TRY:
1. Open a new Select Query Design window

2. Add a table to the Select Query window.

3. Add at least two fields to the QBE grid.

4. View the dynaset.


5. Return to the Select Query Design window, apply a sort to one of the fields and view the new dynaset.

6. Open the W&A Order Details query in Design view'

7. Speciff a new criterion for the Quantity field and view the dynaset.

8. Return to the Select Query Design view.

9. Add the UnitPrice field to the QBE grid, specify a criterion, and hide the field.

10. View the dynaset.

OUESTIONS:
1. How do dynasets differ from tables?

2. How does setting a sort in the QBE grid make viewing the dynaset easier?

3. List two ways to add a table to the QBE grid.

4. What is the Expression Builder used for?

5. How do you prevent a field in the QBE grid from being displayed in the dynaset?

6. Why would you specify a criterion for a field in the QBE grid?

7. Give one example of why you would set criteria for a hidden field.

t64

Vous aimerez peut-être aussi