You are on page 1of 24

Microsoft Access

Why do I need a Database?


Introduction
Access 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. 

In this lesson, we will discuss what a database does and how to decide whether you need a database to manage your
information.

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 allow you to do this
is Microsoft Office Access, which is a database creation and management program.

Why not use Excel?


There are many types of data you may need to store and manage—text and numbers, for example. Depending on what
you want your data to do for you, you may or may not need to 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 data—like a customer's name and contact information—that is
not really what Excel was designed to do.

The following examples 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.

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, that information
would have to be entered each time. Your spreadsheet would
contain redundant information. 

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.

In addition to the table with customer information, you would probably also want a table with information about the
products you sell, and a third table to hold data related to specific customer orders. These tables would be linked
together to help you make the most out of your data.
Access is called a relational database management program because the tables are linked, or related, as 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. 

The Customer Info table contains information about each state, and


the Order 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 query, are 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?
What are at least two differences between Access and Excel?
Exploring an Access Database

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
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 has to
be stored somewhere, along with the price of each
product. 

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 also allow the store to quickly
determine how many Brand X toasters
are in the inventory without needing to
count the 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.
Grocery store: The grocery store is stocked with items. Items must be ordered, shipped, and stocked in the store. The
store has to pay for the items. Then, when a customer buys the items, the cash register retrieves prices, and the
customer pays for products. Where might databases be involved in the 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 Office
Access ,, which is a relational database program.
Getting started with Access
When you start Access, you will see the Getting Started window.
In the left pane, the template categories—including the featured local
templates—are 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.

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 available as part of the local version of Access.

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 open an existing database:


1. In the Open Recent Database section, double-click the file name of the
database you wish to open. It will appear in the window.
OR
Click the More link. A dialog box will appear.

2. Select the database you wish to open.


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

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

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


there is a Font group that contains the font
formatting commands such as font type, size,
color, and alignment. Unless you use keyboard
shortcuts for everything, the Ribbon is how you
get the work done in Access.
Quick Access toolbar
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.

Microsoft Office Button


The Microsoft Office Button resides 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.

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 .

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.

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, beginning Access users may want to
reorder the objects in the Navigation Pane.

An Access database is made up of several components, or objects. These objects include:


1. Tables
2. Queries
3. Forms
4. 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.

1. Tables
A table is the database object that contains the basic information you wish to store. A blue
and white icon represents the table in the Navigation Pane.

In the Customer Info table below, there are columns, or fields, of information, including
title and author. Each row is a record that contains the information specific to the fields
listed.
2. 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.
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 table and Books table. Queries are covered in more detail in later lessons.

3. Forms
A third database object is the form. Forms are an Access tool that users can create to make data entry in database
tables easier.
Entering data directly into a table can be difficult if there is a lot of information to enter. Like an Excel spreadsheet, an
Access table is essentially a screen filled with blank rows where a user enters records.  Forms, however, provide users
with an easy-to-read interface where they can enter table data. Forms are especially useful for Access users who aren't
comfortable working with databases.

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

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?

Thinking about Database Design


The first step in creating a database is to think about why you need it—what is its purpose? Once you know that, you can
begin designing your own database. Ask yourself questions like: What kinds of information will it store? How will I have to
break that information down 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
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.

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


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

2. Plan database tables


Once you have established the purpose, you can begin brainstorming about how to
break the information up into the tables your database will need to store the 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.
Since we are 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.

3. Plan Table Fields


Once you know what tables you need, the next step is deciding what fields belong in each table.
Remember that fieldsare 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 when there is an issue with his order.

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 that category.

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

Don't worry if your plan doesn't include every possible field you may need. Access lets you add fields to tables any time
you think you need another one!

Challenge! Imagine you want to use a database at your new coffee shop. Plan your database:
What would you want to track with your database?
What database tables would you need?
What fields will be in each database table? 

Setting up Tables and Fields


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 those tables. In this lesson, we'll walk you through the steps of setting up a database in Access ,. You will
be setting up tables according to the plan for our bookstore scenario. You will also be setting up the fields for each table,
including establishing what data types can be entered in a given field.

Creating a new database with Access


When you launch Access, you will see the Getting Started window.
In the left pane, the template categories—including the featured local
templates—are 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.
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'd like. In the example
below, we named the database Ready2Read since that is the name of the store in our scenario. 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.

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.

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

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 on the Table you wish to rename in the Navigation Pane.
Select the Rename option that appears in the menu.

The table name will be highlighted and a cursor will appear, which means you can now type in
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 on the Table tab and
choose Close from the menu.

A more common method is to click


the X that appears in the upper-right
corner of the active database object
window.

To open a table
To open a table, right click the Table name of the table you wish to open in the Navigation
Pane. Next, 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, starts out with one table. To add more tables to the database, click on
the Create tab on the Ribbon.

Then, 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. Naming a Table  was addressed on page 3 of this lesson.
TIP: You can tell which table you are currently in by seeing which table tab is highlighted.
Adding fields to a table
Access, 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.

Switching views
To switch views, select the Views command group from either the Home tab
(see below) or the Datasheet tab on the Ribbon. Select the view option you
would like from the menu.

Adding fields in Datasheet View


By default, Access 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, since
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.

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 left-hand column
instead of across the top like in Datasheet View, as seen below .

To add a new field to a table in Design View, just 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.

In Design View, you have many field property options you can set to ensure that 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 , 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 on the field header for the field you wish 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 would like the field to appear.
Release the mouse button, and the field appears in its new location.

Deleting fields
To delete a field in Datasheet View, just click on 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 , 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

From the Ribbon


To change the data type from the Ribbon, click on the field header. Then, select the data type you want from the drop-
down menu next to the Date Type command.

In Design View
To change the data type in Design View, 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/time just in Microsoft Excel.

Challenge!
Open Access and build your own database:
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.
Building Table Relationships
By now, you have set up the tables you need for your database and created fields for those different
tables. Relationships provide Access with the means to bring that information together for you when you need it.  

This lesson explains how to establish relationships between the tables in an Access database. You will learn how to read
and manipulate the relationship map. You will also learn about primary and foreign keys, relationship types,
and referential integrity.

Building Table Relationships


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:


1. Select each table name, then click Add for the tables you want to relate.
2. When you are done, Close the Show Table dialog box.

You should now see a relationship map that contains all of the tables that were selected.

Moving tables in the relationship map


1. To move a table that appears in the relationship map:
2. Place your mouse over the table you want to move.
3. Hold down the left mouse button, and drag the table to a new location.
4. Release the mouse button to drop the table in its new place.

Understanding the relationship map


The relationship map lists all of the tables that were selected to relate, and all of the fields that were set up for that table
previously. 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 for you 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
isOrder 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.

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.

Relating tables with the drag-and-drop method


It is easy to relate tables from the relationship map:
1. Select a field name from one table by holding down the left mouse button. 

2. Drag the field name from the one table to the other table in the desired relationship.
3. 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
theBook ID  field in the  Orders  table.
4. The Edit Relationships dialog box appears.

5. Select the Enforce Referential Integrity option. This


option is explained in detail below.
6. Click Create.

Understanding types of relationships


Access , allows for several different types of relationships. These
include:
1. One to One
2. One to Many
3. Many to Many
The relationship type you will come across most frequently, and the one created in our bookstore scenario, is the  One to
Many relationship.
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 that book should appear only once in
the Books table because that table lists every title that we stock. 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 that we NEVER have an order for a book that doesn't appear
in our Books table. Selecting this option tells Access to check for these things when someone is working with your data
records.

Editing existing relationships


Access , 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 on 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 on your own computer.
1. Open the database, and establish a relationship between the Books table and the Orders table using the Drag
and Drop method.
2. Establish a relationship between the Customers table and the Orders table using the  Edit Relationships command
on the Ribbon.
3. Edit an established relationship by double-clicking the link.
4. Explore the options and settings in the Edit Relationships dialog box.
5. Move the tables around in the relationship map.

Entering and Editing Data in Tables


Access databases hold the actual data records inside tables. You can add, edit, and delete records directly from these
tables. This lesson will show you 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 and the importance of setting validation rules and other field properties to ensure that data is valid.

Adding records to tables


When you enter records into your table, you are populating the database. In Access ,, you can do this a few different
ways.
To add records in the new record row:
1. Click the record row with the asterisk that appears at the bottom of the table.

2. Type the data into the appropriate fields.


3. Hit 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 ,, this can be done several
different ways.

To edit a record directly:


Scroll through the records, or use the Navigation Buttons in the navigation
bar to find the record to edit.

1. Click the cell containing the information that must be edited. A pencil
icon appears to indicate edit mode.

2. Type the new information into the field.


3. Click outside of the record row to apply the change.

Data validation
Data validation is a very 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 acceptable, or valid, format.
Imagine 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 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.
Data validation is accomplished by setting data validation rules and other field properties for various fields.

Setting data validation rules


1. In Design View, highlight the field that requires a validation rule.
2. 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.
Validation rules work most easily with numeric 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 that you can set to have Access tell the person entering data the specific
way you would like that person to enter it.
To set the Validation text, enter the error message exactly as you want it to appear to your user  in the row directly
beneath the Validation Rule row in the Field Properties section of Design View. For the validation rule that we set for
Category, you would set the validation text like this:

The following image shows the resulting error message that the user would
see when the Category validation rule has been broken:

Creating and Using Forms


Another way to populate a database is with the use of forms. An Access form helps you know exactly what data to enter.
This lesson will address the benefits of using forms with a database. It will also show you how to set up a basic form for
your Access database, and will show you how to use the form to populate or edit data in the database. You will also learn
how to enhance a basic form with a drop-down list.

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 record—your record—is captured
with any given paper form.

Access forms work in very much the same 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 the person entering data. An Access
form lets you enter data one record at a time, without having to see
the entire table.

An Access 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 form—like a drop-down menu—can
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 the other users. Form properties can be set so users can only enter
records or just view records.
Creating a form
Access 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: 

The Access forms tools include:


1. The Form command makes a basic form, showing a single record at a time.
2. 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.
3. The Multiple Items command creates a form that shows all records at once, which looks similar to the source
table in Datasheet View.
4. 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.

To create a form using this command:


1. Begin by highlighting the table you wish to use as a source table.
2. With the source table highlighted, select the Form command from the Forms command group in the Create tab
on the Ribbon.
3. 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 did for tables.
The Navigation Bar is located in the bottom-left of the object pane.
The Navigation Buttons work the same way they did for the tables.
The following picture shows the navigation buttons for a form.

To add a record using a form


To add a record to the database using a form:
1. 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.
2. Then, simply add the new data.
3. Finally, you must 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
to refresh the table in Datasheet View to see the newest record.
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 number of 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 allows you to sort the records in your database tables based on a field or value that is either text (like an author's
last name) or numerical (like 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 sorts on a text value, it offers the two options described in the table below:
Sort Option Also Called Description
A to Z Ascending Values closest to A are displayed first
Z to A Descending Values closest to Z are displayed first

To sort based on a text value


To sort based on a text value:
Click the drop-down arrow at the top of the field you wish to sort.

To clear a sort
To clear your sort:
Click the Clear Sort command in the Sort & Filter group on the Ribbon.
Using Queries to Make Data Meaningful - Part 1
The real power of an Access database lies in the 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 will display your results in their own table that you can analyze and manipulate further. This lesson will
explain how to plan a query using a three-question planning process. You will learn how to use the Query
Design command to run the query, as well as how to modify the query to hide fields or other information in your query
results. Finally, it will show you how to save the query for later use.

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 is easy for you to analyze. If you have used an Advanced Filter in Access, then you have
already run a very basic query on only one table. If you want to pull data from more than one table, though, you will need
to use either the Query Design command or the Query Wizard.
Before using the Access query tools, it is 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 you are planning a query:
 What do you want the results to look like? Identify every field or bit of information that you want included in the
results.
 Where is the information stored in the database? List which tables (and/or queries) hold 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:

In which tables is the information stored? For this query, we'll need:


 Customers table—to get customers' names and addresses
 Books table—to know which books are technology books
 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 have planned out your query, you can build and run it using Access ,'s query tools.

To build a query using the Query Design command


To build and run a query using the Query Design command:
1. Select the Query Design command from the Create tab on the Ribbon.
2. 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. 

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

4. 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 , puts quotation marks around the term to show
that it is looking for exactly that term within the designated field.
5. Once the condition is set, click Run! in the Results group on the Ribbon. 

6. Finally, 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 , allows you to
easily hide these fields.

To hide part of the query result


To hide a field in your query results:
1. In the query design window, deselect the Show option by clicking on it. 

2. When you run your results, that field will be hidden, as seen below.

Saving the query


Sometimes you will not need to save your results or your query design. 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
To save the query for later use:
1. Right-click on the query tab.
2. When the Save As dialog box opens, give your query a meaningful name.

3. Click OK.
4. The query will now be listed in the object list on the left side of the Access window.
Using totals in a query
Sometimes you may want to see your query results grouped or counted in some way. Access , 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 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 that it will look for repeating values and group the like values together so they appear as one record rather than as
many records. This is called the Group By function.
Take our bookstore database for 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:

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


To include the Group By and the Count functions in a query:
1. Click on Totals in the Show/Hide group on the Ribbon.

The Total row will instantly appear in the bottom portion of the query design screen.
2. Click in the Totals row for the field you wish to count. We want to count the number of times the same Book
IDappears in the Orders table.
3. From the list of optional Totals functions, select Count.

4. Click Run! to see your results. Notice that each title, author, price, and category is now listed only one time for
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 narrow your results down even
further. This can be done using the methods of sorting and filtering covered in Lesson 10 and Lesson 11, or by applying
the sort and filter in the query design itself.

To sort via the query design


To add a Sort to any field in the query design:
1. Click on the Sort row for the field you wish to sort. A drop-down list will appear:

2. Choose one of the options:


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

To filter via the query design


To add a filter to your query design:
1. Click the Criteria row in the query design.
2. Add your filter criteria by typing the value in the cell, as we did in the following example:

3. Click Run! to see the results.


Using Reports to Make Data Meaningful to Others
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. This lesson will show you how to create a report using
the Report command. It will also show you how to use grouping options and query limits to make the report easier to
read, as well as how to identify several report formatting and layout options that can be set in Layout View. Finally, you
will see how to use Print Preview and how to save the report.

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 like it can be done in Word documents.
Access , 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


One of the easiest ways to create a report is 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


To create a report based on a table using the Report command:
1. Choose the table you wish to use as the source of your report. To do that, 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.

2. Select the Report command on the Create tab on the Ribbon, as seen above.


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

The layout and formatting of the report can be manipulated in Layout View.
Creating a report based on a query
Access , 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.

To limit the number of records in a report


It is 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 records returned in a query:


1. Open the query in Design View.
2. 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 the final report.

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

Formatting a report in Layout View: Access 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: To delete a column or other report element:
1. Highlight the element by clicking on it.
2. Hit the Delete button on your keyboard.

To move a column or other report element: To move a column or other report element:
1. Highlight the element by clicking on it.
2. Drag and drop the element to a new location on the report.

To resize a column or other report element: To resize a column or other report element:
1. Highlight the element by clicking on it.
2. Drag and drop the edge of the element to the new size on the report.
Saving a report
When you have created and modified a report and try to close it, Access 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: As with all Access objects, to save a report:
1. Right-click on the report tab.
2. Choose Save from the list that appears.
3. When the Save as dialog box opens, give the report a name.
4. Click OK.

You might also like