Microsoft Access Tutorial
Overview
MS Access is frequently used by small companies to create simple database solutions. Using Access, you don’t have to know too much about databases and will still be able to easily construct simple, aesthetically pleasing database solutions. This file has hyperlinks to some reference material. The bulk of the material that follows was copied from the following website: http://www.fgcu.edu/support/office2000/access
Part 1: Tables
A database is the container for the data and associated objects. Objects include tables, queries, forms, reports, macros, and modules. In Access, the “table” holds the actual data, so begin your review with basic table operations. If required, you can review the following before starting (headings are linked to an online Tutorial).
Introduction to
Tables Tables are grids that store
information in a database similar to the way an Excel worksheet stores
information in a workbook. Access provides three ways to create a table for
which there are icons in the Database Window. Double-click on the icons to
create a table.
For this class you should create
tables using the Design view only!! Create a Table in
Design View Design View will allow you to
define the fields in the table before adding any data to the datasheet. The
window is divided into two parts: a top pane for entering the field name,
data type, and an option description of the field, and a bottom pane for
specifying field properties.
Field Properties Properties for each field are
set from the bottom pane of the Design View window.
Every record in a table must
have a primary key that differentiates it from every other record in the
table. In some cases, it is only necessary to designate an existing field as
the primary key if you are certain that every record in the table will have a
different value for that particular field. A social security number is an
example of a record whose values will only appear once in a database table. Designate the primary key field
by right-clicking on the record and selection Primary Key from the
shortcut menu or select Edit|Primary Key
from the menu bar. The primary key field will be noted with a key image to
the left. To remove a primary key, repeat one of these steps. If none of the existing fields
in the table will produce unique values for every record, a separate field
must be added. Access will prompt you to create this type of field at the
beginning of the table the first time you save the table and a primary key
field has not been assigned. The field is named "ID" and the data
type is "autonumber". Since this extra
field serves no purpose to you as the user, the autonumber
type automatically updates whenever a record is added so there is no extra
work on your part. You may also choose to hide this column in the datasheet
as explained on a later page in this tutorial. Indexes Creating indexes allows Access
to query and sort records faster. To set an indexed field, select a field
that is commonly searched and change the Indexed property to Yes
(Duplicates OK) if multiple entries of the same data value are allowed or
Yes (No Duplicates) to prevent duplicates. Field Validation
Rules Validation Rules specify
requirements (change word) for the data entered in the worksheet. A
customized message can be displayed to the user when data that violates the
rule setting is entered. Click the expression builder ("...")
button at the end of the Validation Rule box to write the validation rule.
Examples of field validation rules include <> 0 to not allow
zero values in the record, and ??? to allow only all data strings three characters in length. Input Masks An input mask controls the value
of a record and sets it in a specific format. They are similar to the Format
property, but instead display the format on the datasheet before the data is
entered. For example, a telephone number field can formatted with an input
mask to accept ten digits that are automatically formatted as "(555)
123-4567". The blank field would look like (___) ___-____. An an input mask to a field by following these steps:
Adding Records Add new records to the table in
datasheet view by typing in the record beside the asterisk (*) that marks the
new record. You can also click the new record button at the bottom of the
datasheet to skip to the last empty record.
Editing Records To edit records, simply place
the cursor in the record that is to be edited and make the necessary changes.
Use the arrow keys to move through the record grid. The previous, next,
first, and last record buttons at the bottom of the datasheet are helpful in
maneuvering through the datasheet. Deleting Records Delete a record on a datasheet
by placing the cursor in any field of the record row and select Edit|Delete Record from the menu bar or
click the Delete Record button on the datasheet toolbar. Adding and
Deleting Columns Although it is best to add new
fields (displayed as columns in the datasheet) in design view because more
options are available, they can also be quickly added in datasheet view.
Highlight the column that the new column should appear to the left of by
clicking its label at the top of the datasheet and select Insert|Column
from the menu bar. Entire columns can be deleted by
placing the cursor in the column and selecting Edit|Delete
Column from the menu bar. Resizing Rows and
Columns The height of rows on a
datasheet can be changed by dragging the gray sizing line between row labels
up and down with the mouse. By changing the height on one row, the height of
all rows in the datasheet will be changed to the new value. Column width can be changed in a
similar way by dragging the sizing line between columns. Double click on the
line to have the column automatically fit to the longest value of the column.
Unlike rows, columns on a datasheet can be different widths. More exact
values can be assigned by selecting Format|Row
Height or Format|Column Width
from the menu bar. Freezing Columns Similar to freezing panes in
Excel, columns on an Access table can be frozen. This is helpful if the
datasheet has many columns and relevant data would otherwise not appear on
the screen at the same time. Freeze a column by placing the cursor in any
record in the column and select Format|Freeze
Columns from the menu bar. Select the same option to unfreeze a single
column or select Format|Unfreeze All
Columns.
Hiding Columns Columns can also be hidden from
view on the datasheet although they will not be deleted from the database. To
hide a column, place the cursor in any record in the column or highlight
multiple adjacent columns by clicking and dragging the mouse along the column
headers, and select Format|Hide Columns
from the menu bar. To show columns that have been
hidden, select Format|Unhide Columns
from the menu bar. A window displaying all of the fields in the table will be
listed with check boxes beside each field name. Check the boxes beside all
fields that should be visible on the data table and click the Close
button.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Part 2: Forms
Create Form in Design View
![[toolbox diagram]](AccessTutorial_files/image006.gif)
![[form example]](AccessTutorial_files/image007.gif)
Adding Records Using
A Form
Input data into the table by
filling out the fields of the form. Press the Tab key to move from field
to field and create a new record by clicking Tab after the last field of
the last record. A new record can also be created at any time by clicking the New
Record button
at
the bottom of the form window, or the appropriate Add Record button, If one was created for the form. Records are automatically
saved as they are entered so no additional manual saving needs to be executed.
![[Form View]](AccessTutorial_files/image009.gif)
Editing Forms
The follow points may be helpful
when modifying forms in Design View.
![[Tab Order dialog box]](AccessTutorial_files/image011.jpg)
![[formatting toolbar]](AccessTutorial_files/image012.gif)
Part 3: Queries
Queries select records from one or
more tables in a database so they can be viewed, analyzed, and sorted on a
common datasheet. The resulting collection of records, called a dynaset (short for dynamic subset), is saved as a
database object and can therefore be easily used in the future. The query will
be updated whenever the original tables are updated. Types of queries are select
queries that extract data from tables based on specified values, find
duplicate queries that display records with duplicate values for one or
more of the specified fields, and find unmatched queries display
records from one table that do not have corresponding values in a second table.
Create a Query in
Design View
Follow these steps to create a new
query in Design View:
![[New Query]](AccessTutorial_files/image014.jpg)
![[Show Table window]](AccessTutorial_files/image016.jpg)
![[Select Query window]](AccessTutorial_files/image018.jpg)
|
Query Wildcards and Expression
Operators |
|
|
Wildcard / Operator |
Explanation |
|
?
Street |
The
question mark is a wildcard that takes the place of a single letter. |
|
43th * |
The
asterisk is the wildcard that represents a number of characters. |
|
<100 |
Value
less than 100 |
|
>=1 |
Value
greater than or equal to 1 |
|
<>"FL" |
Not
equal to (all states besides |
|
Between
1 and 10 |
Numbers
between 1 and 10 |
|
Is
Null |
Finds
records with no value |
|
Like
"a*" |
All
words beginning with "a" |
|
>0
And <=10 |
All numbers
greater than 0 and less than 10 |
|
"Bob"
Or "Jane" |
Values
are Bob or Jane |
Logical OR vs. Logical
Part 4: Reports
Create in Design
View
To create a report from scratch,
select Design View from the Reports Database Window.
![[New Report window]](AccessTutorial_files/image020.gif)
![[form edit window]](AccessTutorial_files/image021.gif)
Printing Reports
Select File|Page
Setup to modify the page margins, size, orientation, and column setup.
After all changes have been made, print the report by selecting File|Print from the menu bar or click the Print
button on the toolbar.