Vous êtes sur la page 1sur 148

1

Tutorial:
Access 2007
Access 2007 is the database application in the Microsoft Office 2007 suite. Get
Access help designing an Access database and sorting and filtering records, among
other tasks.

Understanding Database
Concepts
1 Why Do I Need a Database?

2 Exploring an Access Database

3 Thinking about Database Design

Building the Database


4 Setting up Tables and Fields

5 Building Table Relationships

6 Entering and Editing Data in Tables

7 Creating and Using Forms

8 Making Forms More Usable with Controls

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
2

9 Making Forms Attractive

Analyzing and Reporting Data

10 Sorting Records

11 Filtering Records

12 Using Queries to Make Data Meaningful - Part 1

13 Using Queries to Make Data Meaningful - Part 2

14 Using Reports to Make Data Meaningful to Others

Extras

Quiz

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
3

Access 2007:
Why Do I Need a Database?
INTRODUCTION
WHY DO I NEED A DATABASE?
What is a database?
Why not use Excel?
EXCEL EXAMPLE: CUSTOMER LIST AND ORDER TRACKING
Sorting and filtering to locate data in Excel
Data entry in Excel
ACCESS EXAMPLE: CUSTOMERS AND ORDERS TRACKING
Entering data in Access
CHALLENGE!

Introduction

Access 2007 is a program that allows you


to create and manage databases. A database is a place
where you can store information related to a specific topic.
How you intend to use the information will determine whether
you need an Access database or a different program to create
and manage your data.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
4

In this lesson, we will discuss what a database does and how


to decide whether you need a database to manage your
information.

Why do I need a database?


Watch the video! (6:03min)

What is a database?
A database allows you to store information related to a
specific topic in an organized way. In addition to storing data,
you can sort, extract, and summarize information related to
the data. One of the software programs that allows you to do
this is Microsoft Office Access 2007, which is a database
creation and management program.

Why not use Excel?


There are many types of data you may need to store and
managetext and numbers, for example. Depending on what
you want your data to do for you, you may or may not need to

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
5

use a database. You might be able to use a spreadsheet


program like Microsoft Excel. How do you know which data
can be adequately managed with Excel and which data requires
Access to manage it more efficiently? It depends on how much
data you have to manage and what you want your data to do
for you. Let's try to answer this by looking at a bookstore
scenario.

If you work for a bookstore business, you might have to keep


track of your customers and their orders. You could
use Microsoft Excel to store and manage this type of data;
however, Excel is a spreadsheet software program that is
traditionally used to manage numerical information, like
totaling up all purchases by one customer. While it can do an
adequate job of storing some types of text-based datalike a
customer's name and contact informationit's not really what
Excel was designed to do.

The examples on the following pages will show you why an


Access database may be a better choice for the bookstore
business.

Excel example: Customer list and


order tracking

Sorting and filtering to locate data in Excel


In Excel, you can store your data in a worksheet so you can
mail promotional information to an entire list or sort to find
specific customers to target mail. You can even filter customer
information to display all of the customers who live in a
particular state, like in the following image. Additionally, you
can sort data to order it in a particular way.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
6

However, if you want to see very specific results in your data


like how many orders a single customer placed in a year
Excel is not as efficient as Access at providing you with that
data.

Data entry in Excel


If you use an Excel spreadsheet to track your orders, each time
a customer places an order you would have to enter a new row
of information in the spreadsheet. This would likely include the
customer's name and address. If that customer orders from
your company more than once, information would have to be
entered each time. Your spreadsheet would
contain redundant information.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
7

As you can see in the image above, customers Tonya


Bullock and McKenzie Grant each placed several orders on
different days and for different books. Their customer contact
information was entered every time they placed an order. This
is the limitation of spreadsheet software such as
Excel because it is a single, flat file.

Access example: Customers and


orders tracking

Entering data in Access


Microsoft Access is designed to manage information. Access
allows you to enter a client's name, address, and phone
number the first time a customer places an order.

This information is entered into an Access table, which is


designed to hold basic customer information on clients.
A table is a list of related information in columns and rows. In a
table, each row is called a record, and each column is called
a field. An Access table in Datasheet view looks similar to an
Excel spreadsheet, as you can see below.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
8

In addition to the table with customer information, you would


probably also want a table with information about the products
you sell and another table to hold data related to specific
customer orders. These tables would be linked together to help
you make the most of your data.

Access is called a relational database


management program because the tables are linked
or relatedas you can see in the image below.

In this example, the Customer Info and Orders tables are linked
by Customer ID and Book ID.

Now, let's assume that you want to identify the book that was
most popular in the state of North Carolina. With Access, this is
possible because you can search and retrieve information from
multiple tables at the same time.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
9

The Customer Info table contains information about each


state, while the Order Info table includes information about
which books were ordered. You will need information from both
tables to identify the book that was most popular in a specific
state.

You could look at the information in these tables separately to


answer your question of which book was most popular in North
Carolina. In the Customer Info table, you could see all of the
customers from a specific state: NC. And in the Books table,
you can see all of the books you have in stock. The real
power of Access comes in being able to link and extract
information from multiple tables to answer specific
questions.

As you can see below, the results of your specific question


or queryare displayed for you.

Challenge!
Try to answer these questions:

What is a database?
What type of software program is Microsoft Excel?
What type of software program is Microsoft Access?

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
10

What are at least two differences between Access and


Excel?

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
11

Access 2007:
Exploring an Access Database

INTRODUCTION
EXPLORING DATABASES
Databases in our lives
Think about it
GETTING STARTED WITH ACCESS
OPENING A DATABASE
To view templates included with Access
To open an existing database
THE ACCESS WINDOW
The Ribbon
The Quick Access toolbar
The Microsoft Office button
The navigation pane
To open and close the navigation pane
PARTS OF A DATABASE
To change how objects are ordered in the navigation pane

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
12

Introduction

Once you have determined that an Access database will help


you store and manage your data, you will need to learn
the parts of a database, how to start using Access, and how
to navigate the Access window. In this lesson, we will
provide a basic overview of Access, including the parts of a
database and common tasks you can complete using a
database.

Exploring databases
Watch the video! (Part 1) (5:16min) (Part 2) (3:26min)

Databases in our lives


Think about all of the information we encounter on a typical
day that might be organized by a database. For example, if
you go shopping at a department store for a toaster, the store
inventory of products is information that must be stored
somewhere, along with the price of each product.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
13

When you make a purchase, the store needs to be able to store


the sales information to determine the daily sales total and how
to track the decrease in inventory. A database could store this
information, and it could also allow the store to quickly
determine how many Brand X toasters are in inventory without
needing to count inventory on the shelves.

While this information could be managed without a database, it


would be easier and more efficient to use one. Databases have
an enormous impact in almost every area of our lives.

Think about it
Think about what is going on around you in everyday
situations and whether there might be a database at work.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
14

Grocery store: The grocery store is stocked with items.


Items must be ordered, shipped, and stocked in the store.
The store must pay for the items. When a customer buys
items, the cash register retrieves prices and the customer
pays for products. Where might databases be involved in
this situation?
Restaurant: Where does the food come from? How does
management know when to reorder a product? How are
bills paid?
Traffic lights: Who or what controls when the lights turn
red or green?
A database maintains order and structure in our lives.
Databases are created using programs such as Microsoft
Access 2007, which is a relational database program.

Getting started with Access


When you start Access 2007, you will see the Getting
Started window.

In the left pane, the template categoriesincluding the


featured local templatesare listed, as well as the categories
on Office Online. Templates are prebuilt databases focused
on a specific task that you can download and use immediately.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
15

In the example below, the featured templates are selected,


and the template options are displayed in the center area of
the screen. Featured templates include database template
options that are available online, as well as templates that are
available as part of the local version of Access.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
16

Opening a database
You have three main options on the Getting Started page. You
can open a template database stored locally or online, an
existing database, or a blank database.

To view templates included with Access:


Click Local Templates in the left pane. The center of
the screen will change to display icons for the templates.
Select an icon in the center of the screen. Details about
the database template will appear on the right.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
17

In the left pane of the Getting Started window, you will see a
list of categories for the templates available on Office Online.
You must have an Internet connection to download these
database templates.

The Blank Database command allows you to create a


database from scratch.

To open an existing database:


In the Open Recent Database section, double-click the
file name of the database you want to open. It will appear
in the window.

OR
Click the More link. A dialog box will appear.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
18

Select the database you want to open.

Click Open. The database will appear.

The Access window


Before you can begin to use a database, you need to become
familiar with the Access window.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
19

The Ribbon
Like other software in the Microsoft Office 2007 suite, Access
2007 has a tabbed Ribbon system you use to navigate the
database. The Ribbon is organized into tabs. Each tab
contains groups of commands you use to perform tasks in
Access.

For example, on the Home tab you'll see that there is


a Font group that contains font formatting commands such
as font type, size, color, and alignment. Unless you use
keyboard shortcuts for everything, the Ribbon is how you get
work done in Access.

The Quick Access toolbar

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
20

Once you are familiar with Access, you may find that there are
commands you use more often than others. To make it easier to
use these commands, you can add them to the Quick Access
toolbar. By default, the toolbar appears above the Ribbon on
the left side of the Access window and includes the Save, Undo,
and Redo commands.

The Microsoft Office button


The Microsoft Office button is located in the upper-left
corner of the Access window and includes key menu options
such as New, Save, and Print. From this menu, you can also
change your Access Options.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
21

The navigation pane


The main control center of each Access database is
the navigation pane. It shows you what is in the database
and makes the information accessible to you. You can choose to
close the navigation pane if you need more of the Access
window to complete specific tasks.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
22

To open and close the navigation pane:


Click the Shutter Bar button on the right side of the
navigation pane.

The navigation pane appears as a single column when it


is collapsed.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
23

Parts of a database
A Microsoft Access database is made up of several components,
including tables, forms, queries, and reports. These
components are called database objects. One or more of
these objects is formed when a database is created, and all of
the objects appear in the navigation pane. To make the
database easier to navigate, beginner Access users may want
to reorder objects in the navigation pane.

To change how objects are ordered in the


navigation pane:
Click the drop-down arrow at the top of the navigation
pane to see ordering options.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
24

Select a menu option. The navigation pane will appear


reordered based on your selection.
If you are new to databases, arranging the objects by type in
the navigation pane is usually a good idea. This will group
tables, forms, queries, and reports into individual groups in the
pane.

To expand or collapse a group:


Click any downward-
pointing double arrow to expand a group so all objects
are displayed.
Click any upward-pointing double arrow to collapse a
group and hide all objects.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
25

Parts of a database
A database is made up of several components, or objects.
These objects include:

Tables
Queries
Forms
Reports
We'll look at each of these objects in more detail in later
lessons, but you can access them from the navigation
pane like you can with tables.

Tables
A table is the database object that contains the basic
information you want to store. A blue and white icon represents
the table in the navigation pane.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
26

In the Customer Info table below, there are columnsor fields


of information, including title and author. Each row is
a record containing the information specific to the fields listed.

Queries
Another database object is called a query. A query allows you
to retrieve information from one or more tables based on a
set of search conditions you define using the table fields.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
27

For example, if you want to know the name of the books that
have sold in Colorado and Kansas, you could create a query
that would retrieve information from multiple tables to
determine the answer. In this example, you would retrieve
information from the Order Info table and Books table. Queries
are covered in more detail in later lessons.

Forms
A third database object is the form. Forms are an Access tool
you can create to make data entry in database tables easier.

Entering data directly into a table can be difficult if there's a lot


of information to enter. Similar to an Excel spreadsheet, an
Access table is essentially a screen filled with blank rows where
you enter records. Forms, however, give you an easy-to-read
interface where you can enter table data. Forms are
especially useful for Access users who aren't comfortable
working with databases.

Reports
The final database object is the report. A report is an effective
way to analyze and present data using a specific layout. The
text can be formatted in an Access report, just like it can be in
Word documents.

To close an object:
Select the tab for the object you want to close. (The
highlighted tab is the active tab).
Right-click the tab, and select Close from the menu.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
28

Challenge!
See if you can answer these questions:

Where is the Ribbon in the Access window?


Where is the navigation pane located?
What is the purpose of each of the four objects in an
Access database?

Access 2007:
Thinking about Database Design
INTRODUCTION
DESIGNING A DATABASE
The Ready-2-Read bookstore scenario
Determine the purpose of the database
Plan database tables
Plan table fields
CHALLENGE!

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
29

Introduction

The first step in creating a database is to think about why you


need itwhat is its purpose? Once you know the answer, you
can begin designing your own database. Ask yourself questions
like What kinds of information will it store? How will I
have to break down this information so it can be stored
in my database? How will I use the data once it's in
there?

In this lesson, we'll walk you through the steps of database


design using a bookstore scenario. You will determine the
purpose of the database and plan the tables and fields you
will need for a simple bookstore database.

Designing a database
Watch the video! (4:22min)

The Ready-2-Read bookstore scenario


The best way to learn about designing a database is to jump
right in to the process. Let's pretend we work for the Ready-2-
Read bookstore, and we need to build a database for the store
to use. Let's think about what we might need the database to
do for us.

The following diagram shows that we have customers and


sell books via orders, both in the store and online.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
30

The store needs a way to keep track of these things.

Determine the purpose of the database


The first step of designing a database is to determine
the purpose of the database. What do we need it to do?

At Ready-2-Read, our customers will place orders for books. At


the very least, we will want our database to track
the books we sell, the customers we sell them to, and the
date of each of the orders.

The database will also be able to tell us where our customers


live when we need to send them books or coupons.
Additionally, we can use it to track our sales or to make a
bestseller list to post in the store.

Plan database tables


Once we've established its purpose, we can begin
brainstorming about how to break up the information into
the tables the database will need to store data. Recall that
a table is a collection of records, and each record is broken up
into the smallest pieces of needed information, called fields.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
31

Because we're planning a database to track our customers,


the books we have, and the orders our customers place, we
will need a table for each one of these.

TIP: Keep your database usable to others by giving your


tables simple, easy-to-understand names.

Plan table fields


Once you know what tables you need, the next step is deciding
what fields belong in each table. Remember that fields are the
smallest chunk of information in any record.

Let's look at our Ready-2-Read bookstore example again. There


will be several fields in our Customers table. We'll obviously
want each customer's first name and last name. We'll also
need an address if we need to send a customer his
order. Email will be necessary if we need to contact the
customer if there is an issue with the order.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
32

We will also need several fields in


the Books table. Title and Author make sense for books. We'll
need a Price for each book. Category will help us know what
type of books sell the best so we can order more books that fit
into this category.

The Orders table will have fewer fields. We'll need this table to
track the Customer who is placing the order, the Book the
customer is ordering, and the Date the order is placed.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
33

Don't worry if your plan doesn't include every possible field


you may need. Access lets you add fields to tables whenever
you need another one!

Challenge!
Let's imagine that you want to use a database at your new
coffee shop. Plan your database by answering the following
questions:

What would you want to track with your database?


What database tables would you need?
What fields will be in each database table?

Previous: Exploring an Access Database
Next: Setting up Tables and Fields

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
34

Access 2007:
Setting up Tables and Fields
INTRODUCTION
SETTING UP TABLES AND FIELDS
CREATING A NEW DATABASE WITH ACCESS
SETTING UP TABLES
NAMING A TABLE
To rename a table
To close a table
To open a table
ADDING MORE TABLES TO THE DATABASE
ADDING FIELDS TO A TABLE
To switch views
Adding fields in Datasheet view
Adding fields in Design view
Moving fields
Deleting fields
SETTING THE DATA TYPE FOR A FIELD
To change data type from the Ribbon

Introduction

Now that we have a handle on what the database should look


like, we need to work on setting up our tables and the fields
within these tables.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
35

In this lesson, we'll walk you through the steps of setting up a


database in Access 2007. You'll be setting up
tables according to the plan for our bookstore scenario. You'll
also be setting up the fields for each table, including
establishing what data types can be entered in a given field.

Setting up tables and fields


Watch the video! (9:23min)

Creating a new database with


Access
When you launch Access 2007, you will see the Getting
Started window.

In the left pane, the template categoriesincluding the


featured local templatesare listed, as well as the categories
on Office Online. Templates are prebuilt databases focused
on a specific task that you can download and use immediately.

You will also see the New Blank Database option, which
allows you to build your own database from scratch.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
36

When you choose the New Blank Database option at the top
of the window, you will be prompted to rename the database
from the default name, which is Database1.accdb. Rename
the database whatever you want. In the example below, we
named the database Ready2Read because it's the name of
the store in our scenario.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
37

Click Create to finish naming the database.

Setting up tables
The new database opens with one table showing as a default. It
also defaults to naming this table Table1 in both
the navigation pane and the Table tab itself. You will want to
name your tables based on your database design plan.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
38

Naming a table
To give the table a unique name, you must first click on
the Microsoft Office button in the upper-left corner of the
application.

Next, select Save from the menu. The Save As dialog box will
appear to let you save the table whatever name you want.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
39

The new table names appear in both the navigation pane and
the Table tab itself, as you can see in the picture below.

TIP: Give your tables logical, easy-to-understand names.

To rename a table:
With the table closed, right-click the Table you want to
rename in the navigation pane. Select the Rename option
that appears in the menu.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
40

The table name will be highlighted and a cursor will appear,


which means you can now type the new name right
there. Left-click anywhere outside of the table name to make
the change.

To close a table:
There are several ways to close an active table. You can right-
click the Table tab and choose Close from the menu.

A more common method is to click the X that appears in the


top-right corner of the active database object window.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
41

To open a table:
To open a table, right-click the Table name of the table you
want to open in the navigation pane, then choose Open from
the menu.

A more common method is to double-click the table name in


the navigation pane. The selected table will open in the
active database object window.

Adding more tables to the


database
By default, Access 2007 starts out with one table. To add more
tables to the database, click the Create tab on the Ribbon.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
42

Next, select Table from the Tables command group. A new


table will open in the active database object window. You must
name your table using the Save command from Microsoft
Office menu.

TIP: You can tell which table you are currently in by seeing
which table tab is highlighted.

Adding fields to a table


Access 2007 allows you to add fields to tables when you are:

Working in Datasheet view, which looks like a


spreadsheet
Working in Design view, where you are able to set more
controls for your fields
Either way, you need to know how to switch between the two
views.

To switch views:

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
43

Select the Views command group from either the Home tab
(seen below) or the Datasheet tab on the Ribbon. Select the
view option you want from the menu.

Adding fields in Datasheet view


By default, Access 2007 creates one field in each new table:
the ID field. This field auto-numbers to give each record in the
table a unique number identifier. Recall that records are the
rows in a table.

TIP: You may want to rename the ID field with a unique


name because the ID field appears automatically in every
table you create. While this is not necessary, it may help
avoid confusion when setting up table relationships.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
44

To add more fields to a table in Datasheet view, double-


click the Add New Field header.

The Add New Field text will disappear from the header. Name
the field by typing the name directly into the header. Press
the Tab key on your keyboard to move to the next field.

Adding fields in Design view


In Design view, the field names are along the lefthand column
instead of across the top like in Datasheet view, as seen below.

To add a new field to a table in Design view, click in the cell


where you want the new field and type the field name. When
you switch back to Datasheet view, your new field appears as
its own column, as seen below.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
45

In Design view, you have several field property options you


can set to ensure data can only be entered in certain
formats. Setting these options is a good idea if you want to
make sure the data you have in your database is good,
strong data.

Moving fields
If you want to rearrange the order in which your fields appear in
a table, Access 2007 lets you easily move them around. To
move a field in Datasheet view, drag and drop the field to the
location you want. To do this:

Click the field header for the field you want to move.
Move the mouse in the area of the header.
When the cross with arrows appears, hold down your left
mouse button.
With the left mouse button still held down, move the
cursor to where you want the field to appear.
Release the mouse button, and the field appears in its
new location.

Deleting fields

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
46

To delete a field in Datasheet view, click the field header,


then select Delete from the Field & Column command group.
This is found on the Datasheet tab on the Ribbon.

WARNING: You should not delete any field in a table without


first knowing what impact the deletion may have on the rest
of the database!

Setting the data type for a field


Access 2007 lets you control how data can be entered in each
table field within your database. This is done using Data Type.
The default data type is text for every field after the ID field,
which was set to auto-number. You can change the Data
Type setting in two ways:

From the Data Type & Formatting command group on


the Ribbon
From the Data Type column in Design view

To change data type from the Ribbon:


Click the field header, then select the data type you want from
the drop-down menu next to the Date Type command.

To change data type in Design view:

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
47

Click the field name, then press the Tab key on your keyboard.
From the drop-down menu under the Data Type column, select
the format you want.

The data type is more noticeable when the database is being


populated with records. It will cause data to be formatted for
currency, text, number, and date and time just like it does in
Microsoft Excel.

Challenge!
Open Access 2007 and build your own database. Then do the
following:

Give Table1 a new name.


Add a new table.
Add fields to a table.
Set the data type for a field in a table.
Open and close the tables.
Move a field in a table.
Delete a field in a table.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
48

Previous: Thinking about Database Design


Next: Building Table Relationships

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
49

Access 2007:
Building Table Relationships
INTRODUCTION
BUILDING TABLE RELATIONSHIPS
To establish a relationship between tables
To move a table that appears in the relationship map
UNDERSTANDING THE RELATIONSHIP MAP
Primary and foreign keys
RELATING TABLES
To relate tables with the drag-and-drop method
Understanding types of relationships
One-to-Many
Enforcing referential integrity
Editing existing relationships
CHALLENGE!

Introduction

By now, you've set up the tables you need for your database
and have created fields for the different
tables. Relationships provide Access 2007 with the means to
bring this information together for you when you need it.

This lesson explains how to establish relationships between


the tables in an Access 2007 database. You will learn how
to read and manipulate the relationship map. You will also

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
50

learn about primary and foreign keys, relationship types,


and referential integrity.

Building table relationships


Watch the video! (6:10min)
Download the example to work along with the video.

To establish a relationship between tables:


Click the Relationships command in
the Show/Hide group on the Database Tools tab in
the Ribbon.

NOTE: Tables must be closed in order to establish


relationships.

When the Show Table dialog box appears:


o Select each table name, then click Add for the
tables you want to relate.
o When you're done, close the Show Table dialog
box.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
51

You should now see a relationship map that contains


all of the tables that were selected.

To move a table that appears in the relationship


map:
Place your mouse over the table you want to move.
Hold down the left mouse button, then drag the table to
a new location.
Release the mouse button to drop the table in its new
place.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
52

Understanding the relationship


map
The relationship map lists all of the tables that were selected to
relate, as well as all of the fields that were previously set up for
that table. Notice that the first field has a key icon next to it.
This is the primary key for the table.

Primary and foreign keys


A primary key is the first field in each table of the database.
You may recall that this field auto-numbers by default, so every
record in the table has its own unique number to identify it.
Access uses this number to quickly pull information together
when you run queries or reports, which are covered later.

In the example above, the primary key for the Customers table
is Customer ID, the primary key for the Orders table is Order
ID, and the primary key for the Books table is Book ID.

A foreign key is a field that is the primary field in its own table
but that shows up in another table. If you look closely at the
Orders table, the fields Customer ID and Book ID appear
there, as well as in their own respective tables. These fields are
the primary key in their own tables, but in the Orders table,
they are considered foreign keys.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
53

Relating tables
There are a few ways to establish relationships between tables:

Using the Edit Relationships command located on


the Design tab of the Ribbon
Using the drag-and-drop method
Both methods give you the same end result, but the drag-and-
drop method is much easier and saves you several steps.

To relate tables with the drag-and-drop method:


Select a field name from one table by holding down the
left mouse button.

Drag the field name from one table to the other table in
the desired relationship.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
54

Drop the first field name onto the field name you want to
relate by releasing the left mouse button.
In the example above, we selected the Book ID field from
the Books table and dragged and dropped it on the Book
ID field in the Orders table.
The Edit Relationships dialog box appears.

Select the Enforce Referential Integrity option. This


option is explained in detail below.
Click Create.

Understanding types of relationships


Access 2007 allows for several different types of relationships.
These include:

One-to-One
One-to-Many
Many-to-Many
The relationship type you will come across most frequently
and the one created in our bookstore scenariois the One-to-
Many relationship.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
55

One-to-Many
The One-to-Many relationship means data for that field will
show up a single time in one table but many times in the
related table.

For example, let's look at one of the book titles in our


bookstore. The Book ID for the book should appear only once in
the Books table because this table lists every title stocked in
the store. But it will probably appear many times in the Orders
table because we hope it gets ordered by many people many
times.

The symbols for the One-to-Many relationship look like this:

Enforcing referential integrity


In the Edit Relationships dialog box, an option to Enforce
Referential Integrity appears.

You should click Enforce Referential Integrity to make sure


you never have an order for a book that doesn't appear in the
Books table. Selecting this option tells Access to check for
these things when someone is working with your data records.

Editing existing relationships

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
56

Access 2007 allows you to edit relationships that already exist.


This can be done using the Edit Relationships command on
the Ribbon. However, a much simpler way is to
simply double-click the link that appears in the relationship
map. Either method brings up the Edit Relationships dialog
box, where you can change your settings.

Challenge!
If you haven't already done so, save the sample Ready2Read
database to your computer.
Open the database, and establish a relationship between
the Books table and the Orders table using the drag-and-
drop method.
Establish a relationship between the Customers table
and the Orders table using the Edit
Relationships command on the Ribbon.
Edit an established relationship by double-clicking the
link.
Explore the options and settings in the Edit
Relationships dialog box.
Move the tables around in the relationship map.

Previous: Setting up Tables and Fields


Next: Entering and Editing Data in Tables

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
57

Access 2007:
Entering and Editing Data in Tables
INTRODUCTION
ADDING AND EDITING DATA IN TABLES
Adding records to tables
To add records in the new record row
To add records with the New Record navigation button
To add records with the New Record command
EDITING RECORDS IN TABLES
To edit a record directly
To edit a record using Find and Replace
To copy and paste a pecord
To delete a record
DATA VALIDATION
Data types and validation rules
To set data validation rules
Validation text
Using field properties to ensure data integrity
CHALLENGE!

Introduction

Access 2007 databases hold the actual


data records inside tables. You can add, edit, and delete
records directly from these tables. This lesson will show you

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
58

how to work in the tables to add new records, as well as how


to edit existing records using commands like copy and
paste and find and replace. It will also discuss the dangers
involved in deleting records from a table, as well as the
importance of setting validation rules and other field
properties to ensure data is valid.

Adding and editing data in tables


Watch the video! (10:10min)
Download the example to work along with the video.

Adding records to tables


When you enter records into your table, you
are populating the database. In Access 2007, you can do this
a few different ways.

To add records in the new record row:


Click the record row with the asterisk that appears at
the bottom of the table.

Type the data into the appropriate fields.


Hit Enter or the Tab key to move to the next field.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
59

To add records with the New Record navigation


button:
Click the New Record button in the navigation bar. The
navigation bar is located in the bottom-left corner of the
open object pane.

Type data into the appropriate fields.


Hit Enter or the Tab key to move to the next field.

To add records with the New Record command:


Click the New Record command in the Records group in
the Ribbon.

Type the data into the appropriate fields.


Hit the Enter or the Tab key to move to the next field.

Editing records in tables


Sometimes it is necessary to edit records in the database. Like
with every other task in Access 2007, this can be done several
different ways.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
60

To edit a record directly:


Scroll through the records, or use the navigation
buttons on the navigation bar to find the record to edit.

Click the cell containing the information that must be


edited. A pencil icon appears to indicate edit mode.

Type the new information into the field.


Click outside of the record row to apply the change.

To edit a record using Find and Replace:


Click the Find command in the Find group on the Ribbon.

The Find and Replace dialog box opens.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
61

Tell Access what to find by typing it into the Find


What: area.
Type the replace term in the Replace With: area.
Tell Access where to look with the Look In: drop-down
list. The first choice in the drop-down list is the field you
were last in within the table.
Tell Access what to Match: Any part of the field, the
whole field, or just the start of the field.
Tell Access how to Search: Up finds records above the
cursor, Down finds records below the cursor, and All
searches all records.
Click one of the action options:
o Find Next will find the next instance of the
word in the table.
o Replace will put the new word into the table,
overwriting what is currently there.
o Cancel stops the editing process.
CAUTION: DO NOT use Replace All because it will overwrite every
instance of the Find term in the table, which can have a serious
impact on your data.

To copy and paste a pecord:


Select the record you want to copy. Right-click, then
select Copy.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
62

Select the new record row. Right-click and select Paste.


The record information appears with a new record ID
number.

To delete a record:
Select the record you want to delete, then right-click and
select Delete Record.
A dialog box appears, telling you the action cannot be
undone and asking if you are sure you want to delete the
record.

There may be other records that rely on the record you are trying to
delete. DO NOT delete a record without knowing how it will impact
the rest of your database.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
63

When you delete a record, the record number is permanently


deleted from the database table. If you delete the last record from a
table and then add a new record, your new record numbers will
appear to be out of sequence.

Data validation
Data validation is an important database concept. It is the
process by which Access tests the data that is being entered
into the database to make sure it is in an acceptableor valid
format.

Let's say one of your database users has entered an order date
of January 4, 2008, in the month/date/year format as
01/04/2008. Another user has entered an order placed on that
same date in the day/month/year format as 04/01/2008. If the
database is tracking all sales for the month of January 2008, it
may not show both orders as placed in January, even though
both were placed on the same date.

Access 2007 allows you to set field properties and data


validation rules to force the person entering data to follow a
specific format.

Data types and validation rules


Data validation begins when data types are set during the
process of building tables and fields. For example, if a field data
type had been set to Currency and a text value is entered in
that table field during data entry, Access will not accept an
invalid format and will display a validation error, like the one
below.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
64

Data validation is accomplished by setting data validation


rules and other field properties for various fields.

To set data validation rules:


In Design view, highlight the field that requires a
validation rule.
In the Field Properties section at the bottom half of the
window, set your validation rule using the Expression
Builder. The Expression Builder offers common syntax to
set up a data validation rule.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
65

Validation rules work most easily with numerical fields. Rules


for text fields require you to enclose each acceptable value
inside its own quotation marks, separating them with Or, as
seen above.

Validation text
Validation text is a specialized error message you can set to
have Access tell the user entering data the specific way you
want that person to enter it.

To set the validation text, enter the error message exactly


as you want it to appear to users in the row directly
beneath the Validation Rule row in the Field
Properties section of Design view. For the validation rule we
set for Category, you'd set the validation text like this:

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
66

The image below shows the resulting error message users


would see when the Category validation rule has been broken.

Using field properties to ensure data integrity


Another way to ensure data integrity is by setting field
properties such as Field Size, Format, and Required.

Field Size can be set to hold a specific number of


characters, up to as many as 255 for text fields. If you
were using a text field to hold the two-letter state postal
abbreviation, the field size could be set to 2 to ensure no
one enters a full state name into this field.
The Format field property can be set to display text or
numbers in a standardized way. For example, text can be
set to show as all uppercase, and numbers can be set to
show scientific numbers, percentages, or decimals.
Set the Required property to Yes if you want users
entering data to be required to enter something in the

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
67

field. Choose No if users are allowed to leave the field


blank.
These are just some ways Access helps you ensure data being
entered into your database is valid.

Challenge!
If you haven't already done so, save the sample Ready2Read
database to your computer.
Open the database, and add records using the New
Record navigation button.
Add a record using the New Record command in the
Ribbon.
Edit a record using the Find and Replace command.
Copy and paste a record in one of the tables.
Set a validation rule and validation text for a field in one
of your tables, then break the rule when entering data to
read the resulting message.

Previous: Building Table Relationships


Next: Creating and Using Forms

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
68

Access 2007:
Creating and Using Forms
INTRODUCTION
CREATING AND USING FORMS
Why use forms?
CREATING A FORM
To create a form using the Form command
USING FORMS TO ENTER DATA
To add a record using a form
To edit records using a form
CREATING A DROP-DOWN LIST
To create a drop-down list using a Combo Box control
CHALLENGE!

Introduction

Another way to populate a database is


with the use of forms. An Access 2007 form helps you know
exactly what data to enter. In this lesson, we'll address
the benefits of using forms with a database, and we'll show
you how to set up a basic form for your Access 2007
database, as well as how to use the form to populate or edit
data in the database. You'll also learn how to enhance a basic
form with a drop-down list.

Creating and using forms

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
69

Watch the video! (Part 1) (3:18min) (Part 2) (6:35min)


Download the example to work along with the video.

Why use forms?


In real life, a form is piece of paper you fill out so someone can
collect and keep track of specific information about you. Only
one recordyour recordis captured with any given paper
form.

Access 2007 forms work in a similar way.

In previous lessons, you saw that you can populate a database


by entering records into the tables themselves. If the database
has hundreds of records and many fields to populate for any
given record, a table can be overwhelming to a user entering
data. An Access form lets you enter data one record at a
time, without having to see the entire table.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
70

An Access 2007 form also lets you know exactly what


information to enter and can even tell you what that
information should look like. Adding certain control components
to a formlike a drop-down menucan dramatically increase
the integrity of the data that is held in a database.

A database owner wants to control the levels of access other


database users have to the data; the fewer the amount of
people who are interacting with the data, the lower the chances
are of the data becoming compromised. Forms are one more
way a database owner can limit the actions of other users.
Form properties can be set so users can only enter records or
just view records.

Creating a form
Access 2007 has several automatic tools for creating forms.
These tools are located in the Forms group on the Create tab
in the Ribbon, as seen below:

Access 2007 forms tools include:

The Form command makes a basic form, showing a


single record at a time.
The Split Form command creates a form showing one
record on top and includes the Datasheet view of the
entire source table on the bottom.
The Multiple Items command creates a form that
shows all records at once, which looks similar to the
source table in Datasheet view.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
71

The Form Wizard is hidden under the More


Forms command. It walks you through the process of
creating more customized forms.

To create a form using the Form command:


The basic Form command is the one we suggest because it
allows you to see just one record at a time. It also includes all
of the fields in your source table for you, and you can modify
the layout of the basic form to hide fields or add controls:

Begin by highlighting the table you want to use as a


source table.
With the source table highlighted, select
the Form command from the Forms command group in
the Create tab on the Ribbon.
The new form is created and opens in the object pane.

The newly created form has the same name as the source
table by default. You can give the form a new name by
saving the form. You will be prompted to give the form a
name.

Using forms to enter data


Populating a database is easy once you have a basic form in
place. Record navigation works the same way for forms as it
does for tables. The navigation bar is located in the bottom-
left of the object pane. The navigation buttons work the
same way as they do for tables. The picture below shows the
navigation buttons for a form.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
72

To add a record using a form:


Navigate to a new record, either by using the New
Record navigation button or by using the New command
in the Records group on the Ribbon.
Add the new data.
Save the record.

Your data must be entered using an acceptable format. The


acceptable formats were established when the field
properties were set.

Save by using either the Save command on the Ribbon or


by progressing to another record using the New (Blank)
Record navigation button. Moving to a new record saves the
most recently entered record. However, it may be necessary

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
73

to refresh the table in Datasheet view to see the newest


record.

To edit records using a form:


Just like in a table, database users can edit records from a form
using the Find and Replace command. This command works
exactly the same way in a form as it does in a table.

Creating a drop-down list


Using a drop-down list on a form can increase the integrity of
the data in the database because drop-down lists force form
users to select one of the preset options in the list to populate
the field. These types of form controls are relatively easy to set
up using the Combo Box.

To create a drop-down list using a Combo Box


control:
With the form opened in Design view, select the Combo
Box command in the Controls group on the Design tab
in the Ribbon.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
74

Drag and drop the combo box sizing tool to create the
combo box where you want it to be on the form.

The Combo Box Wizard appears.

Choose the desired option from the wizard, and


click Next.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
75

Because the middle option was selected in the example


above, the wizard progresses to the next step, which asks
for the values to be typed into a small table.

Next, the wizard asks what to do with the entered values.


Access can either remember the values for later use, or it
can populate a field with the entered values. Use the
drop-down list to select which field Access should use to
store the values.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
76

Once the desired option has been selected, click Next.


Finally, the wizard gives the combo box a generic name,
which can be meaningful to you later if there's ever a
need to adjust the properties of this or another combo
box. If you want, give the combo box a name, then
click Finish.

Whatever name is entered will appear as a label on the


form. This label can be deleted if you want.

Switch to Form view to see how the combo box works. The
Category drop-down list appears on the Books form, as seen in
the image below.

Challenge!
If you haven't already done so, save the sample Ready2Read
database to your computer.
Scroll through the customer records using
the Customers form.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
77

Create a basic Books form using the Form command.


Use the new Books form to enter and save the following
data:
o Title: The Secret Streets of Savannah
Author: Amy Little
Category: Travel
Price: $34.99
o Title: Cars and Trucks
Author: Jonathon Bradley
Category: Kids
Price: $14.99
Using the Combo Box command, create a drop-down list
on the Books form for the following categories:
o Fiction
o Nonfiction
o Kids
o History
o Technology
o Home & Garden
o Travel
o Food
Add another record to the database using the Books
form with the drop-down category selector.
Use the Find and Replace command to change the
price of all books that are $14.99 to $16.99.

Previous: Entering and Editing Data in Tables


Next: Making Forms More Usable with Controls

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
78

Access 2007:
Making Forms More Usable with
Controls
INTRODUCTION
MAKING FORMS MORE USABLE
Making forms more useable
SETTING FORM PROPERTIES
To set form properties
HIDING FIELDS ON A FORM
To hide a field on a form
CREATING COMBO BOXES
SETTING FIELD PROPERTIES
To set field properties from a form in Design view
To set a field to auto-fill with the current date
CREATING COMMAND BUTTONS
To add a command button to a form
CHALLENGE!

Introduction

You've already seen how a combo


box control can make a form more user friendly. In Access
2007, there are several additional ways you can modify forms
to make them easier to use while also increasing the integrity
of the database. In this lesson, we'll explain how to use form
properties to limit the actions your form users can take. We'll

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
79

also walk you through hiding fields on a form and adding


command buttons to the form.

Making forms more usable


Watch the video! (10:04min)
Download the example to work along with the video.

Making forms more useable


You already know that forms can help you increase the integrity
of your data by limiting what you see and how you can enter
data. You saw that using a drop-down list can make data entry
easy. Now it's time to think about the design of your forms from
a form user's perspective.

Let's look at the Orders form in our bookstore scenario. The


basic form, which was created with the Form command, looks
like this:

This form is where we would want our userthe store


employeeto pair a customer with a book to complete an
order. Let's look at the form from the user's point of view:

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
80

The employee would be adding new orders, not editing


existing ones, so we'll set form properties to limit this
action.
The user will also never need to enter the Order ID
number because this is the number the database assigns
each order record to differentiate it from other orders.
We'll hide this field.
The Customer ID field and the Book ID field are not too
useful as they are because the employee would have to
know each customer's ID number and every Book ID
number to be able to enter the data in the format we
need. We'll make these fields more useable by creating
combo boxes that help users select the correct customer
and book.
Our user will not need to enter the Order Date because
we want the database to auto-populate this field in the
database using today's date. We'll set field
properties to make this happen.

Setting form properties


Access 2007 allows you to set several form properties. Form
properties are options that are set in Design view on
the Property Sheet, like the one shown below. These options
control how the form looks, works, and interacts with the rest of
the database.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
81

To set form properties:


View the form in Design view.
Select the Property Sheet command from
the Tools group on the Ribbon, as seen above.

Note: The form Property Sheet is also accessible


by right-clicking anywhere on the form in Design
view and selecting Properties from the menu.

When the property sheet opens:


o Make sure Form is selected in the Selection
type drop-down list.
o Set the desired form properties.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
82

Tip: Use the tabs to find the specific property you want to
set. Use the help available to you in the bottom-left corner of
the Access window to know what each property setting does.

Hiding fields on a form


There will be times when a field will not be needed on a form.
Access 2007 allows you to hide fields by setting
the Visible field property in Design view.

To hide a field on a form:


In Design view, open the Property Sheet.
Change the Visible property setting to No, as seen
below.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
83

Switch to Form view to verify that the field is hidden.

Creating combo boxes


For the New Orders form in our bookstore example, we
created user-friendly drop-down lists using the Combo
Box command. These drop-down lists help our users identify a
specific customer and specific book using more useful
information than the Customer ID and Book ID numbers, as
seen below.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
84

For more information on creating combo boxes, visit this


lesson.

Setting field properties


Sometimes it may be necessary to set field properties from the
form itself. For example, on the New Orders form for our
bookstore shown below, we want to set up the Order
Date field to auto-fill with the current date each time an order
is entered. This way, our employees will not have to worry
about entering a date on the form because the form will do it
for them.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
85

To set field properties from a form in Design


view:
Highlight the appropriate field on the form.
Open the Property Sheet.
Verify that the Field Name appears in the Selection
type drop-down list.
Set the desired field property.
In our example, we want to set the Order Date field to auto-fill
with the current date. Refer to the picture below. Notice that we
have the Order Date field highlighted on the form itself. On
the Property Sheet, we have Order Date showing in
the Selection type drop-down list.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
86

Because we want the Order Date to auto-fill, we must set the


default value to always enter the current date.

To set a field to auto-fill with the current date:


Open the Data tab on the field's Property Sheet.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
87

Set the Default Value property by clicking on


the Expression Builder button.
Use Expression Builder to enter the expression for the
current date. It looks like the image below.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
88

The Expression Builder contains many


commonly used expressions for database
functions. Explore them by clicking the various
files in the lefthand column.

Creating command buttons


Another way to make a form more user friendly is by
adding command buttons to the form. Command buttons are
a quick way for form users to take a specific action. These
command buttons are grouped into categories of actions,
including:

Record Navigation command buttons, which easily


allow users to move among the records in your database
Record Operation command buttons, which let users
do things like save and print records

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
89

Form Operation command buttons, which let users


quickly open or close a form, print the current form, and
perform other actions
Report Operation command buttons, which offer users
a quick way to do things such as preview or mail a report

To add a command button to a form:


Click the Button command in the Controls group on the
Ribbon.

When the Command Button Wizard opens:


o Select the type of command you want from
the Categories list.
o Select the specific action you want the command
button to perform from the Actions list.
o Click Next.

In the next wizard step:

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
90

o If you want text to appear on the button, enter it in


the Text box.
o If you want a picture to appear on the button, select
one using the Browse button.
o Click Next.

In the next wizard step:


o Give the button a meaningful name. Note: Access
will give your button a default name. Renaming it with
a more useful name may help later if you have several
buttons on a form and want to change the properties of
one.

o Click Finish.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
91

The command button should be operational and appear on the


form in Form view.

Challenge!
If you haven't already done so, save the sample Ready2Read
database to your computer.
Open the Orders Form, and change the form properties
so it limits users to adding records only.
Hide the Order ID and Order Date fields.
Set the Order Date field property to have a Default
Value of the current date.
Create drop-down lists for the Customer ID and Book
ID fields, making sure they contain helpful information for
users and correctly populate the database with ID
numbers.
Add a command button to the form.

Previous: Creating and Using Forms


Next: Making Forms Attractive

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
92

Access 2007:
Making Forms Attractive
INTRODUCTION
MAKING FORMS MORE ATTRACTIVE
Making forms more attractive
To switch to Layout view
ADDING A LOGO
To replace the icon with a logo
APPLYING A STYLE WITH AUTOFORMAT
To apply an AutoFormat
WORKING WITH TITLES
To change the form title
CHANGING TEXT ON THE FORM
To modify text
WORKING WITH OBJECTS ON A FORM
To move objects on a form
To resize objects on a form
To apply a border to objects on a form
CHALLENGE!

Introduction

Now that you know how to make forms


work better, it's time to think about what a form looks like. In
this lesson, we'll address the various ways to modify a form
layout, including how to add a logo and apply an Auto

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
93

Format to the form. We'll also cover using and formatting


titles, as well as moving and applying borders to objects.

Making forms more attractive


Watch the video! (3:34min)
Download the example to work along with the video.

Making forms more attractive


Because others will be using the forms in your database to
enter data, you may want to make the forms more visually
appealing. These types of changes are done to the form
in Layout view.

In Layout view, you see the form as it will appear to the user in
Form view, so it's useful for setting the size of controls and
other objects on the form, as well as for changing the font,
colors, and borders on the form.

To switch to Layout view:


There are three ways you can open the form in Layout view.

Right-click the Form tab or the form name in the object


list, then select Layout View from the list.
Select Layout aView in the Views group on the Ribbon.
Click the Layout view icon in the bottom-right corner of
the Access 2007 window.

Adding a logo
Access 2007 automatically puts a form icon, like the one below,
in the header area of every form you create.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
94

One way to customize the look of your forms is to remove the


icon and replace it with a logo. This is easy to do using
the Logo command.

To replace the icon with a logo:


Delete the form icon.
Select the Logo command from the Controls group on
the Ribbon.

Use the Insert Picture dialog box to locate the picture


file you want to use as the logo, then click OK. The new
logo should appear.

You can move and resize the logo as well. Moving and
resizing objects on a form is covered later in this lesson.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
95

Applying a style with AutoFormat


Another simple way to dramatically change the way your form
looks is to apply a style with the AutoFormat command. You
could modify the color for each part of the form on your own,
but Access has already combined colors in several attractive
styles. These styles are available under the AutoFormat
command.

To apply an AutoFormat:
Click the AutoFormat command on the Ribbon.
Select the desired format. The change will appear when
the mouse button is released.

Working with titles


One of the easiest things to change on the form is the title,
which appears in the form header with the icon or logo.

To change the form title:

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
96

Click the Title command in the Controls group on the


Ribbon.

When the title highlight appears, type the new title, then
hit the Enter key on your keyboard.

Note: The title does not affect the name of the form, and
vice versa.

Changing text on the form


Access, like all Microsoft Office 2007 products, allows you to
change the font style, text size, text color, and alignment. It
also lets you apply bold, italics, or underline to the text. All of
this is done from the Ribbon, as seen in the diagram below.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
97

To modify text:
Highlight the text.
Apply the desired format by doing one or more of the
following:
o Select the desired font style from the font
face drop-down list.
o Set the size of the text using the font
size selection list.
o Choose a color for the text using the font
color selector.
o Apply either the bold, italics, or underline style.

Additional text formatting options are available in


the Font group. The above list includes the most common
text modifications.

Working with objects on a form


Other ways to modify the way a form looks in Access 2007
include resizing and repositioning the objects that appear on

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
98

the form, and applying borders to objects on the form. All of


these tasks are easily done in Layout view.

To move objects on a form:


Highlight the object by clicking it.
Move the object by dragging and dropping it in a new
location.

To resize objects on a form:


Highlight the object by clicking it.
When the crosshair cursor appears, hold down the left
mouse button and drag the edge to the preferred size.
Release the mouse button to apply the change.

To apply a border to objects on a form:


Highlight the object by clicking it.
Select a width using the Line Width command.
Select a style using the Line Style command.
Select a color using the Line Color command.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
99

Challenge!
If you haven't already done so, save the sample Ready2Read
database to your computer.
Open the Orders Form in Layout view and change the
form by:
o Adding a picture using the Logo command
o Giving the form a new title
o Modifying some text on the form
o Applying one of the AutoFormat options
o Moving or resizing an object on the form
o Applying a border to an object on the form

Previous: Making Forms More Usable with Controls


Next: Sorting Records

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
100

Access 2007:
Sorting Records
INTRODUCTION
SORTING RECORDS
Sorting records
SORTING ON TEXT VALUES
To sort based on a text value
SORTING ON NUMERICAL VALUES
To sort based on a numerical value
To clear a sort
CHALLENGE!

Introduction

Once a database is populated, it's time to


think about how to look ator analyzethe data. One basic
way to analyze data is to sort it. Sorting data is easy with
Access 2007. In this lesson, we'll show you how to sort text-
based and numerical data using common sorting
commands, as well as how to clear sorts.

Sorting records
/var/www/apps/conversion/tmp/scratch_3/350338943.docx
101

Watch the video! (3:34min)


Download the example to work along with the video.

Sorting records
Sorting is probably the simplest way to look at data because it
keeps similar things together. In our bookstore database, for
example, we could sort our data a few ways:

We could sort orders based on the order date.


We could sort customers by the state in which they live
or by their zip codes.
We could sort our books by author, category, or price.
Access 2007 allows you to sort the records in your database
tables based on a field or value that is either textlike an
author's last nameor numericallike a customer's zip code or
a book's price. Depending on the type of value, Access offers
different sorting options.

Sorting on text values


When Access 2007 sorts on a text value, it offers the two
options described in the table below:

Sort
Option Also Called Description
Values closest to A are
A to Z Ascending displayed first
Values closest to Z are
Z to A Descending displayed first

To sort based on a text value:


Click the drop-down arrow at the top of the field you
want to sort.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
102

When the menu appears, select either the Sort A to


Z or the Sort Z to A option.
o With A to Z, the records will be sorted based on the
chosen field's value with the value closest to A at the
top of the table, as seen below.

o With Z to A, the records will be sorted the using the


chosen field's value with the value closest to Z at the
top of the table.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
103

The sort command section in the Sort group on


the Ribbon is another way to begin a sort.

Sorting on numerical values


Access 2007 also offers two options when sorting based on a
numerical value. These options are described in the table
below:

Also
Sort Option Called Description
Smallest to Values closest to 1 are
Largest Ascending displayed first
Largest to Descendin Values farthest from 1 are
Smallest g displayed first

To sort based on a numerical value:


Click the drop-down arrow at the top of the field you
want to sort.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
104

When the menu appears, select either the Lowest to


Highest or the Largest to Smallest option.
o With Smallest to Largest, records will be sorted
based on the chosen field's value, with the value
closest to 1 at the top of the table.
o With Highest to Lowest, records will be sorted the
using the chosen field's value, with the value farthest
from 1 at the top of the table, as seen below.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
105

The sort commands in the Sort & Filter group on


the Ribbon can also be use to begin a sort.

To clear a sort:
o Click the Clear Sort command in the Sort &
Filter group on the Ribbon.

Challenge!
If you haven't already done so, save the sample Ready2Read
database to your computer.
Open the Customers table and the Books table.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
106

Sort the Last Name field in the Customers table from Z


to A.
Sort the Books table according to Price using
the Lowest to Highest option.
Clear your sorts.

Previous: Making Forms Attractive


Next: Filtering Records

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
107

Access 2007:
Filtering Records
INTRODUCTION
FILTERING RECORDS
Filtering records
FILTERING BY FIELD
To use the Filter by Field feature
To toggle between filtered and unfiltered results
FILTERING BY SELECTION
To use the Filter by Selection feature
SORTING OR FILTERING THE FILTERED RESULTS
USING ADVANCED FILTERS
To apply an Advanced Filter
To save the Advanced Filter
CHALLENGE!

Introduction

Another useful way to look ator analyze


the data in a database is by filtering it. Filtering groups your
data together based on one or more criteria for a given field,
then displays only the records that contain those specified
values and criteria. Filtering data is easy with Access 2007. In
this lesson, we'll show you how to filter records using
common filter commands. You'll also learn how to use the

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
108

toggle button to switch between filtered and unfiltered


results, as well as how to perform advanced filters and save
the filtered results.

Filtering records
Watch the video! (7:10min)
Download the example to work along with the video.

Filtering records
When you tell Access 2007 to filter your records, you are asking
it to:

Search all of the records in one table


Find every record in that table that meets the criteria you
set
Display the results for you in the table by hiding records
that do not meet the criteria
You can filter data using what Microsoft calls the Filter by
Field and Filter by Selection methods. Additionally, Access
2007 can perform an Advanced Filter, which is essentially a
small query that is run on only one table. These options are
described in the table below.

Method Description
Lists all of the values that have been
entered in a specified field so you can
choose which value or values you want
Filter by Field Access to find
Filter by Offers the ability to search records based
Selection on the value that is currently selected in
a table; you can ask it to find records
that:
Equal the value
Do not equal the value

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
109

Contain the value


Do not contain the value
Advanced Narrows filtered results further by
Filter performing additional filters or sorts

Filtering by field
When you Filter by Field, Access 2007 finds all of the values
that have been entered in the specified field. Access lists all of
these values for you so you can choose which value or values
you want Access to find for you within that field. Once you
choose which value to filter by, Access returns the results to
you as a subset of records in the table.

To use the Filter by Field feature:


Highlight the column for the field you want to use as a
filter. In the example below, we are filtering using
the State field.
In the Sort & Filter group on the Ribbon, click
the Filter command (it looks like a funnel).

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
110

When the dialog box appears, select the value you want
to use as the filter value:
o Checking Select All will return every record in the
table. However, clicking this option when all values are
checked will clear the selections.
o Checking Blank will find only records in which the
field is empty.
o Check as many of the values as you want to see
returned in your results.
Click OK.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
111

The results will appear in the table. In the example above, the
results are showing all records for customers living in North
Carolina (NC). Notice that all other records are hidden from
view but that the table name is still Customers.

To toggle between filtered and unfiltered results:


As with most actions in Access, you can toggle between your
filtered results and unfiltered tables in a variety of ways:

Use the label that appears in the navigation bar, as seen


above
Use the Toggle Filter button on the Ribbon

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
112

Filtering by selection
When you Filter by Selection, Access 2007 returns the results
to you as a subset of records in the table. It assumes that your
current selection is what you want to use as your filter value, or
criteria.

To use the Filter by Selection feature:


Place your cursor in the cell that contains the value you
want to use as your filter value.
Click the Selection command in the Sort &
Filter group on the Ribbon.
When the list appears, choose one of the options:
o Equals will return all records that have exactly the
same value as your selected value. In the example
below, this option would return records for the City of
Raleigh only.
o Does Not Equal will return every record that does
not have the same value as your selected value. In the
example below, this option would return all
records except for the ones with Raleigh as a city.
o Contains will return every value that has your
selected value somewhere in it. In the example below,
choosing Contains would return records with a City
value of Raleigh, Caraleigh, or Raleighville.
o Does Not Contain will not return records with the
selected value anywhere within the search field. In the
example below, clicking Does Not Contain would
return all records except for records that have Raleigh
in the city nameRaleigh, North Raleigh, and
Raleighville, for example, would not show up in the
results.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
113

Sorting or filtering the filtered


results
Access 2007 lets you narrow the filtered results further by
applying another level of sorting or filtering. To do this:

In the table showing your filtered results, select the field


or value you want to use as the basis for a deeper sort or
filter.
Apply the additional filter or sort.
Another way to do this is to use the Advanced
Filter command.

Using advanced filters


An Advanced Filter is similar to a multilevel sort in Microsoft
Excel. An Advanced Filter can help you further narrow your
records. This is like running a miniature query on only one
table. It uses a screen that's similar to the query design screen,
and it can even save your results as a query so you can use
them again later.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
114

To apply an Advanced Filter:


o Click the Advanced command in the Sort &
Filter group on the Ribbon.
o From the menu that opens, select
the Advanced Filter/Sort option.
o The design screen will open so you can set up
your filter criteria and/or sorting order for the
various fields in the table.

o To sort or filter another field, drag the field name


from the table at the top of the screen to the
design portion of the screen in the bottom half of
the window. Then:
o To sort the new field:
o Click in the Sort cell for the
field.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
115

o Choose the sort option you


want to use from the drop-down list
that appears.
o To filter the new field:
o Click in the Criteria cell for the
field.
o Enter your criteria by directly
typing it into the cell. Access will put
quotation marks around your criteria,
showing that it is searching for that exact
value.

Important: Access will perform the sorts left to right,


according to the way they are displayed on the Advanced
Filter design screen. Once all of the sorts are complete,
Access will perform filter functions. Similar to sorts, Access
filters from left to right based on the order displayed on the
Advanced Filter design screen.

To view the results, click the Toggle Filter button on the


Ribbon.

Your filtered results will appear in a new table. You can save the
advanced filter so you can run it again later if you want.

To save the Advanced Filter:


Right-click the Advanced Filter design tab.
Select Save.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
116

If the Save as Query dialog box comes up, you must


give the advanced filter a name.
This dialog box will only appear the first time you save.

Access 2007 saves Advanced Filters as queries because they


are simple queries run on only one table.

Challenge!
If you haven't already done so, save the sample Ready2Read
database to your computer.
Use the Filter by Field method to filter
the Customers table to find all customers from NC.
Use the Filter by Selection method to filter
the Customers table, looking for all NC customers NOT in
Raleigh.
Hint: Use the Does Not Equal option.
Practice toggling between the filtered results and the
unfiltered tables.
Apply an Advanced Filter on the Books table to find all
of the Kids books, sorted by price with the highest price
first.
Save your Advanced Filter with whatever name you
choose.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
117

Previous: Sorting Records


Next: Using Queries to Make Data Meaningful - Part 1

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
118

Access 2007:
Using Queries to Make Data
Meaningful - Part 1
INTRODUCTION
USING QUERIES: PART 1
Using queries
PLANNING A QUERY
Planning: Which customers ordered technology books?
USING THE QUERY DESIGN COMMAND
To build a query using the Query Design command
HIDING FIELDS OR OTHER INFORMATION IN THE RESULTS
To hide part of the query result
SAVING THE QUERY
To save a query
CHALLENGE!

Introduction

The real power of an Access 2007


database lies in its ability to pull data for quick analysis, which
is what happens when you run a query. Queries allow you to
retrieve information from one or more tables based on a set of
search conditions you define. Access 2007 will display your

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
119

results in their own table, which you can then further analyze
and manipulate. In this lesson, we'll explain how to plan a
query using a three-question planning process. You'll also learn
how to use the Query Design command to run a query, as
well as how to modify the query to hide fields or other
information in your query results. Finally, you'll learn how
to save the query for later use.

Using queries: Part 1


Watch the video! (5:22min)
Download the example to work along with the video.

Using queries
Queries retrieve information from one or more tables based on
a set of search conditions you set up and then combine that
information in a way that's easy for you to analyze. If you've
used an Advanced Filter in Access 2007, then you've already
run a basic query on only one table. If you want to pull data
from more than one table, though, you'll need to use either
the Query Design command or the Query Wizard.

Before using the Access 2007 query tools, it's important to plan
out the query using a logical process. Otherwise, you may not
get the results you expect.

Planning a query
There are three questions you need to answer when planning a
query:

What do you want the results to look like? Identify


every bit of informationor fieldyou want included in
the results.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
120

Where is the information stored in the


database? List which tablesand/or querieshold the
information you want to see.
What conditions do you want the data to
meet? This helps determine how to set the criteria so
Access can search the records properly.

Planning: Which customers ordered technology


books?
Let's think about this process for our bookstore database
scenario. We have a new technology series coming out soon,
and we want to send coupons to customers who have ordered
technology books from us in the past. A query can help us
answer the question, Which customers have ordered
technology books from us already? Let's use the three-
question process to plan this query.

What fields do we want to see in the results? We


need a list of customer names and addresses in order to
mail the coupons to our customers, so we'll need the
results to show the categories below:

In which tables is the information stored? For this


query, we'll need:

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
121

o The Customers table to get customers' names and


addresses
o The Books table to know which books are
technology books
o The Orders table to know which customers ordered
those books
What is the condition we want the data to
meet? We want Access to look for only the books where
the book's category is technology.

Using the Query Design command


Once you've planned out your query, you can build and run it
using Access 2007's query tools.

To build a query using the Query Design


command:
Select the Query Design command from the Create tab
on the Ribbon.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
122

Use the Show Table dialog box to select which tables


and/or queries to include in the query. Our plan called for
all three tables.

Drag and drop the fields you want to see in your results
to the bottom portion of the query design screen.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
123

Enter the condition in the Criteria row for the condition


field. For our query, we typed Technology in the cell
labeled Criteria for the Category field. As seen above,
Access 2007 puts quotation marks around the term to
show that it is looking for exactly that term within the
designated field.
Once the condition is set, click Run! in
the Results group on the Ribbon.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
124

View your results to determine if they match your


desired results.

Hiding fields or other information


in the results
Sometimes the results of a query will include information that is
seemingly unnecessary to you. Access 2007 allows you to
easily hide these fields.

To hide part of the query result:


In the query design window, deselect the Show option
by clicking it.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
125

When you run your results, the field you chose will be
hidden, as seen below.

Saving the query

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
126

Sometimes you will not need to save your results or your query
design, and other times you may want to keep it to run again
later or to modify it slightly. Saving a query is easy to do.

To save a query:
Right-click the Query tab.
When the Save As dialog box opens, give your query a
meaningful name.

Click OK.
The query will now be listed in the object list on the left
side of the Access window.

Challenge!
If you haven't already done so, save the sample Ready2Read
database to your computer.
Plan a query to find out which customers order a certain
category of books.
Use the Query Design command to set up the query.
Run the query, and view your results.
Save the query.
Modify the query to hide a field.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
127

Previous: Filtering Records


Next: Using Queries to Make Data Meaningf

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
128

Access 2007:
Using Queries to Make Data
Meaningful - Part 2
INTRODUCTION
USING QUERIES: PART 2
USING TOTALS IN A QUERY
USING COUNT AND GROUP BY FUNCTIONS IN A QUERY
To use the Count and Group By options in a query
SORTING AND FILTERING QUERY RESULTS
To sort via the query design
To filter via the query design
CHALLENGE!

Introduction

You already know how to plan and run a


basic query. This lesson will show you how to run a query that
includes a Totals function to group and count the records in
the results. It will also deal with ways to
further sort and filter via your query design to further refine
your results.

Using queries: Part 2


Watch the video! (4:45min)
Download the example to work along with the video.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
129

Using totals in a query


Sometimes you may want to see your query results grouped or
counted in some way. Access 2007 offers several options to
make these functions possible. Perhaps the easiest of these is
the Totals command, whose optional functions are similar to
the functions used in Microsoft Excel. These functions include:

Sum, which is used to add a column of numbers


Average, which is used to find the average of a column
of numbers
Maximum, which returns the highest value in a field
Minimum, which returns the lowest value in a field
Count, which is used to count the number of same
values in a query
One of the most useful totals functions to use in queries is
the Count function.

Using Count and Group By


functions in a query
When you use the Totals command in a query, Access will
automatically group every field by the values in each field. This
means it will look for repeating values and group like values
together so they appear as one record rather than as many
records. This is called the Group By function.

Let's use our bookstore database as an example. If we run a


query to see the information for every book that has been
ordered, we'd get a list that looks like this:

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
130

Notice that we get a record back for every order of each book
that has been ordered.

In our bookstore example query, we want to see these titles


grouped together so we see each ordered title only one time. To
do this, we use the Count and Group By options.

To use the Count and Group By options in a


query:
Click Totals in the Show/Hide group on the Ribbon.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
131

The Total row will instantly appear in the bottom portion


of the query design screen.

Click in the Totals row for the field you want to count. We
want to count the number of times the same Book
ID appears in the Orders table.
From the list of optional Totals functions, select Count.

Click Run! to see your results. Notice that each title,


author, price, and category is now listed only one time for

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
132

each book, with an extra column that indicates the


number of times the Book ID appeared in the Orders
table.

Sorting and filtering query results


Once you have the results looking how you want them, you can
sort and filter them to further narrow your results. This can be
done using the methods of sorting and filtering covered in
earlier lessons, or by applying a sort and filter in the query
design itself.

To sort via the query design:


Click the Sort row for the field you want to sort. A drop-
down list will appear:

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
133

Choose one of the options:


o Ascending will show the results sorted with the
lowest numerical value or the text value closest to A
first.
o Descending will show the results with the highest
numerical value or the text value farthest from A first.
o (not sorted) will keep your records grouped but
will not sort them.
Click Run! to see the results.

To filter via the query design:


Click the Criteria row in the query design.
Add your filter criteria by typing the value in the cell, as
in the example below:

Click Run! to see the results.

Challenge!

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
134

If you haven't already done so, save the sample Ready2Read


database to your computer.
Create a query that uses the Count and Group
By options.
Modify a query design to include a sort.
Run the query, and view your results.
Save the query.
Modify a query design to include filter criteria.
Run the query, and view your results.
Save the query.

Previous: Using Queries to Make Data Meaningful - Part 1


Next: Using Reports to Make Data Meaningfu

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
135

Access 2007:
Using Reports to Make Data
Meaningful to Others
INTRODUCTION
USING REPORTS TO MAKE DATA MEANINGFUL TO OTHERS
CREATING A REPORT BASED ON A TABLE
To create a report based on a table using the Report command
CREATING A REPORT BASED ON A QUERY
To limit the number of records in a report
GROUPING ITEMS ON A REPORT
To add grouping to a report
FORMATTING A REPORT IN LAYOUT VIEW
To delete a column or other report element
To move a column or other report element
To resize a column or other report element
To add a logo to the report
To modify the title of a report
To modify text in report headings
To apply an AutoFormat style
To change the page layout
To change the page layout options
SAVING A REPORT
To save a report
CHALLENGE!

Introduction

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
136

Now that you know how to use queries to


analyze the data in a database, it's time to find out how
to create a report that will make the data meaningful to
someone else. In this lesson, we'll show you how to create a
report using the Report command, as well as how to use
grouping options and query limits to make the report easier
to read and how to identify several report
formatting and layout options that can be set in Layout
view. Finally, you'll learn how to use Print Preview and save
the report.

Using reports to make data


meaningful to others
Watch the video! (7:07min)
Download the example to work along with the video.
As you know, queries make the data in a database meaningful
to you. Sometimes, though, you need to share that data with
someone else. A report is an effective way to present your
data using an attractive layout. The text can be formatted in an
Access report similar to how it can be done in Word documents.

Access 2007 offers tools that allow you to create and format a
report. The Report Wizard walks you through the steps of
creating a report. The Report command, however, is much
easier to use, and all of the formatting options are still available
to you in Layout view once the report is created. With these
tools, you can create a report based on a table or query.

Creating a report based on a table

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
137

One of the easiest ways to create a report is by using a table as


the source of the report. For example, in our bookstore scenario
we have a table that lists all of the books in our inventory. We
want to create a Book Price List report that lists all of the
details for each book in our store's inventory.
The Report command makes this incredibly easy because it
automatically includes every field in the source table in the
report.

To create a report based on a table using the


Report command:
Choose the table you want to use as the source of your
report. To do this, you can either open the table or
highlight the table name in the navigation pane. In our
example, we used the open Books table to create the
report.

Select the Report command on the Create tab on the


Ribbon, as seen above.
The report is automatically generated and includes every
field in the table in order of their appearance in the table.
This can be seen in the example below, which was
created from the table above.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
138

The layout and formatting of the report can be manipulated


in Layout view.

Creating a report based on a


query
Access 2007 can also create a report using a query as the
source. The process for creating a report based on a query is
identical to the process for creating a report based on a table,
which was outlined on the previous page. And just like when
making a report from a table, every field and record that
appears in the query results will appear on the report.

It's possible to limit the number of records in a report, but only


if the report was based on a query. The limit is set in the query
itself, using the query design screen.

To limit the number of records in a report:


Open the query in Design view.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
139

Use the Return option in the Query Setup command


group to set the number of records you want to see in the
query results and in the final report.

Click Run! to make sure the query results look like you
want the report to look.
Create the report using the Report command on
the Create tab.
Format the report as desired.

Grouping items on a report


Grouping items on a report can make it much more readable.
Access 2007 offers a quick and easy way to add grouping to a
report.

To add grouping to a report:


With the report open, select the Group &
Sort command from the Grouping & Totals command
group on the Format tab on the Ribbon.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
140

This opens a Group, Sort, and Total dialog box in the


lower portion of the window.

In the Group, Sort, and Total dialog box, select Add a


group.
Select the field you want to group by from the drop-down
list. We chose to group our list by Category.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
141

When you release the mouse button, the report will now
appear with items grouped. Our report is grouped
on Category now, as seen below.

The Group, Sort, and Total dialog box will remain open
until you close it.

Formatting a report in Layout view

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
142

Access 2007 opens the created report in Layout view so you


can easily make modifications. In Layout view, you can change
the look of your report in many different ways, including:

Deleting columns and other report elements


Moving and resizing columns
Adding a logo
Changing the title and other text on the report headings
Applying a report style with AutoFormat
Modifying the page layout

To delete a column or other report element


Highlight the element by clicking it.
Hit the Delete button on your keyboard.

To move a column or other report element:


Highlight the element by clicking it.
Drag and drop the element to a new location on the
report.

To resize a column or other report element:


Highlight the element by clicking it.
Drag and drop the edge of the element to the new size
on the report.

To add a logo to the report:


Click the Logo command on the Format tab on the
Ribbon.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
143

When the Insert Picture dialog box opens, find the


picture file.

Click OK.

To modify the title of a report:


Click the Title command on the Format tab on the
Ribbon.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
144

When the highlight appears, type the new title.

To modify text in report headings:


If you don't like the standard font face and size Access used to
create your report, you can modify them using common
Microsoft Office text formatting commands. You can modify the
size, font face, font color, alignment, and much more. They all
work basically the same way.

Highlight the text you want to change.


Select the formatting option you want from the lists that
appear when you click a command.

The change appears when you release the mouse


button.

To apply an AutoFormat style:


Like with forms, Access 2007 offers a variety of report styles in
the AutoFormat command. To apply a style:

Click the AutoFormat command on the Ribbon.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
145

Select a format from the drop-down list. The change is


applied instantly.

To change the page layout:


When a report is created, it opens in Layout view, like the one
in the picture below. The dotted lines are showing where the
edge of the page will be in Report view.

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
146

To change the page layout options:


Switch to Print Preview using the Views command on
the Ribbon.

Select the layout option you want to alter from the Page
Layout command group on the Ribbon.

All of the standard Microsoft page layout options are available,


including:

Page Layout
Option Description
To set the margins for narrow,
Margins wide, or normal
To select either
a portrait or landscape orienta
Orientation tion
Size To set paper size

Saving a report

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
147

When you have created and modified a report and try to close
it, Access 2007 will prompt you to name and save the report. If
you do not need this report again, you do not need to save it.
However, if you think you may want to publish it again, it is
best to save.

To save a report:
Right-click the Report tab.
Choose Save from the list that appears.
When the Save As dialog box opens, give the report a
name.

Click OK.

Challenge!
If you haven't already done so, save the sample Ready2Read
database to your computer.
Create a report based on a table.
Create a report based on query.
Modify the layout of a report by:
o Resizing or moving columns
o Deleting report elements
o Giving the report a new title
o Applying an AutoFormat style to the report
o Using groups, sorts, or totals in a report

Previous: Using Queries to Make Data Meaningful - Part 2


Return to Playlist: Access 2007

/var/www/apps/conversion/tmp/scratch_3/350338943.docx
148

/var/www/apps/conversion/tmp/scratch_3/350338943.docx

Vous aimerez peut-être aussi