Microsoft Access 2000
Microsoft Access 2000
Microsoft Access 2000
General Concepts
What is a Database and what is it used for?*
The primary function of a database is to enable the user to organize and retrieve information
in a manner defined by the user.
Access
Relational database software with a graphical user interface.
Easy to get started with pre-made tables, forms, queries & reports.
Can use to create database applications by incorporating macros & modules (Visual Basic).
A Relational database consists of multiple tables linked together by at least one common
field.
Status bar
Forms
Reports
Queries
Macros
Modules
Pages
KINGSON Page 2
Tables
Tables are the heart of Access.
All data stored in tables. Fields (columns) and records (rows) intersect to form cells.
Each field contains a specific type of information such as text, number, currency, dates, etc.
Two or more tables are linked together through fields they have in common. This is done by
defining relationships.
Access creates relationships between different tables, about different but related subjects
A table should contain data about 1 topic only, e.g., not students and faculty in one.
Queries
Create a subset (dynaset) of data.
Action queries can be used to update, archive, delete, append records, etc.
Forms
Used to view, edit, and enter data. You can also enter data directly into a table. They can be
customized for convenience. Best for on-screen viewing.
Can use controls to make data entry easier and more consistent such as drop-down lists,
radio buttons, etc.
Reports
Sorted and summarized data. They can be designed to show only the data you want to
show. Best for printed materials.
Macros
Automatically carry out one or more tasks. Best for tasks that you perform often.
KINGSON Page 3
Modules
A set of procedures stored as a unit to perform an action. Written in Visual Basic.
Pages
A data access page for viewing on the Internet, or an intranet.
Datasheet allows you to enter data, sort and filter data, hide and freeze columns, etc.
Design allows you to create tables, add fields, and set and modify field properties.
Sorting
Automatically sorted by primary key (unique identifier assigned to every table)
KINGSON Page 4
Adjacent fields – Click left edge and drag
Format/Unhide to restore
Format/Unfreeze to restore
Printing datasheets
Hide and/or size columns for best view
Manipulating data
Adding records
►* for new record
KINGSON Page 5
Current record only – less distracting
Editing records
Click inside field (pencil will appear on left)
Deleting data
Within a single field, select and hit Del
You must select the same number of fields to paste into that you copied from
Finding data
Edit/Find
KINGSON Page 6
Filtering Records
Filtering Data
By Selection
By Form
Can use ‘and’ ‘or’ statements; cannot sort at the same time
Advanced Filter
Use a filtering grid to enter expressions and sort criteria; most like query grid; can
sort simultaneously, offers most flexibility.
Filter by selection
Select data you wish to look for
Filter by form
Best for simple multi-criteria
Advanced Filter/Sort
Records/Filter/Advancrd filter-Sort
File/Save as Query
KINGSON Page 7
Advanced Filter/Sort Operators
> greater than
* wildcard
Null – no value
Not like *oak* - All words that don’t have “oak” in them
KINGSON Page 8
Multiple criteria – “and” vs. “or”
If you are looking for an “and” relationship, place both criteria on same line
If you are looking for an “or” relationship, place criteria on different lines
“Or” statements can be typed together in same box (R-click for “zoom”)
Practice session
“X” to clear grid
A list of orders with freight $50 or over to Germany or Brazil sorted by amount (90 records)
Database Design
Figuring out what you need
Determine the purpose of the database. The subjects that need to be included and the facts
you need about each subject.
Determine the tables you need. Divide information into separate subjects, and have a
different table for each subject.
Determine the fields you need. Decide what information will be stored in each table. Break
the information down to its smallest logical part
Determine which field will be the unique identifier (key field). If there isn’t one (i.e. – SS#),
Access will supply one. Names are not unique, and addresses and phone numbers can
change.
Determine the relationships. Decide how the tables relate to each other. Add fields and/or
tables to help clarify these relationships.
KINGSON Page 9
You want lists of attendees by workshop, by location, by interests
You want to create mailing lists for future workshops, based on interests and/or location
4 interrelated tables
Table of workshops
Table of attendees
Table of presenters
Workshop index
W# - key field
Facility
Address 1
Address 2
City
State
Zip
Date of workshop
Attendee listings
A# - key field
Prefix
FName
LName
Phone number
Address 1
Address 2
KINGSON Page 10
City
State
Zip
Presenter listings
P# - key field
Prefix
FName
LName
Phone number
Address 1
Address 2
City
State
Zip
Presenter expenses
E# - key field
Date
Travel expenses
Food expenses
Lodging expenses
Materials expenses
Misc. expenses
KINGSON Page 11
Creating the tables
Files/New/Database/Create to start from scratch
Usually best to have Access assign one (SS#, pre-existing employee # are exceptions)
Data type – number ONLY if you perform math functions (Zip Code, phone numbers best as
text) – default is text
Description – will show in status bar – let others know what the field is for, how to enter
data, etc.
Each field created in upper grid has a set of properties defined in lower grid
Field size
Maximum number of characters an entry could be
KINGSON Page 12
Format
Displays numbers and text in a certain format, usually numeric – dates, currency.
Different formats displayed for different data types (text has none listed)
Some text formatting: < is all lowercase, > is all uppercase, @ will display “no data” when
nothing is entered
Input mask
Inserts characters that aren’t saved in data, but help the imputer format data – phone
numbers, Social Security numbers, dates
Caption
Specifies a label other than the field name
Default value
Automatically fills in a specific value – current date is most common
Validation rule
Limits data to certain restrictions
>=50
KINGSON Page 13
Validation text
Message displayed when data breaks violation rules
“Allow Zero Length” applies to text and memo only, allows a blank field to be accepted
Indexed
Speeds searches on frequently sorted or search fields
• Employee to Sales
• Each record in Sales matches only one record in Employee, but one
employee had many sales
• Student to Classes
• Pull the Key field from each table together in third table is a simple way
KINGSON Page 14
One to one – rare because it is two dimensional, can use Excel instead
Viewing relationships
Tools/Relationships
Click and drag one field to same field in different table to form relationship
“Cascade delete” will delete all records with references to that record – BE CAREFUL
Extra credit!
Can you find the table created to link two many-to-many relationship tables together?
Queries
Action queries
KINGSON Page 15
Allow you to modify data
Creating a query
Select the database
Queries/New
Design view
Tables must be connected, or all permutations will show, and your PC will crash
Specify criteria
Limits results of the query
KINGSON Page 16
In Field grid, put field names in brackets
[UnitPrice]*[Quantity]
[UnitPrice]*.25
Parameter Queries
For queries you run frequently, with different values
When someone brings up the query, it will prompt them for the variable
After save, it becomes part of the database, and will show when you hit the queries button
in the database window
KINGSON Page 17