Вы находитесь на странице: 1из 14

MS Access 2007

Create a Blank Database

A blank database is a database with nothing in it. You must create all the tables,
forms, reports, queries, and so on. If you cannot find a template that suits your
needs, create a blank database. After you create the database, Access opens to a
datasheet and makes available the tools you need to create objects. Creating
tables is the first step in building a database. You will learn more about creating
tables in the next lesson.

To create a blank database:

1. Start Access.
2. Click Blank Database.
3. Type the name you want to give your database in the File Name field.
Access will automatically append .accdb to the name.
4. Click the Browse button. The File New Database window appears.
5. Locate the folder in which you want to store your database. Note that the
name of the file appears in the File Name field.
6. Click OK.
7. Click the Create button. Access creates the database and opens a
datasheet with the Table Tools available to you.

Note the Table Tools in the upper-right portion of the Ribbon.


What is a Datasheet?
In Access, data is stored in tables. A datasheet displays the information stored in a
table in columns and rows. The columns are called fields and the rows are called
records. You can use a datasheet to create a table, enter data, retrieve data, and
perform other tasks

Creating a Table

When you click the Create button your Access 2007 screen will change to the
image below. This is the “new look” in 2007 Office. You will now see Tabs and
Ribbons that automatically appear for the area in Access on which you’re working.
Instead of a Menu Bar and drop down selections, you’ll now see these new
features. Tabs

Ribbo
n

Group
s within
When we clicked the Create button Access assumed we desired to create –
our Person database – another database – which is called a Table. You’ll notice
that at the top of the above image that the Table Tools and Datasheet Tabs
appeared to assist you. The Ribbon below these Tabs is composed of Groups of
selections you’ll use to assist you as you create your Table. We’ll be working with
these Tabs/Ribbons throughout this tutorial.
In the lower portion of the above image you’ll see selections that indicate we are
creating a new Table.

On the left of the Table Tools-Datasheet Tab/Ribbon you’ll see a View button.
Click the View button.

When you click the View button the image on the left
will appear. Since we want to create or design a new
Table, we’ll click the Design View selection.

A Save As menu screen will


appear similar to the image on the
right. Type personnel in the
Table Name: area and then click the OK button.

Your Access 2007 screen will now change again – to the image below.
We’ve enlarged the upper left corner of this image below.

Notice (in the image above) that our Table Tools Tab still appears. However,
because we are now in the Design process, the lower Tab/Ribbon has changed to
Design – to assist us with designing our Table.

In the image on the last page you will


notice that the Primary Key button is
“orange” and, in our Personnel Table,
that it is also “orange” – with a little key to
the left of ID.

In database language this is called “keying.”

Keying, or indexing, is somewhat advanced. You can get a good description by


searching in Help for Keying or Primary Key.

To “turn off” the Primary Key, click the Primary Key button. You’ll notice that they
Primary Key button is no longer “orange” and the little key is gone from the left of
ID.

If the Personnel Table image does not “fill” the screen, click-on
the small square between the “minus and the X” in the upper right
hand corner of the screen (see arrow and image on right). This will Maximize the
screen.

Notice, under the Blue Bar at the top of the Design screen there are (3) things:
Field name, Data Type, and Description

And, in the lower half of the window; Field Properties.

We’ll be creating the Field Names that make up a database. This is similar to
creating a blank personnel form (on paper) that will be "filled-in" for each employee
(Name, Address, Phone Number, etc.). The areas that will be filled in are called
Fields in a database. When you fill in all of the fields for a person, the individual
"forms" are called records in a database. There will be a record, or form, for each
employee. All the forms, together, make up a Table (database).

So let’s create a personnel database.

Significant Note: When creating a database it is always best to “break down” a


field into its “smallest parts.” For example – Name would break down into First
Name, and Last Name (you could also have Middle Initial, Title, etc.) Address
would break down into Street Address, City, State, and Zip (you could also have
Apartment Number, etc). Because we are working in Access 2007 it will be very
simple to “put the fields back together” with a few mouse clicks when we need to
do this. Trust us. This will save you a lot of time later on.
Look at the image on the right. Click-in
the area or space under Field Name
and type-in Last Name (to replace ID).
Tap Enter or click-in the area to the
right under Data Type. The cursor now
moves to the right under Data Type.
Click the down arrow under Data Type
on right (see arrow on right). Your
design screen should look like the one
on the right.

Now we’ll talk about Data Types.

Data Type

Text You may type in any alphabetical/numerical data that you desire -
up to a maximum of 255 characters. As indicated, this is a text field, so you can't
do mathematical calculations. Examples of Text data are: names, addresses,
stock numbers, room numbers, zip codes, etc.

Memo This field is for lots of text. You can have up to 32,000 characters.

Number This field is for numbers where you want to add, subtract, multiply, divide,
average, and do numerical calculations. This field can be a very large size, so
when we get to Field Properties, we'll talk about "sizing" this field so it doesn't take
up to much "space" in storage.

Date/Time Dates and Times. You may format these later, as you may desire.

Currency Dollars ($). You may format these later, as you may desire.

AutoNumber This field is an "automatic" counter that assigns a number


each time you put data into a new field.
Yes/No This is a "True/False" or "Yes/No" type of field.

OLE Object This means "Object Link Embedding" which indicates you can
insert a graphic, picture, sound, etc. Pretty neat to put a photograph in a personnel
record or a picture of an inventory item in the stock record (advanced stuff).

Since this is a simple, introductory Access tutorial, we won’t work with Hyperlinks,
Attachments, or Lookup Wizards.

We'll leave Last Name as a Text Data Type. To the right under Description you
may make any remarks you feel are appropriate to someone who may want to
know how/why you designed the field as you did.

Now notice in the lower part of the screen, under Field Properties, that a box
appeared when you selected the Text Data Type. This box is "tailored" to the Text
Data Type that you selected above. Your Field Properties should look like the one
below when you finish doing the steps indicated below.

To create relationships:

1. Close all tables and forms. (Right-click on the tab of any Object. A menu
appears. Click Close All.)
2. Activate the Database Tools tab.
3. Click the Relationships button in the Show/Hide group. The Relationships
window appears.

4. If anything appears in the relationships window, click the Clear Layout


button in the Tools group. If you are prompted, click Yes.
5. Click the Show Table button in the Relationships group. The Show Table
dialog box appears.

6. Activate the Tables tab if your relationships will be based on tables,


activate the Queries tab if your relationships will be based on queries, or activate
the Both tab if your relationships will be based on both.
7. Double-click each table or query you want to use to build a relationship.
The tables appear in the Relationships window.
8. Click the Close button to close the Show Table dialog box.
9. Drag the Primary table’s primary key over the related table’s foreign key.
After you drag the primary key to the related table’s box, the cursor changes to an
arrow. Make sure the arrow points to the foreign key. The Edit Relationships Dialog
box appears.

10. Click the Enforce Referential Integrity checkbox.


11. Click Create. Access creates a one-to-many relationship between the
tables.

12. Click the Save button on the Quick Access toolbar to save the
relationship.
Tip: After a relationship has been created between two tables, you must
delete the relationship before you can make modifications to the fields on which
the relationship is based. To delete a relationship:

1. Click the line that connects the tables.


2. Press the Delete key.

Create Form

In the previous lesson, you created an Access Table and entered three records.
However, to get the most out of Access it makes sense to create a data entry
FORM. By doing so you are making your database more user friendly. It is easier
and quicker to enter data onto a form than it is into a table, not least because you
have more control over the layout and labelling of your form. In this lesson we will
learn how to create a FORM that uses your newly created table as the DATA
SOURCE.

Create Access form

There are a number of ways to create an Access form. In this lesson we are going
to use the ACCESS FORM WIZARD.

1. Select form wizard

Open your database if it is not already open. Click the CREATE tab on the
ACCESS RIBBON and then select MORE FORMS from the forms group.

A drop down list of form types appears. You need to select FORM WIZARD from
this list.

2. Select table and fields

The Form wizard then opens as the pop up window below.


On the first page of the form wizard we select which table we are going to use as
the DATA SOURCE. Since there is only one table in this database so far, it should
already be selected for us in the TABLES/QUERIES combo box.

Underneath there is a list of the four fields in your table. You could select each field
individually by highlighting the field name and clicking the single arrow >. We can,
however, select all four just by clicking the double arrow >>. Once they have been
transfered into the right hand box they are selected. We can now click NEXT to go
to page 2 of the form wizard.

3. Form Layout
This is where we choose the FORM LAYOUT. We are going to leave this on the
default setting of COLUMNAR. Click NEXT again to move onto page three of the
form wizard.

4. Form Style
Here we select a style that from the list box. Preview a style by clicking on its
name. This step just determines how the form looks aesthetically. Once you have
selected a style to your taste, click NEXT again.

5. Form Title

This is the last stage of the wizard. Here we are going to choose the name for our
form - lets say FORM1. We are going to leave the radio button selected for OPEN
THE FORM TO ENTER OR VIEW INFORMATION

All we need to do now is click FINISH and our form should like something like this:

6. Navigate Records via Access Form

As you can see, the form opens with the first record in your original table
displayed. You can navigate through each record using the NAVIGATION
BUTTON at the bottom left of the form window.
To move to the next record click the right arrow button on the navigation control.
To move to the last record click the >| button on the navigation control. To move
backwards through the recordset use the left arrow buttons. You could edit any
record from the form, which will update the data in your table. For now, though, just
try navigating through the three records without changing any data.

7. Create New Record via Access Form

Now that you know how to move through the recordset, lets finish off by adding two
more records. To do this click the star button on the right of the navigation control.
This should bring up a blank record. Add JOE for firstname, BROWN for surname,
and 39 for age. Click the star again to bring up a new blank record, and enter SUE
MOORE 33. When you have finished click x on the form window to close.

Example for a university Database:

Вам также может понравиться