Sie sind auf Seite 1von 28

Microsoft Access 2007

Module 1

http://pds.hccfl.edu/pds
Microsoft Access 2007:
Module 1
August 2007

©2007 Hillsborough Community College - Professional Development and Web Services


Hillsborough Community College - Professional Development and Web Services

The material contained in this training material is copyrighted ©2007 Hillsborough


Community College Department of Professional Development and Web Services and
may not be reproduced without express, written permission. Other trademarks, trade
names, logos, designs, brand names, and product services mentioned in this publica-
tion may be trademarks or registered trademarks of third parties.
Microsoft Access 2007 - Module I

Table of Contents
Objectives. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Database Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Database Terminology. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3
Relationships
One-to-many . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Many-to-many . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
One-to-one. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Create a New Database. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Access 2007 Tour and Features . . . . . . . . . . . . . . . . . . . . . . . 7
Create a Table in Datasheet View. . . . . . . . . . . . . . . . . . . . . . 8
Edit a Table in Design View . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Save a Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Enter Data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Use Input Mask Wizard. . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Data Type: Yes/No. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Data Type: Lookup Wizard. . . . . . . . . . . . . . . . . . . . . . . . . . 15
Insert and Delete Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Set a Primary Key . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Form Wizard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Split Form. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

i
Microsoft Access 2007 - Module I

Objectives
At the end of this training session you should be able to:
1. Understand the three types of relationships: one-to-many, many-to-
many and one-to-one;
2. Create a new database;
3. Create tables for data entry in datasheet view and design view;
4. Enter data into a table;
5. Use, understand, and set data types: text, memo, number, currency,
date/time, autonumber, yes/no, lookup wizard;
6. Insert and delete a field;
7. Create and delete a primary key;
9. Create a form using the Wizard tool;
10. Create a split form.


Hillsborough Community College - Professional Development and Web Services


Microsoft Access 2007 - Module I

Before a database is developed, plan the structure from the beginning to the end. Flow-
charting or blueprinting in advance will eliminate restructuring and/or starting from
scratch.

Questions to Ask Before Designing a Database:

1. What does the database need to do?


2. What functions need to be achieved?
3. Which objects (such as tables, forms) depend on each other?
4. What items are needed for the database?
5. Who will use the database?
6. How will the output data (report) be generated?
7. How will the database be organized?

Access Database Terminology

It is necessary to understand and be familiar with the basics of a database and its ob-
jects to create or generate information.

Table- The central framework of a database that stores data in fields (columns) and re-
cords (rows).

Query- Allows for table inquiries. A query can change, delete, add, arrange data in
tables. Also aids gathering information for forms and reports.

Form- Displays and enters data in a fitted format. Forms can also contain other nested
forms (subforms).

Report- Allows for the printing and print preview of information such as labels, lists,
form letters, invoices, summaries, display charts, etc. The user can personalize reports
by adding a logo or picture, organizing headers, details, footers, and sorting columns.

Page- Also known as Data Access Page. Allows the publication of a web page and web
access to a database. A page can be viewed and edited.

Macro- Allows for automating simple and common tasks such as opening and closing a
form, exporting data, printing data in a report, and saving data.


Hillsborough Community College - Professional Development and Web Services

When organizing and creating a data-


base, the question, "How will the ob-
jects (tables) relate?" must be asked.
1
There are three types of relationships in
Microsoft Access:
One-to-many Table 1
Many-to-many
One-to-one

One-to-many relationship
The most common type of relationship. A
record from one table (Table 1) can have
matching records in another table (Table
2
2); however, Table 2 has only one match-
ing record in Table 1. Table 2
3
Let's look at the example.
1. One Department
2 . has more than one Course,
3. yet each Course has one Department.

Many-to-many relationship
Not recommended due to problems en-
forcing referential integrity. A record from
one table (Table 1) can have many match-
ing records in another table (Table 2). Table 1
Also, a record in Table 2 can have many
matching records in Table 1. This is possi- 3
ble through the use of a third table called
a junction table. The junction table has 1 2
a primary key that consists of two fields
from Tables 1 and 2.

Let's look at the example.


1. Primary key from Inventory Details table
(tblInventDetails) Junction Table
4
2. Primary key from the equipment table
(tblEquipment)
3. One department can have several types of
equipment,
4. And each type of equipment can appear in
several departments.
Table 2


Microsoft Access 2007 - Module I

One-to-one relationship

Least common type of relationship. How-


ever, a one-to-one relationship is useful if
there are records that must be kept confi-
dential and secure. A record from one table
(Table 1) can have one single matching
record in another table (Table 2), and Table
2 can have only one single matching record 1
in Table 1.

Let's look at the example.

1. All students have one matching record in the


2
student table (tblStudents).
2 . The values are a subset of the social security
field and the student table (tblStudents).


Hillsborough Community College - Professional Development and Web Services

Create a New Database


Before creating tables and forms, creating a
general database is recommended.

1. Open Access 2007. Go to Start > All Programs


> Microsoft Office > Microsoft Office Access
2007
2. You have the option to:
A. Open a Microsoft template
B. Open a recent database
C. Open a Blank Database. For this exercise,
we will choose this option.
3. Type the file name of the database.
e.g. HCC_Employee_Data
4. Click Create.

2C

2A
2B

4

Microsoft Access 2007 - Module I

Access 2007 Tour and


Features
The top of the screen has been rearranged
in Access 2007. Instead of concealed 1 2
toolbars and commands, you have one 3
control center, called the Ribbon. The
Ribbon area includes Office Button, the
Quick Access Toolbar, tabs, groups and
commands.

Ribbon Area 4
1. Select the Office Button to access most of what
used to be under the File menu, such as Open,
Save and Print. 5
2. The Quick Access Toolbar includes buttons to
Save, Undo and Redo. You can customize this
toolbar by adding your favorite commands. Just
click the down arrow to the right of the Redo
button.
3. Tabs include Home, Create, External Data,
Database Tools and Datasheet.
Tabs, such as Table Tools will appear when you
are working on a related task.
4. Groups include related commands. For
example, the Font group includes the buttons
for font type, font size, font color, alignment,
etc.
1
5. Commands are the actual task buttons, such as
Bold, Underline, Italicize, etc.

Examples of New Features
1. Database Templates 2
2. Split Form
3. Enhanced Datasheet View
4. Memo fields support rich text
5. Attachment data type


Hillsborough Community College - Professional Development and Web Services

Create a Table In Datasheet


View
Creating a table in Datasheet View gives
you access to the field names (data
headings), data types and the actual data.
1

1. When you first open a Blank Database, a new


table is created for you. To create one yourself,
go to the Create tab. Under the Tables group,
3
select Table.
2. The default view for a new table is Datasheet
view. The first field (column) is automatically 2 4
named ID, the data type is AutoNumber and it
is the assigned Primary Key. You can delete or
edit this field, if your table does not need an ID
field. For now, let’s leave it there. We will use it
later.
5
3. Double click on Add New Field and type in the
new field name of LastName. When entering
field names, do not use spaces or punctuation.
4. Type in Smith, in the first row under the new
heading of LastName.
5. The Data Type is set to Text. If you had typed
in numbers, the data type would have been
Number.

If you need to change data types, click on


the down arrow in the box next to Data
Type to make your selection.

Go to the Data Type section in this booklet


for descriptions or hit F1 on your keyboard
for more details and help on data types.

Primary keys are not required; however,


they are needed to create relationships
between tables in a database. Primary keys
cannot be duplicated; therefore, never
use a last name, address, or a field where
information is likely to be repeated. Ideal
primary keys are employee numbers, social
security numbers, product numbers, etc.


Microsoft Access 2007 - Module I

Edit a Table In Design View


1
Creating or editing a table in Design View
gives you freedom to construct a table with
specifications for data collection. You do
not type in the actual data in this screen.
You are setting up the table structure -
field names, data types, field size, data
validation, etc.
2
1. The default view for a new table is Datasheet
view. In the Home tab>Views group, select the
Design View button to switch to Design View.
2. If prompted, save your table as
tblEmployeeInfo.
3. To add or edit fields, type in the Field Name
column. When entering field names, do not use
3
spaces or punctuation.
4
4. Under Data Type, click on the down arrow and
select an appropriate data type.
Go to the Data Type section in this booklet
for descriptions or hit F1 on your keyboard for 5
more details and help on data types.
5. You can set more specific settings for your data
6
types in Design View. For example, locate the
General tab and type 20 for the Field Size of
LastName.
Typing in 20 for the field size indicates that the
last name can be no more than 20 characters
long.
6. Type a label for the Caption.
e.g. Last Name:

Spaces and punctuation can be used for


captions. Whatever is typed in the caption
will appear in both forms and reports. If
no caption is entered, the field name will
appear instead.

Activity
Add the following fields to the table, FirstName,
MI (middle initial), Street, City, State, Zip, Exempt,
Phone and Campus. Also add the Field Size and Cap-
tion for each field name.


Hillsborough Community College - Professional Development and Web Services

Save a Table
1
Saving a table with a specific title will help 2
when organizing information, creating
queries, forms, and pages, and connecting
to other tables.

1. To save the current table, click the Save button


in the Quick Access Toolbar.
2. You can also get to a Save button through the
Office Button.
3. You can use Save As, from the Office Button to
rename the database, save a copy or to save it in
another format, such as in a previous version.

10
Microsoft Access 2007 - Module I

Enter Data into a Table


Once a table has been created, data can be
entered. 2
1. If your new table is not open, double click on its
title, in the Navigation Pane.
2. In the Home tab>Views group, select
Datasheet View. 1
3. Under FirstName, type in new data.
e.g. Sue
4. Type in data for MI, Street, City and State.

5. Click Save.

Activity
Create a new table, tblCampus. Add one field to the
table, Campus. Open the table and add the data, BR,
DAO, DM, MacDill, PC, SPC, YB.

11
Hillsborough Community College - Professional Development and Web Services

Data Types

It is important to assign appropriate data types to a field since they specify


what type of data can be entered into a field.

Data Type Description


Text Can contain any entries that do not require calcula-
tions such as addresses, social security numbers,
dates, and phone numbers. Maximum number of
characters, including spaces, is 255 characters.

Memo Long text or number entries. Use when more than


255 characters are necessary.

Number Can contain only numbers. Can be positive or nega-


tive. Used for calculations.

Currency Can contain only monetary data. Can be used in cal-


culations.

Date/Time Add date and time. 8 character default.

AutoNumber Use when sequential, random, or replication ID num-


bers are needed.

Yes/No Use when Yes/No, True/False, or On/Off are neces-


sary.

OLE Object Add objects such as Excel workbooks or Word docu-


ments that are linked or embedded.

Hyperlink Link to files, objects or web links.

Lookup Wizard Use when choosing data such as tables or a list of


values.

Attachment Can contain an attached file, such as images or doc-


uments.

12
Microsoft Access 2007 - Module I

Use Input Mask Wizard


The Input Mask Wizard allows the
designer to define the format for entering
data. In this example, a format is set for
entering a zip code. To use the input mask
wizard the table must be in Design View.

1. If you don’t have the Zip field yet, type Zip


under the Field Name column. 1 2
2. Select Text for Data Type.
3. Type Zip: for the Caption.
4. Click in the field property for Input Mask.
4 5
5. Click on the build button. The Input Mask 3
Wizard appears.
6. Select Zip Code and click on Next.
7. You can alter the mask and select a placeholder,
if you would like. When your changes are
complete, click on Next.
The underscore _ is the default placeholder
character.
8. Click on the With the symbols in mask radio 6
button.
9. Click Next and Finish. Notice that the mask is
added under Field Properties>Input Mask.

10. Now all entries in the zip code field will have to
follow this format. Go to the Datasheet View to
test out the mask.

7 8

13
Hillsborough Community College - Professional Development and Web Services

Data Type: Yes/No


Data types are used to specify what type of
data can be entered and stored into a field.

In this example, the Yes/No data type is


used for Exempt. Using the Yes/No format
is helpful for simple, clear-cut answers. You
can edit data types in either Datasheet
View or Design View. We’ll use Design
View. 1
1. If necessary, enter the Exempt field under the
Field Name column.
2. Under Data Type, click on the down arrow and
select Yes/No. 2
Go to the Datasheet View. Yes is represented by
a check and No is not checked in the Datasheet
View.
3. Select Yes, if you are prompted to save the table.
4. Select Yes, if you are prompted that you may
lose data due to the data type change.
5. Test and view the yes/no format in the Exempt
field. 3

Yes/No also represents the following: True/


False, 1/0, and On/Off.

14
Microsoft Access 2007 - Module I

Data Type: Lookup Wizard


The purpose of the Lookup Wizard is to
connect one field from one table to another
table or a list of values. Using the Lookup
Wizard is useful when choices need to be
limited.

For instance, Hillsborough Community


College has the campus location of District
Administrative Offices. If members of
the HCC community were to type District
1
Administrative Offices in a table, they
could type GK, DAO, District Administrative
Offices or some other spelling/misspelling.
Therefore, restricting the location to DAO
ensures the same information is entered.

In this example, a drop-down menu is


created by using the Lookup Wizard,
which will connect to tblCampus. 2
To use the Lookup Wizard the table must
be in Design View.

1. If necessary, type in the Field Name.


e.g. Campus
3
2. Under Data Type, click on the down arrow and
select Lookup Wizard.
3. A Lookup Wizard dialog box appears. Click on
the I want the lookup column ... radio button.
4. Click on Next. 4
5. Select the table for the lookup.
e.g. Table: tblCampus
6. Click on Next.
5

15
Hillsborough Community College - Professional Development and Web Services

7. Select the available field(s) to include by


selecting the field(s) and clicking on the single-
headed next arrow.
e.g. Campus
8. Click on Next.
7
9. Set sort order as needed and click on Next.
e.g. Campus, Ascending
10. Select Hide key column and click on Next.
11. After entering the label name for the lookup 8
column, click on Finish.
e.g. Campus
12. Click Yes to save table and create relationships.

To view the down-drop menu for the


different campuses, click on the
Datasheet View button.

To manually add a drop down menu, select


Lookup Wizard... as the Data Type. Select
I will type in the values I want and follow
the wizard.

10

Activity
Use the Lookup Wizard to connect the field name
State to a table called tblState or manually add a
lookup for State. You do not need to include every
state.
11

16
Microsoft Access 2007 - Module I

Insert and Delete Fields


After a table is created, additional field
names may to be added or deleted. 2
In this example, we are adding an
EmployeeID (employee number) field.

To insert a field into the table, go to Design 1


View.

1. Click on the row below where the field is to


appear. In this example, click on the field name
LastName.
3
2. In the TableTools/Design tab>Tools group,
click on Insert Rows.
3. Type in the Field Name and Data Type
e.g. Field Name: EmployeeID
Data Type: Text
Field Size: 7
Caption: Employee ID:
The data type is set to Text because this data
doesn’t require any calculation.
4. To delete a field name, select the row and press
the Delete Rows button in the Tools group of
the Design tab.
5. Go to Datasheet View and enter in a unique
EmployeeID for each employee.

4
In Datasheet View, the Insert command
is on the Datasheet tab, in the Fields &
Columns group.

Activity
1. Insert a field of your choice. Choose an
appropriate Data Type. Enter the Caption for your
new field.
2. Delete the Phone field.

17
Hillsborough Community College - Professional Development and Web Services

Set a Primary Key


Primary keys uniquely identify each record 2
in a table. An advantage of a primary
key is that it does not allow duplication
of information. Access does not require 3
a primary key and multiple primary keys
can be set. Select a primary key when you
need to create relationships between tables
in a database. Primary key data cannot
1
be duplicated; therefore, never use a last
name, address, or a field where information
is likely to be repeated. Ideal primary keys
are employee numbers, social security
numbers, product numbers, etc.
4
In this example, a primary key is set for
the Field Name: EmployeeID.

To set a primary key, the table must be in


Design View.

1. Click on the row selector for the field to be set


as a primary key.
e.g. EmployeeID.
2. Select the Design tab.
3. Press the Primary Key button.
4. If the there is more than one primary key,
press and hold down the Ctrl key, and click
on the row selector for other fields. With the
appropriate rows selected, press the Primary
Key button.
e.g. EmployeeID and ID.

Ideal primary keys are employee


numbers, social security numbers,
product numbers, etc.

18
Microsoft Access 2007 - Module I

Create a Form: Form Wizard


The Form Wizard is simple and easy
to use. A form is used to simply display
and enter data in a fitted format. Forms
in Access are created from tables and/or 1
queries. Forms can also contain subforms
(nested tables).

Personalize forms in Design View or


Layout View by adding a picture, header
or footer. Switch between views on the
Form Layout Tools/Format tab.

1. In the Create tab>Forms group, select More


Forms>Form Wizard.
2
2. Select the table or query for report, for example,
tblEmployeeInfo.
3. Add Available Fields to Selected Fields and 3
click on Next.
In this example, add all available fields by
clicking on the double arrow.
4. Choose a layout and click Next. In this
example, the Columnar layout is chosen.

19
Hillsborough Community College - Professional Development and Web Services

5. Select the form style and click on Next, for


example, Access 2007.
6. Give the form a title, for example,
frmEmployeeInfo. 5
7. Choose whether to Open the form to view
or enter information or Modify the form's
design, for example, Open the form to view or
enter information.
8. Click Finish.
9. The employee information form now appears.
In this example, a form was created using the
table tblEmployeeInfo. When information is
added or changed through the form, the table
tblEmployeeInfo is automatically updated.

9 7

20
Microsoft Access 2007 - Module I

Create a Form: Split Form


With some tasks, it may be helpful to view
the form and the datasheet simultaneously.

1. In the All Access Objects pane, select the


object that you would like to use for creating the
form. For example, select tblEmployeeInfo.
2. Under the Create tab>Forms group, select
Split Form.
3. You can now see a form and datasheet based on 1
tblEmployeeInfo. Data can be added, edited
and deleted from the new split form.

Activity
Create a new database and form with fields of your
choice. Use a variety of data types, such as text,
number, yes/no, date/time, currency and lookup.

21
Hillsborough Community College - Professional Development and Web Services

22

Das könnte Ihnen auch gefallen