Professional Documents
Culture Documents
2007
1
Objectives
• Access or Excel?
• RDMS
• Tables
• Filters
• Queries
• Relationships
• Forms
• Reports
Access or Excel?
Use Excel when: Use Access when:
Your data is of a • You are working with
manageable data size large amounts of data
There is no need for • You need to create
relationships between relationships between
data your data
You are primarily • You rely on external
creating calculations databases to analyze
and statistics data
3
Relational Database - RDBMS
• Relational database • This is much more efficient
management systems than the opposite of an
allow data to be RDBMS which is a flat file.
grouped into tables and Flat files store data in one
relationships created single file with no special
between the tables groupings or collections
4
Working with Multiple Tables –
Table Relationships
Relationship
between two tables
Database
6
Using Microsoft Access 2007
• Access contains four types of components
– Table: used for data storing
– Form: used for data entering
– Query: used for data selection
– Report: used for formally data display
• Basic operations:
– Design tables
– Enter data
– Do queries (select interesting data)
– Produce report
Opening a Database
• Start Access and display the Getting Started
with Microsoft Office Access page
• Click the More option to display the Open
dialog box
• Navigate to the database file you want to
open, and then click the file
• Click the Open button
8
Access 2007 Start Up Screen
9
Create a New Blank Database
10
Access 2007 Interface
11
Save with Quick Access Toolbar
12
Organizing the Shutter Bar
13
Access Objects
• Tables
• Queries
• Reports
• Forms
• Macros
• Modules
Objects
14
Closing and Exiting Microsoft Access
You must perform an appropriate
exit from the database and
Microsoft Access to insure the
stability of the data.
15
Tables
16
Data Modeling Concepts: Entity
• Entity – a class of persons, places, objects, events, or
concepts about which we need to capture and store
data.
• In database design, it will be converted into a table
18
Table Design Considerations –
Avoid Calculated Fields
• Calculated fields should be used mainly in
queries and reports
19
Table Design Considerations –
Design Multiple Tables
Multiple tables shown in the Navigation pane
20
Table Structure
• Data is stored in Tables
• Each row is a record (instance)
• Each column is a field
21
Table Structure
A database is made up
• Field of one or more tables
Individual fields
• Record
• Table
• Database
Individual tables in a
database
Records
22
Primary key
• A collection of related tables is called a database, or a
relational database
• You connect the records in the separate tables through
a common field
• A primary key is a field, or a collection of fields, whose
values uniquely identify each record in a table
• When you include the primary key from one table as a
field in a second table to form a relationship between
the two tables, it is called a foreign key in the second
table
23
Creating tables
Datasheet View
• Click F6 to
switch
between the
upper and
lower panes
27
Creating a Table in Design View
• Click the Create tab on the Ribbon
• In the Tables group, click the Table button
• Right click the table name and open in design
view.
• Add fields and specify primary keys
28
Creating Tables – From the Create
Tab
• Enter table data directly in fields
– From the Create Tab, click Table
• Use a table template
– From the Create Tab, click Table Templates
Enter field names, data
types and descriptions in
Table Design View
Enter data directly into a table,
including the field names
30
Create Tables – Specifying field
names Table Design
View
Add field
Table Viewin
Table View
• After choosing your method of creation begin implementing the table design
– Use CamelCase notation for field names
– Specify data types
– Establish a primary key
– Consider the need for a foreign key
31
Create Tables – Primary Key
Primary Key icon
Primary Key Field
33
FIELD PROPERTIES
• Field Size is used to set the number of characters needed in a
text or number field.
√ save disk space
√ prevent entry errors Likewise, if the field will require more than 50
characters, enter a number up to 255.
• The field size is set in exact characters for Text type, but
options are give for numbers:
– Byte - Positive integers between 0 and 255
– Integer - Positive and negative integers between -32,768 and 32,767
– Long Integer (default) - Larger positive and negative integers between -
2 billion and 2 billion.
– Single - Single-precision floating-point number
– Double - Double-precision floating-point number
– Decimal - Allows for Precision and Scale property control
34
PRIMARY KEY
• Every record in a table must have a primary key that
differentiates it from every other record in the table
• The primary key field will be noted with a key image to the left.
To remove a primary key, repeat one of these steps.
35
PRIMARY KEY
• If none of the existing fields in the table will produce
unique values for every record, a separate field must be
added.
36
FIELD PROPERTIES
• Format conforms the data in the field to the same format when
it is entered into the datasheet.
• For text and memo fields, this property has two parts that are
separated by a semicolon. The first part of the property is used
to apply to the field and the second applies to empty fields.
37
TEXT AND MEMO FORMAT
Format Datasheet Display Explanation
Entry
@@@-@@@@ 1234567 123-4567 @ indicates a
required
character or space
@@@-@@@& 123456 123-456 & indicates an
optional
character or space
< HELLO hello < converts characters
to lowercase
> hello HELLO > converts characters
to uppercase
38
TEXT AND MEMO FORMAT
Format Datasheet Display Explanation
Entry
@\! Hello Hello! \ adds
characters to
the end
@;"No Data Entered" Hello Hello
@;"No Data Entered" (blank) No Data
Entered
39
NUMBER FORMAT
Format Datasheet Display Explanation
Entry
###,##0.00 123456.78 123,456.78 0 is a placeholder that
displays a digit or 0 if
there is none.
$###,##0.00 0 $0.00 # is a placeholder that
displays a digit or
nothing if there is
none.
###.00% .123 12.3% % multiplies the
number by 100 and
added a percent sign
40
CURRENCY FORMAT
• This formatting consists of four parts: format for
positive numbers; format for negative numbers;
format for zero values; format for Null values.
Format Explanation
$##0.00; Positive values will be normal currency
format
($##0.00)[Red]; negative numbers will be red in
parentheses
$0.00; zero is entered for zero values
"none" "none" will be written for Null values 41
DATE FORMAT
• Datasheet entry is “1/1/01”.
Format Display Explanation
dddd","mmmm d","yyyy Monday, dddd, mmmm, and yyyy print
January the full day name, month
1, 2001 name, and year
ddd","mmm ". " d", '"yy Mon, ddd, mmm, and yy print the
Jan. 1, first three day letters, first
'01 three month letters, and last
two year digits
"Today is " dddd Today is
Monday
h:n:s: AM/PM 12:00:00 "n" is used for minutes to 42
AM avoid confusion with months
YES/NO FORMAT
• Yes/No fields are displayed as check boxes by default on the
datasheet. To change the formatting of these fields, first click
the Lookup tab and change the Display Control to a text box. Go
back to the General tab choices to make formatting changes.
The formatting is designated in three sections separated by
semicolons. The first section does not contain anything but the
semicolon must be included. The second section specifies
formatting for Yes values and the third for No values.
Format Explanation
50
Entering/Deleting/Updating
Record
• Open Table in datasheet view
• Enter new record
– Scroll down to the last record
– Enter a new record
• Delete/update record
– Search the record
– Delete/update
51
Using data types
52
Using data types
• Access 2007
supports the use of
numerous field data
types.
• Press the down
arrow in the Data
Type field to display
available options.
53
Data Type
Data type – a property of an attribute that identifies what type of data can
be stored in that attribute.
55
Work with Table Views
Caption property
Indexed Property
• Input mask—such
as !(999) 000-
0000—may be
confusing.
• Each character
has meaning
within Access.
61
validation rules
64
Importing delimited text files
65
Filters
66
Filters
• Create a subset of records
• Do not change underlying table data
• Two types
– Filter by Selection
– Filter by Form
67
Filter by Selection
Selection of criteria
during Filter by form
process
70
Sorting Table Data
72
Forms, Queries, and Reports
74
Queries
• A query is a question you
ask about the data stored
in a database
• Use a Select query to locate
specific records.
• Calculate sums, counts, and
averages using a Select
query.
• Create an Update query to
make mass changes to a
table in one step.
75
Queries
Criterion restricting
dataset to show records
that have a job title of
Sale Representative
77
Using the Query Wizard
• The easiest way to create a new query is by
using the Query Wizard.
• Trigger queries by selecting the Query Wizard
object from the Other section of the Create
tab.
78
Using the Query Wizard
Click the Create tab and select the Query
Wizard button in the Other group.
80
Creating Criteria and Running a Query
Select the Design/Query
Tools tab in the Results
group, click the Run
button.
81
Select Query
84
Specifying Criteria – Wildcards
86
Specifying Criteria – And and Or
87
Copy a Query
89
What Are Expressions Used For?
• You can use an expression to:
– perform a calculation
– retrieve the value of a field
or control
– supply criteria to a query
– create calculated controls
and fields
– define a grouping level for a
report
Operator
91
Creating a Calculated Field
Expression using existing fields in a database
Calculated Field
94
Expression Builder
• Used to formulate the expressions in a
calculated field
95
Expression Builder
Expand folders
by clicking plus
sign Fields available
in current query
Payment function in
work area Function categories
Arguments separated
by commas
99
The IIF Function
• Evaluates a condition
• Executes one action when the expression
• Alternate action when the condition is false
100
Example of IIF Function
=IIF(Quantity_on_Hand] >= 1, “In Stock”, “Out of Stock”)
102
Use a Totals Query to Group
Grouping field
Field to be totaled
104
Using the Relationship Window
Relationship
window
Show Table dialog box
Primary Key
Foreign Key
Enforce Referential
Integrity
109
Forms
Form
111
Creating Forms and Split Forms
Click the Create tab and then
select the Form button in the
Forms group.
112
Auto Formatting and Saving Forms
Use the Format tab and the AutoFormat
group to select a predefined layout, such as
the “Opulent” layout from the AutoFormat
gallery. The formatted form should display in
Layout View. Save the form to include a
name, such as Customer.
113
Report
114
Reports
116
Identify Data Sources
Determine the
underlying data
source or sources for
your report
Report Tool
Report generated
using the Report Tool
120
Report Views – Print Preview
Print Preview
121 121
Report Views – Design View
124
Insert Graphical Elements
Select Logo to insert a
new graphical element
125 125
Divisions of a Report – Detail
Section
Detail Section
Group Header
Group Footer
128 128
Divisions of a Report – Page and
Report Footers
Report Footer
Page Footer
• Page footers: at the end of each page
• Report footers: at the end of the report
129 129
Working with Controls
• Controls allow you to position, display, format
and calculate report date
• Controls are manipulated in Design View
• Two types of controls
– Bound – tied to an underlying source
– Unbound – not tied to an underlying source
130
Using the Report Wizard
• The Report Wizard creates a
report based on answers that
you provide
• Allows application of
predefined styles Click to use the Report Wizard
131
Using the Report Wizard –
Choosing Fields
Choose a field and
click to add
individual fields to Click to add all fields to
the report the report
132 132
Using the Report Wizard –
Grouping Levels
Choose a field to
group by
Choose a layout
• Pick a layout
• Choose landscape or portrait
135 135
Using the Report Wizard –
Choosing a Style
Choose a style