Using Microsoft Access
Using Microsoft Access
• Address book
• Library catalogue
• Telephone directory
• Stock list
• Inventory control
• Payroll systems
• Personnel records
• Music collection catalogue
• Phone and address lists
In the exercises that will follow you will create a simple database while you learn the basic features
of Access. Later on, you will create a more complex database as you learn more advanced features in
addition to some of the principles of database theory. In these exercises it is assumed that you are
familiar with Windows use and have experience in using other applications such as Word or Excel.
Note Most of what is taught in these exercises will work fine in most versions of Access up to Access 2003.
However, some features may be missing or slightly different in older versions. Also, databases
created in newer versions of Access won’t work in some older versions. Screen shots in these
exercises are from version 2003 though there is little difference in the 2002 (XP) version.
On the top of the window you will see menus and toolbars similar to the ones found in most
applications. On the right, you will usually see the task pane which provides shortcuts to common
tasks, such as opening or creating a database (the task pane is also a feature of recent versions of
Word, Excel and other Microsoft Office applications).
4) For the file location, select (or create) and appropriate folder in your student drive. Type
Student List for the file name and click Create.
The file will be saved with a .mdb extension (for Microsoft Database).
Note Creating a database should normally only be done after a lot of planning has taken place. In the
following exercises it is assumed that the database you will create has already been well planned.
Later on we will get in to some procedures for planning a database.
Databases are made up of various objects such as tables, queries and forms. The options down the left
side will take you to the main sections of the database. The options at the top of the database window
allow you open existing database objects , modify database objects or create new
database objects .
Some older database management systems required you to create a separate file for each object in the
database. In Access, all of these database objects are contained in the same database file. The first
database object we will look at is tables.
Tables
Tables are the most important component of an Access database because tables are where all of your
information is stored. Tables in an access database are similar in many ways to Excel tables. Most
Access databases will consist of more than one related table, but the first database we will create will
be a simple, single-table database. Each table is made up of columns referred to as Fields and rows
referred to as records.
Example: A telephone book is made up of several related tables. There is the main table which
contains all of the phone listings. There are also related tables containing information such as area
codes and post codes. The following is an example of how a telephone listing may appear in a phone
book.
Field
3) The New Table dialog will appear. Select Design View from the list of options and click
OK. A new blank table will now appear in the design view (You can also click the
option in the database window to create a new table).
The table design window will look similar to the one below.
The top section of the window is where you enter the names of the fields in your table along with the
data type for each field. When you have a field name selected in the top section, the bottom section
will display properties which allow you to customise the selected field.
Text This is the default field type since it is the most commonly used. Text fields can
store any kind of text/numeric characters with a maximum of 255 characters.
This field is best suited for text or numbers that don’t require calculations (such
as phone numbers)
Memo Stores large amounts of text or numbers – up to 65,535 characters. Uses more
memory on your computer than a text field.
Number Stores only numbers. Useful for fields that may require calculations. For
numbers that don’t require calculations (such as phone numbers) you are better
off sticking with Text fields which use less space.
Date/Time For date and time information.
Currency Used for dollar amounts.
AutoNumber Automatically generates a unique number for each new record. Useful for
primary key fields.
Yes/No Fields that contain only one of two values (such as yes/no, true/false, on/off).
OLE Object For fields that need to contain an external object, such as a picture or document.
Hyperlink For links such as email and web page addresses.
Lookup Wizard… Allows the user of the table to choose a value from another related table.
Note it is not essential to provide a description for each field but it is a good idea. These descriptions can
be used to provide information for people using the database.
You can also insert a new row by right-clicking on a row and choosing Insert Rows or by clicking the
icon on the toolbar.
An AutoNumber field is the only one where you don’t need to type anything in to a record. For each
new record entered, Access will automatically place a new number in the AutoNumber field. It is
useful as a primary key field as it ensures that each record will have a unique number.
You can also set a field as a primary key by right-clicking and selecting Primary Key or by clicking
the icon on the toolbar. If you accidentally set the wrong field as a primary key, then simply select
the intended field and choose the primary key option once again to set it as the new primary key.
1) From the File menu choose Save (you can also press [Ctrl][S] or click the icon).
Note You can call the table whatever you want but it is best to choose names that describe what sort of
information the table will store. This helps when there are several tables in the database. Also, some
developers like to name tables in uppercase letters and queries in lowercase letters or use prefixes in
names to make it easy to distinguish between the two.
2) Notice that the first column is for the Student Number field and it is filled with the text
(AutoNumber). We don’t need to enter anything in this field since a student number will
be generated automatically (remember that’s what an AutoNumber field’s for) so press
[Tab] to move to the Last Name field.
3) Type Robbins as the Last Name. Notice that as soon as you enter information, a number
will appear in the Student Number column. Every record will be given a unique number. If
you delete a record, that number won’t be used again.
4) Press [Enter] after typing the name and the cursor will move to the next field.
5) Complete the rest of the fields as shown below.
Date
Student Last First
of Address Suburb Postcode State Phone Gender Mark Comment
Number Name Name
Birth
1 Robbins Mark 17- 4 Dianella 6059 WA (08)93751234 Male 78
06- Kensington
89 Ave
6) When you reach the last field (Comments) press [Enter] again to move to the next line.
As soon as you move off that row, the record will be saved. Changes to table data are saved
automatically in Access. The only time you need to save any changes yourself is when you’ve
modified the structure of a database by adding or modifying the design of objects (such as tables).
Changes to data are saved for you.
When you close the database window, you will be closing the database.
2) Close the database window by clicking the close button as shown above. If there have
been any changes to the design of the table you will be prompted to save the changes.
Table Properties
A database will often be used by a lot of different people and the person
designing it will not always be one of the users. For that reason, it is important
to ensure that the database is designed to be easy to use. A table’s fields each
have several properties that can be changed to make the table easier to use.
The properties available for each field will vary depending on data type. The
following table provides a summary of the purpose of each field property.
8) Read through the information about the different field sizes that appears in the help
window on the side of the screen. When you are finished, close the help window.
9) For our marks field we want an option that allows for decimal places but doesn’t have a
large number range. Single would be a suitable option so choose that for Field Size.
10) Click or press [Ctrl][S] to save the changes to the design of the table.
You can also create your own custom formats for any field. Remember that you can use the [F1] key
for help on creating custom formats.
4) In the Format property for the date, delete Short Date and change it to dd-mm-yy. This will
mean that the date from the example in step 3 would appear as 01-01-04.
Tip If you have a field where you want the default value to be the current date, you can use the =Date()
function. Whenever you enter a record, Access will enter the current date in that field.
When you save changes to a table design, you may see a message like the following.
This simply means that Access wants to check data that has already been entered in to the table to
make sure that it won’t conflict with any changes in the table design.
3) In the first step of the wizard, make sure the first phone number option is selected.
4) Press [Tab] to move to the Try It: box.
5) Type in your own phone number to see a sample of how the input mask will work. Notice
that the brackets and spaces are put in for you so you only need to enter the numbers.
6) Click Next to move to the next step of the wizard.
7) The top part of this step will show the code for the input mask as !\(999) 9900\ 0000. We
only want a 2 digit area code so change it to !\(99) 9900\ 0000. Leave the placeholder
character as it is and click Next.
8) For the final step, choose the first option, With the symbols in the mask, and click Finish.
9) The Input Mask property will now contain !\(99) 9900\ 0000;0;_ (remember you can press
[F1] for an explanation of what the input mask code means).
10) Enter Input masks for the following fields as shown below.
This rule will only accept dates that are earlier than Date() (which means the current date in Access).
Obviously we won’t have any students that haven’t been born yet, so any future dates entered would
be an error. Validation rules and text can let a user know when they have made an error such as that.
Note If you create a validation rule, make sure you also provide a clear validation text message. If a user
gets an error message, they’ll want to know why there’s an error.
When a field is indexed, it means that Access will keep track of what has been entered in to that
field. That means that Access will be able to find information in that field a lot quicker which speeds
up operations such as sorting, searching and querying. It is similar to the way an index in a book
allows you to find information quicker without you have to search one page at a time. It is a good
idea to index any field that is likely to be used a lot in searches and sorting.
The Duplicates OK part simply means that it will be OK to have more than one record with the same
last name in the field.
5) Change the Indexed property to Yes (Duplicates OK) for the following fields.
• First Name
• Date of Birth
• Suburb
• State
• Gender
• Mark
Note You can't index Memo, Hyperlink, or OLE Object data type fields.
As soon as you begin entering a date in the Date of Birth field, the Input Mask will appear.
5) We will test the Validation Rule by entering a date that’s not accepted. Enter a future date
such as 020809 (remember you won’t need to enter the / since the input mask puts them
in there for you). As soon as you press [Enter], the Validation Rule will recognise that the
entry is invalid and the Validation Text will appear.
6) Click OK to clear the message. You won’t be able to proceed until you enter a valid date
or press [Esc] to cancel the entry. Enter 100489 (10/04/89) for the date and press [Enter] to
proceed to the next field.
7) Enter 24 Browne Ave for the Address Field and Yokine for the Suburb field.
8) Enter 6060 for the Postcode field (notice the input mask in this field).
9) Notice that the Default Value for the State field (WA) has already been entered. To test the
Validation Rule, enter NY as the State. The Validation Text will tell you that only Australian
states can be entered.
10) Type WA for the State and press [Enter] (The Input Mask used for this field automatically
converts entered text to uppercase).
11) For the final four fields, enter the information shown below.
A form will be created automatically using the Fields and Records from your table.
You can move from one record or Field to another using your mouse or the keyboard.
To use your keyboard:
• Press ↓ or [Tab] to move to the next field and ↑ and [Shift][Tab] to move to the previous field.
• Press [Page Down] to move to the next record and [Page Up] to move to the previous record.
• Press [Ctrl][End] to move to the last record and [Ctrl][Home] to move to the first record.
• If you are already on the last record, moving to the next one will give you a blank record.
To use your mouse, click the icons at the bottom of the form.
6) After you have entered the last record, close the form. You will be prompted to save.
7) Since this was only a temporary table to use for data entry, click No.
8) Open the table and you will see the new records listed.
• In a table with a lot of records, you may not want to have to go all the way to the bottom to
add a new record.
• If you have several records to enter, it is a lot easier to check what you have just typed when
the new records are the only ones displayed.
4) When you have completed entering the records, go to the Records menu and select
Remove Filter/Sort. All 12 records will now appear.
5) Close the table (There won’t be any need to save anything unless you changed the design
of the table by doing something like adjusting column widths).
Tip A quick way of entering information in a field that is the same as information from the previous record
is to use the [Ctrl][‘] (Control apostrophe) shortcut. For example, in the above exercise, if you wanted
to add a thirteenth record that had Dianella for the suburb, you could use the shortcut since the
precious record also had Dianella for the suburb. When you were in the Suburb field, you could press
[Ctrl[‘] to enter the information from the previous record in the same field.