microsoft access overview
DESCRIPTION
Microsoft Access Overview. Lydia Scheer, ITEP. The Database Environment. Access is a relational database Data stored with Access are related to one another in multiple ways Access maintains the data relationships when database is structured correctly - PowerPoint PPT PresentationTRANSCRIPT
1
Microsoft Access Microsoft Access OverviewOverview
Lydia Scheer, ITEP
2
The Database The Database EnvironmentEnvironment
• Access is a relational database– Data stored with Access are related to one
another in multiple ways– Access maintains the data relationships when
database is structured correctly
• MS Excel (or other spreadsheets) are considered “flat” file databases– Rows and Columns of data that may be related– Excel has no way of maintaining relationships
automatically
3
How do Relationships How do Relationships Work?Work?
A relationship works by matching data between tables based on values in key fields. In most
cases, these matching fields are the primary key from one table,
which provides a unique identifier for each record, and a foreign key
from another table.
4
5
Relationships WindowRelationships Window
• View, define, and modify relationships• Tools (Menu)Relationships… or right-
click on database window (white area) to view
• Join lines indicate type of relationship (1=one-side; = many side)
• Double-click on a join line to modify relationship
• Tables/field lists are moveable/sizeable• A table can be related to multiple
tables, but only by ONE field at a time
6
Types of RelationshipsTypes of Relationships
• One-to-One– Item (record) in Table A related to only one item in Table B– Not common because usually the information is stored all in one
table– Example: Data archive table; Subset of information that would
result in too many blank fields in main table (confidential info, instructors, etc.)
• One-to-Many or Many-to-One– One item in Table A can be related to multiple items in Table B– Example: One site has multiple (many) monitors; One person has
multiple visits to the clinic• Many-to-Many
– Combination of two One-to-Many relationships– Example: One person has multiple visits to the clinic; One clinic has
multiple people visit.– Some Many-to-Many relationships are not immediately obvious
(Example: One site has multiple monitors, but does a monitor have multiple sites?)
7
Join Lines (Identify
Relationships
8
The Structure of AccessThe Structure of Access
• Database File: This is your main file that encompasses the entire database and that is saved to your hard-drive or floppy disk. Example: DMExample.mdb
• Table:A table is a collection of data about a specific topic. There can be multiple tables in a database. Example #1: tblFIPSCodesExample #2: tblAQS_Ozone
• Field:Fields are the different categories within a Table. Tables usually contain multiple fields. Example #1: FilterID Example #2: Date
• Datatypes:Datatypes are the properties of each field. A field only has 1 datatype. FieldName: FilterIDDatatype: Number
• Value: The Data.Example (FilterID): 7544231
•
9
The Database WindowThe Database Window
•Default view when database is opened•Lists all available database objects
–Tables, Queries, Forms, Reports, Pages, Macros, Modules
•Lists all available database object groups–A way of organizing shortcuts to objects that are related–Create groups specific to your project/needs (e.g. “Favorites”)
•Toolbar across top has commands for database objects
–Open, Design, New, Delete –View style (4 buttons on the left)
10
The Database Window
11
Object ViewsObject Views
•Datasheet View–Tables, Queries, Forms–Standard table view – “spreadsheet style”
•Form/Page View–Standard form view or page view
•Print Preview–Standard view for Reports–Can also be used with Forms, Tables, Queries & Pages
•Design View–Applicable to all database objects–Layout/view is specific to the database object–Make changes to the structure/format/layout of object
12
Database Objects-TablesDatabase Objects-Tables
• Used for storing data in rows and columns• Rows = Records; Columns = Fields• Records are UNIQUE collections of data about
“something” (e.g. a person, a PM filter, etc.)• Fields are categories of data for a set of records• Tables contain information about one subject only• Primary Key field in a table is a unique identifier
for each record—no null values or duplicates• Tables can have up to 255 fields, and can store up
to 1 gigabyte (GB) of data per table
13
Design View
Datasheet View
14
Database Objects-QueriesDatabase Objects-Queries
• Retrieve sets of data based on user-defined criteria (text strings, expressions, functions)
• Often used to combine data from multiple (usually related) tables
• Subsets of data stored in tables; data are not actually stored in queries
• Perform calculations on or with data• Can be constructed to perform an “action”
– create a new table from query results– append records to an existing table– update records in an existing table (similar to
find and replace, but can use calculations, too)
15
QBE Pane or Query Design View
16
Delete Query Grid:
Append Query Grid:
Make Table or Append Query Pop-up:
Update Query Grid:
17
Database Objects-FormsDatabase Objects-Forms
• User-friendly way of displaying data for entry or manipulation
• Programmed actions (macros, modules) can be attached to forms
• Display data from tables and/or query results
• Can also be used as a menu (or switchboard), created as custom dialog boxes, or displayed as a datasheet
• Subforms-form within a form that displays data from a different dataset than that of the main form
18
Data Entry Form (with Tabs)
“Switchboard” Form
19
Database Objects-ReportsDatabase Objects-Reports
• Output of information from database (tables or queries) in the form of a printed report
• Allows you to group and summarize information
• Can be previewed on the screen prior to printing
• Can include graphs, data tables, images, and calculations/totals
• Reports are for publishing data only, not for data manipulation
20
21
Database Objects-Database Objects-Macros & ModulesMacros & Modules• Macros
– Access-specific “mini-programs” – Pre-programmed for ease of use
• Modules– Visual Basic for Applications (VBA) programming language– More complicated to use properly, but more options and
flexibility than macros• Both are based on event-driven programming
– An event (click a button, open/close a form, etc.) triggers an action (macro/module) that carries out a programmed set of commands
– Most actions have required arguments (user-specified data that tells the event how/when to carry out the action)
– Must act on a certain object or control on the form or report
• Can only be attached to forms or reports
22
23
Adding a Macro or Module (Event Procedure) to a Form
Event
24
WizardsWizards
• Access has a number of wizards built in to make it easier to work with each tool
• Wizards walk you through creating db objects– Tables & queries– Forms & reports– Other items inside above (expressions,
events, etc.)
25
Simple Query Wizard asks for a table or query to use for base data
Then you have the option of displaying all records/fields or creating a summary query
Final query results (grouped by Month
as an option) displays Avg, Min,
and Max of monthly PM mass
26
Things to make your life Things to make your life easier…easier…
• Naming Conventions– Consistency in naming different types of objects, controls, etc.– Use identifiers in names (e.g. tbl, qry, frm) that make sense to
you– NO SPACES or Punctuation in names-harder to deal with in
expressions and code procedures– Examples: tblSites, qryAQS_OzoneArizona, cmdClose,
dap2003SummaryDataPMFineHighestConc
• Document what you are doing…will you remember what you did (or why) in three months time?
• Changes made to data are PERMANENT• Backup….BACKUP…BACKUP!
27
The Database Window The Database Window ToolbarToolbar
View Objects with
Details
View Objects as Small Icons
View Objects as a
List
View Objects as Large Icons
Create a New
Object
Open Current Object
Delete Current Object
View Object in Design
View
28
The Database Toolbar The Database Toolbar (Default)(Default)
Help Files
View Relationshi
ps
VBA (Code) Window
Publish or Merge with another Office
Application
Format Painter
Copy
Spell Checker
Open another
database file
View, Edit, or Create Indexes
Show Object Properties
Analyzer Tool
Undo Action
Paste or Clipboard
Tool
Cut
Print Previe
w
Save
Create a new Database
File
29
Table (Datasheet View) Table (Datasheet View) ToolbarToolbar
New Object (incl.
AutoForm & AutoReport
)
Delete Record(
s)
Database
Window
Add/Go To New
Record
Apply/ Remo
ve Filter
Find a Value
Filter by
Form
Filter by Selectio
n
Sort Field
Data by Ascendi
ng Values
Sort Field Data by
Descending Values
Insert Hyperlink ( to Internet or other network
location)
Print Tabl
e
Table Print
Preview
Switch to Table
Design View
Save Table Desig
n
30
Table Design View ToolbarTable Design View Toolbar(also for Query and Form Views)(also for Query and Form Views)
Field Builder Wizard
Table Propertie
s
Delete a Row (Field)
Insert a Row
(Field)
View/Set Indexes
Set Field(s) as Primary
Key
Print Table Design View
Switch to Table
Datasheet View
Save Table/ Query/Form
Design
31
Query Design View Query Design View ToolbarToolbar
New Object (incl.
AutoForm & AutoReport)
Expression Builder or Calculated
Field Wizard
Query Properti
es
Show Top Values (all,
25, 5%, etc.)
Create a Totals Query
Undo Last Action (only
allowed once)
Add a table to the QBE
Pane
Save Query
Print Query Design View
Switch to Query Datasheet View or SQL View
Run Query (select queries
display in datasheet view; action queries
attempt to run)
Choose or Change Query Type (delete,
append, select, etc.)
32
Form Design View ToolbarForm Design View Toolbar
Expression Builder Wizard
AutoFormat Form Design
Open VBA
WindowProperties
for selected control(s)
Field List-shows available fields for use on the
form
Font Size Indicator
Font Selection Box for controls with dynamic
fonts (text boxes, labels, buttons, etc.)
Format Font (Bold, Italicize,
Underline)
Toolbox for Form
ControlsIdentifies the control on the form which has
the focus
Switch to Form
Design or Datasheet
View
Fill Color, Font Color, Line
Color
Text Alignment: Left, Center,
Right
33
Form/Report Design Form/Report Design ToolboxToolbox
Label (control) Tool
Option (radio) button; Check
box
Textbox Tool
Select Control Tool-Use to
select a control on a form or
report to modify, delete,
move, etc.
Command button
Insert Page Break
Rectangle Tool
Create an Option Group
Create Combo Box
Toggle Button Tool
Control Wizard—Selected means wizards will be activated when a tool is chosen to help the user establish the control properly. Deselected means wizards will not be activated when a tool is chosen, and enables the user to design a control with his/her own methods.
Create a List Box
Create an Unbound Object
Frame
Line Tool
Insert Image or Graphic
Click to view more controls
for use on forms/reports
Tab Control
Create a Bound Object Frame
Insert a Subform/ Subreport
34
Report Design View Report Design View ToolbarToolbar
Expression Builder Wizard
Print Report
Show Toolbo
x
Properties for
selected control(s)
Format
Painter
Save Report Design
Insert Hyperlin
k
Switch between Print Preview,
Design View and Layout Preview
Print Previe
w
Show Field LIst
Sorting/ Groupin
g Options
VBA Windo
w
AutoFormat Report
Layout
35
Macro Design View Macro Design View ToolbarToolbar
Expression Builder Wizard
Delete a Row
Show/Hide Macro Names
ColumnSave Macro
Show/Hide Macro Conditions Column
Print Preview Macro Definitions
(summary of macro actions and arguments
Undo last action (can
only use once)
Insert a Row
Run Macro
Step Through Macro
Actions