Title: Access
1Access
Part I
2Open a Access Database
- Blank Database
- Database Wizard
- Existing Database (last five databases saved on
the computer appear in the list box. If the file
you want does not appear select More files)
3The database window
- This window will appear after selecting the
database. Note it has the 6 database objects
each on its own tab.
4Database Tables
- Used to store data
- holds field names, field descriptions and data
for each field of each record - underlying structure for data stored in a database
5Table Selection
- Datasheet View
- Design View
- Table Wizard
- Import Table
- Link Table
6Design ViewDatabase Table
7Columns in the Table Design
- Field Name
- Data Type - 10 types that are listed in a drop
down box by clicking the arrow button on the
column - Description
8Access Data Types
- Text - any combination of alphabetic and numeric
characters, such as names, addresses, and
telephone numbers, that are not use in
calculations (default) - memo - long entries requiring multiple lines of
text, such as detailed descriptions and
performance notes
9Access Data Types
- Number - numeric values, such as the number of
items or number of days worked that might be used
in calculations - Date/Time - dates, such as date hired, and times,
such as 100 - Currency - monetary values, such as salary
10Access Data Types
- AutoNumber - numbers assigned by Access to
uniquely identify each record these values
cannot be changed, deleted, or edited - Yes/No - Single-character entry fields that are
marked when the status of the field is true (yes)
or left blank when the status is false (no)
11Access Data Types
- OLE object - fields that may be linked to an
object, such as a picture or a document - Hyperlink - fields linked to other objects, Web
pages, or documents that appear when the field
when the field is clicked. - Lookup Wizard - fields that enable you to access
a value from a table or list of values
12 Filled in Table Design
13Datasheet View
The Field Name(s)
There are no records for this Database (yet)
14Records Added to Datasheet
15Two Views
- Datasheet view - you see the field names as
column headings and records as row. View multiple
records on the screen. - Form view - forms use the fields and data that
are stored in database tables to see one record
on-screen at a time.
16Form View
17Maintenance
- Change is inevitable. You will need add, delete
modify information in your db - find, update, insert, replace, delete, sort, and
filter and query.
18Find, Filter, Query
- Query language
- format
- examples
19Query Language
- ask questions about the database
- find the records which match a certain criteria
20Find or Filter or Query
- Which one? Depends on preciseness.
- All display or filter only the record(s) that
match a specific criteria - note that there is also a FIND command in the
word processing and spreadsheet tools.
21Find
- usually used for error correction
- used in searching for a particular value in a
record. This command works the same way as it
did for the spreadsheet. - you type in the dialog box
- Find what the entry you want to find.
Depending on whether you unselected current
field, Find searches each field (in the table)
to look for a match.
22To Find Records in a DB Table
- The binoculars on the toolbar
- also can do find/replace (Edit-gtReplace)
23Find
- Find can a search criterion with text or values
anywhere in the table. This can be inexact. For
example, if you used the find command to find an
employee named Brown, the records of employees
who live in the town Brown or on the street Brown
could also be displayed.
24Filters
- A Filter is an exact match. In a filter, Access
only matches within a certain field. So in our
last example, you would tell Access to find only
NAMES (the field name) that are equal to Brown.
Thus the other Brown matches are eliminated.
25Filters
- To display (filter) only the record or records
that satisfy a criterion. - Filter by selection is the simplest type of
filter. - All you need to do is give Access an example of
the data you want by selecting the data within
the table, and then clicking the Filter by
Selection button on the Form View toolbar (the
sieve with the lighting bolt)
26Filter
- In order to have all the records once again
displayed, you remove the filter by clicking the
Remove Filter button on the form toolbar. ( the
sieve by itself icon)
27Filter/Query
- Can be saved (it is one of the 6 objects)
- multiple tables
- displays only the fields you specified
- queries can also be used to insert new values,
modify field values and perform calculations on
field values
- Not saved
- only within a single table
- displays all the fields of filtered records
- no other functions
28Database Window
Three options you can do in queries section
Queries Tab
Previously Saved queries
29Queries
- Click on tab marked Queries on the Database
Window - There are three button on this window
- Open - If a previously saved query is
highlighted, clicking this button will display
the results of this query. - Design - If a previously saved query is
highlighted, clicking this button will display
the design query window filled in with the
settings for this query. - New - An empty design query window will be
displayed
30Queries
- Note the table(s) used in the query display at
the top. - If you clicked the Design button, the table(s)
used in this saved query will be displayed. - If you clicked the New button, you will be given
the opportunity of selecting the tables through
the Show Table.
31Show Table
To add tables to the query, highlight the table
name and click Add. When finished click Close
Tables saved for this database
32Query Design Window
Back to Queries slide
33The Query Design Window
- A Window that isolates the important parts of a
query. (Design view) - Two Important parts to the Window
- Table(s) used in the query (top half)
- The Query Grid
...
34Parts of the Query Design Windowthe table(s)
used in the query
Example of a selected table to use in a query,
appears in the top half of the Query Design Window
Customers Customer Id First Name Last
Name Address
Table name
Field Names
35Parts of the Query Design Windowthe query grid
Drop down box of the Field Names from the
selected tables
36Field
- Drop down box, depends on the tables you selected
to include either when the show table dialog box
appeared (New) or from the original query
(Design) . Once selected, the fields from the
selected tables will be used in the query.
37Table
- You can select several tables for a query
operation. - Once you have selected the Field , this entry is
automatically entered by Access. Access will
enter the table name of the field you selected.
38Sort
- You have the option of sorting the matching
records - Just left click on the box and a drop down menu
will appear, - Ascending, Descending and none
- Can sort on more than one field, the first field
listed (the leftmost) is the major key. - Remember only the query is sorted not the
original table(s)
39Show
- If you want this field data to appear in the
results - An empty Show box indicates that the field data
will not appear in query results. - A checked Show box indicates that the field data
will appear in query results. - Objective remove unnecessary or duplicate fields
40Criteria
- The final part, the criteria, (the comparison),
determines how the query will do its comparisons. - Using expressions (just like Excel), combinations
of field names, constant values, arithmetic and
logic operators, you can restrict the number of
records returned by a query
41Our Question (Query)?
Who are our customers with the first name of
John? (list them alphabetically)
Customers Customer Id First Name Last
Name Address
Select the Customers database
This can be answered by a completing a Query
Design Window.
42Filled in Query Design Window to Answer our
Question
Customers Customer Id First Name Last
Name Address
Display in alphabetical order the last names of
customers with the first name of John
Field
First Name
Last Name
Table
Customers
Customers
Sort
Ascending
Show
Criteria
John
Or
43The Results
- A list will appear when the run command is
clicked, the ! Icon.
Only Last Name field data displays Also note that
the Johnaton(s) are not listed Must use wild
cards John
Last Name Black Braithwaite Dewey Dickenson Dobbin
s Duran
44Access Automatic FILL
- When you entered in the string John, Access will
automatically place the quotes - John John
- If you entered the string John, Access will
automatically change the field to - John Like John
- Or you can put these in yourself.
45String Criteria
- We can match strings for text type fields
- We can use the wild cards and ? for
substitution of characters - - 0 or more character substitution
- Like John
- matches John, Johnaton, Johns, Johnstone
- but not Jon, Jjohn
- ? only one match and not anymore
- Like 285?5???
- matches 285 5555, 285- 5555
- but not 765-285-5555, 1-285-5555, 285-51111
46Our Next Question?
Who are our customers with the first name of John
or Susan? (list them alphabetically)
Customers Customer Id First Name Last
Name Address
Our database
This can be answered by a completing a Query
Design Window.
47Design Query
Customers Customer Id First Name Last
Name Address
Display in alphabetical order the last names of
customers with the first name of John or Susan
Field
First Name
Last Name
Table
Customers
Customers
Sort
Ascending
Show
Criteria
John
Or
Susan
48The Results
- A list will appear when the run command is
clicked, the ! Icon.
Last Name Black Braithwaite Dewey Dickenson Dobbin
s Duran Doolittle
Only Last Name field data displays Also you note
that the Johnaton(s) and Susanne(s) are not
listed. Must use wild cards in strings John
Susan
49OR
- connectors
- allows you to link comparisons to make it
possible for you to analyze data in various ways - logical operators, because they act in
comparisons the way mathematical operators work
in the Spreadsheet
50Or Conjunction
- when one or more of the conditions needs to be
true we use the or conjunction - color equal to green OR color equal to yellow
- color equal to green OR part number equal to 948
- one listed in the criteria row, the other in the
or row
51Numeric Criteria - Logic Operators
- Greater than (gt)
- Less than (lt)
- equals ()
- greater than or equal to (gt)
- less than or equal to (lt
- not equal to (ltgt
- (same as Excel If expressions)
52Design Query
Customers Customer Id First Name Last
Name Address Total Purchase Age
Table name
Display in descending order the total purchase
of customers who are under 30 years of age
Field
Age
Total Purchase
Last Name
Table
Customers
Customers
Customers
Sort
Descending
Show
Criteria
lt30
Or
53The Results
- A list will appear when the run command is
clicked, the ! Icon.
Total Purchase 1900.50 1410.26 1167.88 900.88
469.34 367.99
Last Name Smith Buy Jones Smith Feather Johnson
Age 24 21 26 20 14 29
The query is sorted by the amount of the total
purchase
54Design Query
Orders Customer Id Order Product ID
Quantity Unit Price Date of Purchase Date of
Payment
Table name
Display all orders which have not been paid by
oldest date
Field
Date of Purchase
Date of Payment
Order
Table
Orders
Orders
Orders
Sort
Ascending
Show
Criteria
Is Null
Or
55Criteria
- Null - the absence of data - an empty field.
- If a field has no entry, it is called a null
value. This is not the same as a space or zero! - The computer treats dates as if they were
sequential numbers that increase with time
56The Results
- A list will appear when the run command is
clicked, the ! Icon.
Order 146678 145778 145807 145900 145910 145950
Date of Purchase 3/10/2000 3/12/2000 3/15/2000 3/1
9/2000 3/21/2000 3/24/2000
Date of Payment
The query is sorted by the date of purchase Note
that the Date of Payment could have been marked
to not display.
57Design Query
Orders Customer Id Order Product ID
Quantity Unit Price Date of Purchase Date of
Payment
Table name
Display all orders which were paid this month
Field
Date of Purchase
Date of Payment
Order
Table
Orders
Orders
Orders
Sort
Ascending
Show
Criteria
gt4/1/2000
Or
58The Results
- A list will appear when the run command is
clicked, the ! Icon.
Order 146578 145578 145607 145600 145710 145750
Date of Purchase 3/02/2000 3/02/2000 3/05/2000 3/0
5/2000 3/06/2000 3/06/2000
Date of Payment 4/2/2000 4/2/2000 4/4/2000 4/5/200
0 4/6/2000 4/6/2000
The query is sorted by the date of purchase Note
that the Date of Payment could have been marked
to not display.
59Access Automatic FILL
- When you entered in the string gt4/1/2000, Access
will automatically place the s - gt4/1/2000 gt4/1/2000
- Or you can put these in yourself.
60Simple Selection Query
Customers Customer Id First Name Last
Name Address
Display all of the customers with the name John
Smith
Field
First Name
Last Name
Table
Customers
Customers
Sort
Show
Criteria
John
Smith
Or
61And Conjunction
- The AND conjunction says that both conditions
must be present for the record (row) to be
queried - to combine criteria with AND, place the criteria
on the same line
62Combining Multiple Conjunctions
- when combining with all Ors - no problem
- when combining with all Ands - no problem
- when combining with both Ands and Ors - order is
important
63Design Query
Customers Customer Id First Name Last Name Age
Display in alphabetical order the last names of
customers with the first name of John or Susan
that are older than 50 years of age.
Field
First Name
Last Name
Age
Table
Customers
Customers
Customers
Sort
Ascending
Show
Criteria
John
gt50
Or
Susan
64The Records in the Database
First Name Last Name
Age David Done
33 Fred
Flinstone 55 Susan
Johnson 43 Susan
Peters 34 John
Peters
39 John Smith
55 Susan Smith
52
65Result of Query
First Name Last Name
Age Susan Johnson
43 Susan Peters
34 John
Smith 55 Susan
Smith 52
Note that the records matched any record with the
first name of Susan and records that had the
first name of John and were older than 50
(FirstName John AND Age gt 50) OR FirstName
Susan
66But what if wanted only those records with first
name of Susan who were age 50 or older or records
with the first name of John who were age 50 or
older or
First Name Last Name
Age John Smith
55 Susan Smith
52
Note that the records matched any record with the
first name of Susan and records that had the
first name of John and were older than 50
(FirstName John OR FirstName Susan) AND
age gt 50
67Design Query
Customers Customer Id First Name Last Name Age
Display in alphabetical order the last names of
customers with the first name of John or Susan
that are older than 50 years of age.
Field
First Name
Last Name
Age
Table
Customers
Customers
Customers
Sort
Ascending
Show
Criteria
John
gt50 gt50
Or
Susan
68Result
First Name Last Name
Age John Smith
55 Susan Smith
52
Note that the records matched any record with the
first name of Susan who was older than 50 years
of age or records that had the first name of John
who were older than 50 years of age. (FirstName
John and age gt 50) OR ( FirstName Susan
and age gt 50)
69Three fields using AND and OR
70Meaning
- Be careful of the wording when designing queries.
- For example if I asked you to give me a list of
classes that are held at 900 A.M and 1000 A.M,
I am using the word AND to mean both (not the
connective AND) - BOTH-gt OR
71Questions