Microsoft Access - Home - Tulpehocken Area School District
Transcript of Microsoft Access - Home - Tulpehocken Area School District
Microsoft Access
1 Access is a Database Management System (DBMS) that is used to find data based upon tables
in which data records are stored. It provides an extremely fast and accurate way to manage
even large amounts of data on any subject.
Starting Access Access can be started by choosing the Start – All Programs – Microsoft Office 2007 – Microsoft
Access 2007 options from the desktop.
Opening a Database A database is a collection of objects that work together to store, retrieve, display, and
summarize data.
Above, is the opening screen. Here, it is possible to:
Open previously opened databases o Clicking the More option lists a My Documents dialog to browse the file system
Create a blank database
Choose from pre-made, on-line styles available from the Internet
Microsoft Access
2
Opening an existing database displays:
The database name at the top of the screen
Database objects in the Navigation Pane
The Access Screen The Access screen looks like the other Office 2007 applications with the ribbon, title bar, quick
access toolbar, and status bar (at the bottom).
Database Objects
Microsoft Access
3 Navigation Pane
Double clicking an object in the navigation pane opens it with its name at the top. Opening
several objects simultaneously creates tabs in the main part of the screen. Clicking on any of
these tabs opens that object.
Below is an example of an Access screen with tabs for tables, a query, and a report.
Shutter Bar –
Lists objects
in the
database
Ribbon
Quick Access Toolbar Office Button Title Bar
Status Bar
Microsoft Access
4 Records
Databases are configured in two-dimensional grids. Each horizontal row is called a record.
Each record contains a series of fields represented by columns.
Below is an example of the Member table. Each row is a record consisting of a series of fields
which are labeled at the top (i.e. Member ID, Last Name, First Name, etc.).
Navigating Records
Microsoft Access
5
Editing Records
Individual records can be accessed using the Record Navigation Bar located at the bottom of
the data sheet:
Moving to the next record using the Tab or Enter keys will select the contents of the data cell
moved to. From there, simply keying in data will delete the original and replace it with the
keyed data.
Clicking to move to a new cell will place the insertion point at that point in the cell and it can
be moved using the arrow keys. The Delete key will delete characters to the right of the
insertion point and the Backspace key will delete characters to the left of the insertion point.
Changes can be reversed using the Undo Button on the Quick Access Toolbar.
Selecting Records and Fields
Records can be selected using the Record Selector located at the left of each record. Fields can
be selected using the Field Selector located at the top of each field. The entire datasheet can
be selected using the Datasheet Selector located at the upper left corner of the datasheet.
First
Record
Previous
Record
Current Record
Next
Record
Last
Record
Add a New Record
Field Selectors
Microsoft Access
6
Selecting Duplicate Records or Fields
A range of records or fields can be selected by:
Click a record or field selector – hold the Shift Key – click another record or field
selector. The two selected items and all those between the two selected items will be
selected.
Click and drag over a range of either fields or records.
Deleting Records
Click the desired record selector(s)
Press the Delete Key on the keyboard
In the resulting dialog box, click YES to permanently delete
Copying and Moving Records
Copy and Cut work the same in Access as they do in the other Office 2007 applications. Care
must be taken when copying or moving a record so as not to inadvertently overwrite existing
data that you want to keep. To avoid this problem, when pasting the data, click the down-
arrow in the paste button and choose the Paste Append option.
Changing Row Height
Point to the border between two row (record) selectors
Left click and drag until the height of the upper row is adjusted to taste
OR
Click the More Button in the Records Group in the Home Tab
The Row Height Dialog opens and a height can be entered
Record Selectors
Microsoft Access
7
Changing Column Width
Point to the right border of the column (Record) to change
Left click and drag to the desired width
OR
Point to the right border of the column to have Access auto-fit its width
Double click on the border to auto-fit the width to accommodate the widest data
element
Rearranging Columns in a Datasheet
Click the Field Selector of the desired field(s)
Left click and drag to a new location
Freezing Columns
To keep columns at the left from scrolling off the screen when the table is too wide:
Select the field selector(s) of the columns to freeze
Choose the More Button in the Records Group in the Home Tab
Click the Freeze option (The unfreeze option removes any freeze that was set.)
Changing Background Row Color
Datasheet rows are, by default, colored with alternating white and gray. Changes to this theme
are accomplished by using the Alternate Fill/Back Color button in the Font group in the Home
tab.
Clicking on a color from the palette applies that color to the background of the selected row.
Microsoft Access
8
Previewing and Printing a Table
Print Preview in Access, as with all other Office applications, is accessed by clicking the Office
Button and then choosing Print Preview from the Print options. Clicking the Close Print
Preview button returns to the datasheet.
Printing a Table
The print options dialog is accessed by using the Print option from the Office Button:
From here you can choose to
print all the records or only
some of the records.
Using the Quick Print option
from the Print Options in the
Office button will print the
entire datasheet
immediately.
Saving and Closing Objects
As changes are made to the object’s data, Access saves the changes automatically. Changes to
the layout of the object are NOT automatically saved. To save all changes, use the Save As
option for an unsaved new object or the Save option for a previously opened or saved object.
Clicking the Close Button closes the object.
Compacting and Repairing a Database
As records are removed and others are added, the database may become fragmented. Or,
databases may sometimes become damaged. To fix these situations, use the Manage option
from the Office Button and click the Compact and Repair Database option.
Closing a Database and Exiting Access
Use the Close option from the Office Button to close a database. To exit, either use the Exit
option from the Office Button or click the close button on the title bar.
Microsoft Access
9
Lesson 2 Creating a Database
In addition to a blank database option, Access provides templates for specific data types such as
Assets, Contacts, Issues, Events, etc. When using one of these templates, Access creates tables,
forms, queries, and reports automatically. Most of the time, you will use the Blank Database
option
The blank database will begin with a blank table.
From here, you can add fields to the table. Clicking the Save option from the Office Button
prompts a name for the table. The new table will include the ID field which is the default
primary field. The primary field is the field which will be unique for each record in the table.
The primary field can be changed later.
Microsoft Access
10
Upon clicking the Save Button or
opening another table or closing
the database, will prompt a save
of the table:
Entering Field Names
Field names can be added by double clicking the field name text box and typing the name of
the field. Pressing the Tab key creates another field box. After all field names have been
entered, pressing the Tab key twice will end the entry of field names.
The Open/Close Shutter Button will make the navigation pane open or close.
Microsoft Access
11
Data Types
Entering Records in Database View
Changing a Field’s Data Type in Datasheet View
Typing a name in a field automatically sets that field to a text data type. Typing a date in a field
causes that field to be set to a date data type. Entering numbers in a field sets that field to a
number data type.
To change a field’s data type, select that field and click the data type arrow and choose the
desired data type.
Microsoft Access
12 Working in Design View
Click the View Button in the Views Group in the ribbon
Choose the Design option
In this view you can change a field’s data type, name, and its properties. You can also assign a
primary key to a field.
Adding, Deleting, Renaming, and Rearranging Fields in Design View
The position of fields can be
changed by clicking and dragging
the record selector up or down the
list
Fields can be renamed by double-
clicking the name and keying in the
new name for the field
Current Field
Design Grid
Field Properties Pane
Primary Key Symbol
Microsoft Access
13 Fields can be added by selecting the field where the new field should go and then clicking the Insert Rows button in the ribbon
The data type can be changed or created by clicking the Data Type Arrow and choosing the desired data type for the field
Microsoft Access
14 After designating the data type, pressing the Tab Key highlights the Description Property box. This is optional and is used to explain the field’s function.
Changing Field Properties in Design View
Depending upon the field’s data type, it is given certain properties. Field Properties describe a
field’s contents beyond the data type.
Field Size
Text – Maximum number of characters allowed in the field
Numbers – Default is long integer (large negative and positive numbers)
o Can also choose integer, single, double, byte, Replication ID, and decimal
o Choose integer or long integer for whole numbers
o Choose either single or double for decimal numbers
Choose a size as small as possible that still has capacity for the maximum number
After changing the field size, a message will appear saying that data contents may
change as a result
You cannot undo field size after saving the table
Double click the
current field size to
select it
Retype the new size
In number data
types, a down arrow
will allow you to
choose the field size
Microsoft Access
15
Field Format
The field format determines how data will be displayed. It is changed in the Format Property.
The date data type includes a down
arrow in the Format option that
includes several ways to show dates.
When a field has a description it will appear in the status bar on the left side.
Setting a Field’s Default Value
This property determines what the value for a field will be whenever a new record is added to
the table.
Microsoft Access
16
The Required Property
Setting this property
means that every record
must have a value in that
field.
Adding a record without this field will result in an Access error message
Changing this value will result in an Access message stating that it is checking every record
to be sure they all comply
with this rule upon saving
the table.
The default value is NO
Microsoft Access
17 Lesson 3 Creating Queries A query is an Access object that asks questions of the database. The questions are called
criteria or conditions that Access uses to pull certain records out of the table(s).
Click the Query Wizard button in the Other group in the ribbon.
Choose the Simple Query Wizard option in the
New Query window.
In the Tables/Queries dialog, choose the
table for which the query should be
created.
The fields in that table will then appear in
the Available Fields dialog.
Microsoft Access
18
Choose the fields in the chosen
table that are desired in the query
and press the Select Single Field
button to send that field into the
Selected Fields window.
Then, click the Next button.
Choose the Detail (shows every field of
every record) button.
Click the Next button.
Key the name of the query in the name
box.
Choose the Open the query to view
information option
Click the Finish button.
Microsoft Access
19
The query datasheet opens with the
contents of the chosen fields listed.
Sorting Data
Sorting data means to order the contents of the query numerically or alphabetically keyed upon
the chosen field in either ascending or descending order using the appropriate sort buttons.
Microsoft Access
20 Filtering Data
Filtering means to display only those records that fit the criteria.
Select the value of the field in a given record
Click the Selection button
o Choose the criteria from the resulting list
Click the Toggle Filter button to filter the data as per the selections
To refine the filter further, double click a word in the criteria and repeat the process:
Microsoft Access
21 Click the Selection button
Click the Contains … button from the drop-down list
Clicking the Toggle Filter button turns the filter off and allows all records to appear
Clearing All Filters
Click the Advanced Button
Choose the Clear All Filters option
Microsoft Access
22 Advanced Filter
Choose the Advanced button in the Sort & Filter group in the ribbon
Choose the Filter By Form option
Choose the down arrow in the field from which the filter should come
Choose the value to filter on
Click the Toggle Filter button
The records containing that value in that field will appear
Microsoft Access
23 Sorting From the Filter By Form
Choose the Field Header down arrow
Choose the type of sort
Creating a Query in Design View
In the Create Tab, choose the Query Design button.
In the Show Table Dialog, choose the table(s) you want to include in the query Click the Add button to add the table to the query Click the Close button to close the Show Table Dialog
Microsoft Access
24 Double click the table name header
in the table(s) to be used in the query o All of the table fields will then
be selected
Drag any of the selected field names into the first column of the query and all of the fields will be added to the query
Click the Save button in the quick access toolbar and name the query as you would like it to be called
Moving and Sorting Fields in Design View
Click the bar at the top of
a column to move (this
will select that column)
Click and drag the bar to
the desired new position
of the column
Release the left button to
drop it into place
Microsoft Access
25 To sort on a field:
Click in that field’s Sort Box
Click the resulting down-arrow
Choose Ascending, Descending, or Not Sorted(to turn the sort
off)
To do a sub-sort (In the event the primary sort runs into an equal value):
Follow the same procedure in another column in the grid
Adding a Criteria to a Field
To limit the query to a certain value in a given field:
Click in the Criteria Box in the field containing the desired value and type that value in
Click the
TAB key to
set the
value (it
will be
enclosed
in quotes)
Running the Query
Save the query
Click the Run button in the Results Group in the Design Tab
Microsoft Access
26 The query results shows with the data sorted as requested (in this case, ascending by
data and descending by Order Number)
Creating Table Relationships
Relationships between tables can only be accomplished if the tables have a Matching
Field, that is, a field with the same data type, field name, and data in it.
Most relationships are a one-to-many relationship
o One record of the primary table can match many records in the related table
Table relationship rules are called Referential Integrity which protects data in the tables
from being accidentally deleted or changed
o Use the Enforce Referential Integrity option when creating the relationship
Click the Relationships
button located in the
Database Tools tab
Microsoft Access
27 Click the Show Tables
button
In the Show Tables
Dialog, choose the
tables to include in
the relationship
o Click Add to
include each
individual one
In the example to the left, the
matching field is the Product ID field
Drag from the matching field listing in
one table to the matching field listing
in the other
Check the Enforce Referential
Integrity box
Click Create
The relationship is made
Close the Relationship Tools Design tab
Choose Yes to save the relationship
Microsoft Access
28 Viewing Related Records
Open the primary table
Click the expand indicator (plus sign) for any record(s) in the matching field
o Those records in the related table matching that entry will be displayed
Creating a Multitable Query
Click the Query Design button from the Create Tab
Microsoft Access
29 Click on the tables to
include in the query,
clicking the Add button
after each selection
Double click the field listing in any of the tables that are desired to be in the query
In the example to the
left, the Order Number
field in the Orders Table
was double clicked, as
were the other fields in
the Products Table
o It does not
matter from
which table the
matching field is
chosen as its
values are
identical
Set the criteria and sorting options as desired
Press the Tab key
Choose the Save button
Click the Run button to see the results of the query
Microsoft Access
30 The query to the left
uses the listed records
from the two related
tables to list all of the
records by Product
Name in ascending
order that have a
Units In Stock value of
zero
Using Operators in a Condition
The criteria below was changed to list those items with Units In Stock greater than 5
Below is an example of a query with Units In Stock greater than 5 AND Retail Price less than
$20
Microsoft Access
31 Below is an example of a query with Units in Stock greater than 5 OR Retail Price less than $20
Calculating Data
Calculated fields are fields that represent the result of a calculation. For instance, the current
date minus birth date equals age.
Create a query and add the desired tables as before
Double on the tables’ field names to add the desired fields to the query
Right Click in the field header to contain the calculation
o Choose the Zoom option
Microsoft Access
32 Key in the desired calculation (below is an example of the quantity ordered times the
unit price) in the Zoom Dialog
Click OK
Save the query and run it
The results appear below:
Microsoft Access
33 To change the name of the field from Expr1 to Order Line Total
o Change to the Design View using the View Button
o Double click on the Expr1 TEXT ONLY
o Key in the text Order Line Total
o Press the Tab Key
o Save and run the query to see the new field label
Use the Manage – Compact and Repair Database options from the Office Button to be
sure all data integrity is assured and close the database
Microsoft Access
34 Creating and Modifying Forms Forms represent data in a more manageable, concise way. They are created based upon the
data in tables or queries. These tables or queries are called the record source. Forms created
with tools are opened in Layout View.
The split form tool creates a form with the control objects (text boxes and labels) at the top and
the data table or query at the bottom.
Choose the table or query
to be the record source for
the form
Click the Form button in
the Create tab on the
ribbon OR
Split Form Button to
create a split form OR
More Forms button to see
additional options such as
a datasheet form
Right clicking on the open form’s
tab allows you to save or close and
rename any form(s) that are open.
Microsoft Access
35 The Form Wizard walks you through the creation of a form.
Click the down arrow on
the More Forms button to
see the Form Wizard option
Choose the desired table or query to be the record source
Use the Select All Fields
button to designate all of
the fields in the table to
appear in the form OR
Use the Select One Field
button to select only the
field selected
Click the Next button when
all selections have been
made
Choose the type of table desired
Click the Next button
Microsoft Access
36 Choose one of the many
form styles available
Click the Next button
Name the form
Choose the view in which to
open it
Click the Finish button
Microsoft Access
37 Navigating a Form
The Record Navigation Bar includes buttons and text boxes to move within the records in the
record source:
Highlighting the contents of the Record Box and typing a record number in it will bring
that record up in the form
Using a Form to Find an Replace Data
Highlight the word to find
Click the Find button in the Find Group on the ribbon
Clicking Find Next will open
the next record that matches
the criteria
Here, the Affiliation field
must have McCormack in it in
order to match the criteria
First Record
Button
Previous Record
Button
Current
Record Box
Next Record
Button
Last Record
Button
New Record
Button
Microsoft Access
38 Here, if Any Part of the Field contains the word, it will be shown
Click Find Next to see
the next record that
matches the criteria
Keep clicking until
Access gives you a
message saying that it
is at the end of its
search.
Clicking the Replace
Tab allows you to not
only find an entry but
replace it with a
different entry
Here, McCormack will
be replaced with
Greene
Using a Form to Update Data
Click to highlight text to
be edited
Type the new text
Press the Tab Key to
make the change
Microsoft Access
39 Add a New Record
Click the New Button in the Records Group in the Home Tab
A new blank record
appears, into which
data can be
entered
After entering all of
the new data, press
the Tab Key to add
the record to the
data sheet and
display a new blank
record
Opening the record
source shows that the
new record has been
added
Close the form to make
the addition permanent
Microsoft Access
40 Using a Form to Delete Data
Deleting an entry in a field can be undone but once an entire record is deleted, it can only be
re-entered by typing its
data in again.
Open the form
again
Highlight the text
to be deleted
Click the Delete
Button in the
Records Group
The selected text is
deleted but can be
gotten back with
the undo button
To delete a record,
click the down arrow
in the Delete Button
and choose the Delete
Record option
The dialog at the left appears
Click the Yes button to allow
Access to delete the record
Microsoft Access
41 Creating and Modifying a Form in Layout View
Choose the Blank Form button from the
Create tab
The Field Listings pane appears
o Click the + to expand the listing
Double click the listing(s) needed in the form
o That label and text box control appears in the form
Microsoft Access
42 In the Fields Available in Related Tables pane, click the expand ( + ) button to see the
fields in tables related to the original table used
o Double click any that you would like to include in the form
Below, we double clicked the First Name field in the Brokers Table listing and it
appeared as a combo box in the form
Clicking the Property Update Options button allows you to change the combo box to a
text box.
Continue this procedure until all of the related table fields are included in the form
Click the Add Existing Fields button to finish creation of the form
Microsoft Access
43 Adding a Title to a Form and Changing its Format
Choose the Layout View from the Views
Button on the ribbon
Choose the Title Button from the Format
Tab on the ribbon
The default
heading appears
and can be
changed
You can then change the font
attributes from the Font Group
in the ribbon to suit your needs
o Bold, Italics, Underline
o Font Color
o Fill Color
o Etc.
Microsoft Access
44 Resizing a Control in a Form
Choose the control you wish to resize
Point to the edge of the control
where you wish to make a change
When a double arrow appears
o Left click and drag it the
direction you wish to go
o The number of characters the
new control size can handle
appears in the status bar at
the bottom left
Moving a Control in a Form
Click on any control you wish to move
o Hold the shift key while clicking on
additional controls to select them all
Click the Remove Button in the Arrange tab to
remove all selected controls
o The labels and text boxes are all
selected with an orange outline
Microsoft Access
45
Click and drag the
selected controls to the
location where you would
like to place them
Adding an Unbound Control to a Form in Design View
Go to Design
View
Click and drag
the bottom of
the Form Footer
down (in this
case, about ½
inch)
Microsoft Access
46
Click the Label
Button
Point to the area
in the footer
where you would
like to place the
label
o Left Click
Type your name
in the text box
Press Enter
The name will
appear on the
form
Microsoft Access
47
Previewing and Printing a Form
Use the Office Button – Print – Print
Preview combination to see what the
printed form would look like.
Microsoft Access
48
The print option allows
you to print all of the
pages or choose a
range.
Microsoft Access
49 Creating and Modifying Reports
Using the Report Tool
Select the table or query for which
you want to create a report
Choose the Report Tool from the
Create Tab on the ribbon
o All of the fields in the table are
included in the report
Save the report
Using the Label Wizard
Highlight the table or
query for which you
would like to make a
report
Choose the Labels
option from the
Create Tab
Choose the type of
label desired
Click Next
Microsoft Access
50
Choose the text
properties desired
Click Next
Double click the
field names you
desire to be
included in the
label
o Be sure to
include
spaces and
commas
between
fields as
desired
o Press Enter to add a line on the label
Click Next
Microsoft Access
51 Choose the field(s) you
would like to use to sort
the records for the
labels
Here, we sort by Last
Name
Click Next
Name the label report
Choose to See the labels
as they will look printed
if everything has been
configured to your
liking, otherwise, the
Modify the Label Design
option will allow you to
make changes
Click Finish when
completed
The list
document
appears as it
would be
printed
Close the Print
Preview
Microsoft Access
52 Close the report document
using the X in the upper
right hand corner
Using the Report Wizard
Choose the Report Wizard
button from the Create Tab
on the ribbon
Choose the table(s) or
query(s) desired
Double click on the field
names to be included in the
report
Click Next
Microsoft Access
53
If there are fields from
more than one table or
query in the report,
choose the one by
which you want the
data to be viewed
Choosing a different
one may result in the
report being grouped in
several levels
Click Next
If you don’t want to add another grouping, click
Next
Microsoft Access
54
Choose the field upon
which you would like to
sort the report
o You can include up
to four fields
Click Next
Choose the Layout and
the Orientation desired
Click Next
Choose the desired Style
Click Next
Microsoft Access
55 Key in the desired name for
the report
Choose to Preview the
Document
Click Finish
The report document appears
Microsoft Access
56
Clicking the Shutter Bar Open/Close Button opens
and closes the task pane
Using the Zoom – Fit to Window options from the ribbon, resizes the report so the
entire sheet will appear
Microsoft Access
57 Modifying the Report in Layout View
Click the Layout View button in the Status Bar
Or
Choose the Layout View option in the Views Group of
the ribbon
Select the field header of the field you wish
to adjust
Point to the right border of the header
until the double arrow appears
Drag the border until the desired number
of characters appears in the status bar at
the lower left
Microsoft Access
58 Modifying a Report in Design View
Choose the View – Design
View options from the
ribbon
Report Header – Printed once at the top of the first page of the report
Page Header – Printed at the top of each page of the report
Group Header – Printed at the beginning of each new group of records
Detail – Printed once for each row in the record source. Contains main body.
Group Footer – Printed at the end of each group of records and usually includes
summary options
Page Footer – Printed at the bottom of each page. Usually includes page numbers etc.
Report Footer – Printed once at the bottom of the last page of the report. Usually
includes grand totals etc.
Microsoft Access
59 Adding a Line to a Report
Point to the bottom of the area to add the line (In this case – the Report Header
Drag down to widen the area
Choose the Line Tool and, while holding the SHIFT key, drag a line where desired
Use the Thickness Tool to
choose a line thickness
Use the Line Type tool to
choose a line type
Use the Line Color tool to
change the color
Microsoft Access
60 Adding a Label Control to a Report
In Design View, click the
Label Tool
Point to the area in
which the label should
be placed
Left click to insert the
label
Type the text desired
(In this case, we insert a label in the Page Footer area)
Moving a Control in Design View
Any control can be moved to a different location by pointing to it and, when the 4-way arrow
appears, left click and drag to the new location.
Setting a Report Property
Report properties are listed to the right of the report in the properties task pane.
Click the Property Sheet button in the Tools Group in the ribbon
Select the text in the line for the property desired and change it
Below, the current Width setting is selected
Change it to the new width to make
it printable
Press the Tab Key
Microsoft Access
61 Now, the entire report fits on one sheet of paper in Landscape Orientation
Adding a Picture
to a Report
In Design
View, click the
Logo Button
The Insert
Picture Dialog
appears
Microsoft Access
62 Drag the
image to the
location
desired
Prior to closing a database after it is saved,
choose the Compact and Repair Database
option from the Manage option from the
Office Button.