Anda di halaman 1dari 11

Create an Address Book in Microsoft Access

At the end of this session you will be able to:



Make a table for your data
Make a form for easy entry of data
Make mailing labels from your data
Query your data by zip code
Perform a mail merge with Word using your data

Create a Table

We are going to create a very simple database to use for creating mailing labels and
performing a mail merge. The core of all databases are the tables. A table is a location
to store your data. Since you will use a form to enter your data, queries to retrieve your
data, and reports to print your data, you do not need to worry about formatting or sorting
a table. However, you do need to identify each cell of the table and its properties.

1. Open Access
2. Choose Blank Access Database
3. Choose where you
want to save your file
(in this case the 3
Floppy Drive) and
give the database a
name: Address Book
4. Under objects select
TABLE and choose
Create table in Design view by double clicking on it.
5. A blank sheet for naming your fields appears.
It is a good idea to always have a unique number to identify each record in a
field. This especially becomes important when you are going to have several
tables connected by links. This unique number is called a primary key. It could
be an automatic number, our Unique ID numbers, a program number, etc. as
long as NO OTHER ITEM can be identified by that number.
1

6. To set our primary key type AutoNumber under Field
Name
7. Under Data Type use the drop down arrow and
choose AutoNumber. This will automatically assign a
number to each entry in your database.
8. Highlight the first row by clicking once in the gray box
to the left of the Field Name column.
9. Click on the yellow key icon on the toolbar. This sets
this field as the primary key.
10. We are going to continue to enter field names and data types as follows:

Title Text
First Name Text
Last Name Text
Address Text
City Text
State Text
Zip Code Text

11. Now lets save the table. Click on the save icon on the tool bar or go to
File>Save As and name the table tblAddresses.
12. Now lets set up the table with some restrictions and automatic entries to keep
our database clean and save us time when entering information.
13. Highlight the City field by clicking the gray box to the left of City in the Field Name
column.
14. At the bottom left of the
screen is a box with two
tabs: General and Lookup.
Click in the Default Value
box under the General tab
and type Durham.

This will mean that Durham will
automatically populate this field. If
you need to type another city you
simply type over the Durham (well
do this in our form).
2
15. Lets do the same thing for State. For the default value put NC.
16. Under field size (top of the General tab) we can change 50 to 2. Thus, no matter
what the state, we will always be forced to enter the 2-letter abbreviation.
17. Now lets work on Zip Code. Here, you can change the field size from 50 to 5
OR you can enter an input mask.
NOTE: Not all machines are being set up with the input masks installed. If you
need an input mask send a work order to IS.
18. Click in the Input Mask box
and then click on the 3 dots that
appear next to the box.
19. If you are asked to save
the table, answer yes.
20. The input mask wizard
will appear.
21. Choose Zip Code from
the list.
22. You can test it in the
Try It: box. If you make
an error typing in the
code, you will see the
same error message
that you would see if
you were actually
entering the information
into the table or form.
23. Hit Next. You dont
need to change
anything in the next
box, so hit next again.
24. In this box, choose if you want a hyphen to separate the 5 + 4, or if you want all
the text to run
together. Since we
are going to use the
table to make
mailing labels lets
choose the hyphen.
3
25. On the last box, click Finish.
26. We are ready to save our table again by clicking on the save icon.
27. If, at this point, you wanted to type an entry onto your table you can toggle from
design view to datasheet view by clicking the icon at the top left corner of the
toolbar. this icon puts you in datasheet view and this icon puts you in
design view.
28. Lets close the table (File>Close or click the lower x in the right hand corner) and
make a form that will make it easier to enter information.

Create a Form
1. Click on Forms under Objects and
double click on Create form by
using wizard.




2. Here you choose the
table or query you want
to use to make the form.
We only have one
choice tblAddresses.
3. We also need to say
what items we want to
appear on our form. We
want them all, so click
on the double arrow
pointing to the right.
(you can also move one
item over at a time with
the single arrow pointing
to the right OR remove
the AutoNumber with
the single arrow pointing to
the left.
4. Click Next.
5. Next, choose a layout for your form. You can click on each choice to get a
sample view. I personally always stick with Columnar, but this is probably
personal preference.
4
6. Click Next.
7. Next pick a form styleagain
this is personal preference.
Click on them all to see your
choices.
8. Click Next
9. Finally, you will give your
form a name: frmAddresses.



10. Since we are ready to view
our form, leave the Open the
form to view or enter
information selected.
11. Click Finish.
12. When your form appears,
notice that Durham and NC
are already in their fields.
13. Go ahead and enter your own
address. You can use Enter
or Tab to move to the next
field. If you need to go
backwards, use Shift + Tab.
14. Notice that you can type over
Durham and NC with different information, if you need to. However, if that
information is correct simply Tab through it.
15. You do not need to save after you enter information. Access automatically
keeps data entries. You only save changes in the design of the database itself.
16. Go ahead and close this entire database (not just the form).

Create Mailing Labels
To save data entry time, I have created a database with lots of names and addresses
already entered for you.

1. From your floppy disk open the database called ClassMail
2. Notice that we have a table named tblAddresses and a form named
frmAddresses
5
3. Now we are going to create a REPORT of mailing labels for the tblAddresses
table.
4. Select Reports under Objects and
then click on the button that says
New.





5. In the New Report box choose Label
Wizard and in the drop down box
choose tblAddresses as the table
where the data is to create the
labels.
6. The label wizard will appear.
7. Make any needed changes and
choose Next.






8.
Make sure English is
picked.
Choose your
label.
Avery labels
are the most
common.
6

8. On the next screen choose the font, font size, font weight, and font color.
9. Click Next.
10. Using the arrow
pointing to the
right, select each
item you want to
print on your label.
REMEMBER, you
have to insert
spaces and
punctuation.
Access does not
assume where you want spaces, commas, enters, etc. to go.
11. When you are done, it should look like the Prototype label above.
12. Click Next.
13. The next screen
allows you to sort
your labels by a
certain field. Most
often, we would
want to sort by zip
code. This helps
the post office
deliver our mail
soonerespecially
if it is bulk mail!

14. On the final screen you can click FINISH and a print preview of your labels will
appear.
15. To print the labels, put the label sheets in your printer and click the printer icon
(or go to File> Print) at the top left of your screen.

Create a Query
Suppose you want to print labels only for the 27704 zip codes. You can create a query!
1. Under Objects select Query and double click on Create Query by using Wizard
2. In the first step select all the items except the AutoNumber (remember, you can
choose them one at a time with the single arrow or select all with the double
arrow and the move AutoNumber back)
3. Click Next
7
4. At this step you can
create the table you want
to use for your query.
We only have one table,
and it is already
selected. Change the
name to qry27704.
5. Check the button to
modify the query design.




6. In the design view of the query you can set Criteria. In this case we want to see
only the addresses with at 27704* zip code. We are doing this because some
of our zip codes have the +4 and some do not. The * is a wild card (just like in
SAP/R3).
7. Type 27704*in the Zip Code column and Criteria Row (it will change to Like
27704* after you hit enter)
8. Use the red exclamation point on your tool bar to run your query (see the
results).

Now, you can run a new label report using this query and only print labels for 27704.
Give it a try!
Some notes about setting criteria:
If you type criteria on the same row it is like saying AND. For instance, the query
below reads Who are all the people who are Mr.s AND who live in a 27704 zip
code?
8
If you type criteria in different rows, it is like saying OR. For instance, the query
below reads Who are all the people named Henderson OR who live in 27704?

Here are some examples of ways to specify criteria

= Equal to
<> Not equal to
> Greater than
< Less than
>= Greater than or equal to
<= Less than or equal to
>K Text that begins with a letter that is greater than
K (ie-L-Z)
<>C All words except those starting with C (not equal
to C)
sm* Text that begins with sm
s*d Text that starts with s and ends with d
s?s Three letter text that starts with s and ends with
s
[hint
phrase]
The query will prompt you to enter the criteria
you want when you run the query

Lets try that last example.
1. Create a query with the following criteria:



9
2. Name the query qryPrompt (if you ran through the wizard without changing the
name you can rename the query by right clicking on it and choosing Rename).
3. Run the qryPrompt by double clicking on it in the list of queries.
4. When prompted, enter 27705- (you need the dash since we set ours up for zip + 4.
5. View your results.

Note: If you make a report for labels using qryPrompt you will be asked to enter the zip
code every time you run that report.

Perform a Mail Merge Using an Access database

1. Open the word document ltrMailMerge
2. Go to Tools>Mail Merge
3. In the first step go to Create>Form Letters
4. Select the Active window box since we have our letter open in the active window
5. In step 2 click on Get Data and Choose Open Data
Source
6. Browse to where your Access Database is saved
(for class the 3 floppy drive). Be sure to change
the Files of type: to MS Access Databases or All
Files, otherwise, you wont see your database.
7. Highlight the database and click OK
8. Next you will see a box that will let you choose the
table or query for your mail merge. We are going
to use the table tblAddresses.

9. Click on the
Edit Main
Document
button.

10
10. It is now time to insert your merge fields. This is a layout for where you want the
names and addresses to go. Put them exactly where you want them to appear in
your letters. You must insert all spaces and punctuation yourself.
It should look like this when finished:


Go here to insert
merge fields.


11. Go to Tools>Mail Merge and in Step 3 click Merge.
12. On the box that appears, click Merge again.
13. View and /or print your letters.







11

Anda mungkin juga menyukai