part i. open a access database blank database database wizard existing database (last five databases...
DESCRIPTION
The database window This window will appear after selecting the database. Note it has the 6 database objects each on its own tab.TRANSCRIPT
Part I
Open 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…)
The database window
• This window will appear after selecting the database. Note it has the 6 database objects each on its own tab.
Database 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
Table Selection
• Datasheet View• Design View• Table Wizard• Import Table• Link Table
Design ViewDatabase Table
Columns 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
Access 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
Access 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 1:00
• Currency - monetary values, such as salary
Access 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)
Access 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
Filled in Table Design
Datasheet View
The Field Name(s)
There are no records for this Database (yet)
Records Added to Datasheet
Two 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.
Form View
Maintenance
• Change is inevitable. You will need add, delete modify information in your db
• find, update, insert, replace, delete, sort, and filter and query.
Find, Filter, Query
Query languageformat
examples
Query Language
• ask questions about the database• find the records which match a certain
criteria
Find 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.
Find• 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.
To Find Records in a DB Table• The binoculars on the toolbar• also can do find/replace (Edit->Replace)
Find
• 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.
Filters
• 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.
Filters• 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)
Filter
• 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)
Filter/Query• Not saved• only within a single
table• displays all the fields
of “filtered” records• no other functions
• 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
Database WindowQueries Tab
Three options you can do in queries section
Previously Saved queries
Queries• 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
Queries• 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.
Show Table
Tables saved for this database
To add tables to the query, highlight the table name and click Add. When finished click Close
Query Design Window
Back to Queries slide
The 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
...
Parts of the Query Design Window
the table(s) used in the query
Customers
*
Customer Id
First Name
Last Name
Address
Table name
Example of a selected table to use in a query, appears in the top half of the Query Design Window
Field Names
Parts of the Query Design Window
the query grid
Field:Table:Sort:Show:CriteriaOr:
Drop down box of the Field Names from the selected tables
Field
• 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.
Table:
• 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.
Sort: • 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)
Show:
• 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
Criteria
• 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
Our Question (Query)?
Customers
*
Customer Id
First Name
Last Name
Address
Who are our customers with the first name of John? (list them alphabetically)
Select the Customers database
This can be answered by a completing a Query Design Window.
Filled in Query Design Window to Answer our
Question
Field:Table:Sort:Show:CriteriaOr:
Customers
*
Customer Id
First Name
Last Name
Address
Display in alphabetical order the last names of customers with the first name of John
First NameCustomers
Ascending
“John”
Last NameCustomers
The Results• A list will appear when the run command is
clicked, the ! Icon.Last Name
Black
Braithwaite
Dewey
Dickenson
Dobbins
Duran*
Only Last Name field data displays
Also note that the Johnaton(s) are not listed
Must use wild cards *
“John*”
• 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.
Access Automatic “FILL”
String 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
Our Next Question?
Customers
*
Customer Id
First Name
Last Name
Address
Who are our customers with the first name of John or Susan? (list them alphabetically)
Our database
This can be answered by a completing a Query Design Window.
Design Query
Field:Table:Sort:Show:CriteriaOr:
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
First NameCustomers
Ascending
“John”
Last NameCustomers
“Susan”
The Results• A list will appear when the run command is
clicked, the ! Icon.Last Name
Black
Braithwaite
Dewey
Dickenson
Dobbins
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*”
OR
• 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
Or 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
Numeric Criteria - Logic Operators
• Greater than (>)• Less than (<)• equals (=)• greater than or equal to (>=)• less than or equal to (<=• not equal to (<>• (same as Excel If expressions)
Design Query
Field:Table:Sort:Show:CriteriaOr:
Customers
*
Customer Id
First Name
Last Name
Address
Total Purchase
Age
Tablename
Display in descending order the total purchase ofcustomers who are under 30 years of age
Total PurchaseCustomers Customers CustomersDescending
Last Name Age
<30
The 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*
The query is sorted by the amount of the total purchase
Last Name
Smith
Buy
Jones
Smith
Feather
Johnson
Age
24
21
26
20
14
29
Design Query
Field:Table:Sort:Show:CriteriaOr:
Orders
*
Customer Id
Order #
Product ID #
Quantity
Unit Price
Date of Purchase
Date of Payment
Tablename
Display all orders which have not been paid by oldest date
Order #Orders Orders Orders
Date of Purchase Date of Payment
Is Null
Ascending
Criteria
• 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
The Results• A list will appear when the run command is
clicked, the ! Icon.
Order #
146678
145778
145807
145900
145910
145950*
The query is sorted by the date of purchase
Note that the Date of Payment could have been marked to not display.
Date of Purchase
3/10/2000
3/12/2000
3/15/2000
3/19/2000
3/21/2000
3/24/2000
Date of Payment
Design Query
Field:Table:Sort:Show:CriteriaOr:
Orders
*
Customer Id
Order #
Product ID #
Quantity
Unit Price
Date of Purchase
Date of Payment
Tablename
Display all orders which were paid this month
Order #Orders Orders Orders
Date of Purchase Date of Payment
>=4/1/2000
Ascending
The Results• A list will appear when the run command is
clicked, the ! Icon.
Order #
146578
145578
145607
145600
145710
145750*
The query is sorted by the date of purchase
Note that the Date of Payment could have been marked to not display.
Date of Purchase
3/02/2000
3/02/2000
3/05/2000
3/05/2000
3/06/2000
3/06/2000
Date of Payment
4/2/2000
4/2/2000
4/4/2000
4/5/2000
4/6/2000
4/6/2000
• When you entered in the string >4/1/2000, Access will automatically place the # s
• >=4/1/2000 >=#4/1/2000#• Or you can put these in yourself.
Access Automatic “FILL”
Simple Selection Query
Field:Table:Sort:Show:CriteriaOr:
Customers
*
Customer Id
First Name
Last Name
Address
Display all of the customers with the nameJohn Smith
First NameCustomers
“John”
Last NameCustomers
“Smith”
And 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
Combining 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
Design QueryCustomers
*
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:Table:Sort:Show:CriteriaOr:
First NameCustomers
“John”
Ascending
Last NameCustomers
“Susan”
AgeCustomers
>50
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
The Records in the Database
First Name Last Name Age
Susan Johnson 43
Susan Peters 34
John Smith 55
Susan Smith 52
Result of Query
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 > 50) OR FirstName = “Susan”
First Name Last Name Age
John Smith 55
Susan Smith 52
But 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
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 > 50
Design QueryCustomers
*
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:Table:Sort:Show:CriteriaOr:
First NameCustomers
“John”
Ascending
Last NameCustomers
“Susan”
AgeCustomers
>50
>50
First Name Last Name Age
John Smith 55
Susan Smith 52
Result:
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 > 50) OR
( FirstName = “Susan” and age > 50)
Three fields using AND and OR
Meaning
• 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 9:00 A.M and 10:00 A.M, I am using the word AND to mean both (not the connective AND)
• BOTH-> OR
Questions