Advanced Access 2003
Advanced Access 2003
Table of Contents
Page
LESSON 1: INTRODUCTION..............................................................................................1
Parameter Queries 4
Crosstab Queries 7
Statistical Queries 12
Calculated Fields 14
Action Queries (Make Table, Update, Append,
Delete) 17
LESSON 4: SWITCHBOARDS.........................................................................................33
Creating a Switchboard 33
Edit the Switchboard Form 37
Creating a Macro 41
Create a Command Button 44
Display Options 48
LESSON 6: GIVE IT A TRY!............................................................................................50
NICE TO KNOW......................................................................................................................53
Mouse Pointers 53
Toolbar Buttons 54
Keyboard Shortcuts 56
This workbook may be reproduced in whole or in part by an employee of the Department of Health and Human
Services. All other reproduction is prohibited unless written permission is obtained from the Training Institute.
LESSON 1: INTRODUCTION
OBJECTIVES: Discuss Access output capabilities.
Recognize the impact of data entry on output.
Tables are the basis for all objects in an Access database. Data can be entered
either directly into a table, or into a form, which passes data on to the table.
Data can be described as the raw facts and figures that are input, but
information is more likely what you want to get out of your database.
Information takes data and makes it meaningful. For example, data could be
the cities where classes are held. Information based on those cities could
include how many classes are held in a given city, or how many different
cities offer classes.
When you are looking for information from your tables, a variety of tools are
available to help you find the specific information you need. You may simply
need to scroll through the records in the table or form, use the Find tool, or
filter the data as necessary. However, Access provides you with more
streamlined methods for extracting information from your database.
Queries allow you to ask a question of your data. The answer to that question
appears as a group of records matching certain criteria, and displaying only
specific fields. These results are called a dynaset in Access.
Reports display the results of a query or show selected fields from a table,
whose records may be grouped and sorted as desired. While all objects
created in an Access database may be printed, reports are specifically
designed for printing.
There is a commonly used phrase related to databases that is, “Garbage in,
garbage out.” If the data being entered is inaccurate or inconsistent, the
information extracted will also be inaccurate or inconsistent. It is very
important to realize this fact as you make decisions based on data output.
Another important aspect of the relationship between data entry and output is
that you cannot take out what has not been put in. If the data has not been
collected and entered, there is no way to pull information based on that data
out of your database. Therefore, it is essential that you are very familiar with
the content of your database. You should know the fields that exist in each
table, how tables are related, how data is collected and entered, and who is
responsible for data entry. It is impossible to generate meaningful and
accurate queries and reports without this knowledge.
Classes
Instructors
Students
Students, continued…
STEPS
Helpful Hint:
1. Create a SELECT QUERY and include the fields you wish to have
You must
appear in your query results.
always use
square brackets
2. Set any standard criteria for the query, if applicable.
around the text
you want in
3. In the criteria line of the field(s) for which you wish to set parameters,
your parameter
type the question you want Access to ask in its dialog box. For
query.
example, in the criteria line for the City field, type:
However, you
cannot use text
[Enter City]
that exactly
matches a field
name in your
database.
Also, you can
use a colon (:)
at the end of
your message,
but not a
period (.), as it
4. To create a parameter query that allows you to type just the first
causes an error
letter or two of the entry, type the following:
to occur.
Like[Enter and your field name:]&*
If you want to
be able to type
any portion of
the field entry,
type Like
*&[dialog box
prompt]&* in
6. Look through your results, and return to DESIGN VIEW, if
thenecessary,
Criteria line.
to make any further adjustments.
Lesson Example
Your supervisor would like to know how many students are taking classes
from different locations. She would also like to see how many Social
Workers are taking classes in Portland, as well as other locations and
classifications. Instead of creating 35 queries to look up each location and
each classification, you decide that a parameter query would answer the
questions.
STEPS
2. Open the Advanced Access file (your instructor will give you the
location).
10. Run the query again, this time typing Portland in the dialog box.
EXERCISE:
STEPS
3. Identify the table you want to use for the query. Click NEXT.
4. Select the field(s) that you want to use for row headings. You can
identify up to three fields. Click NEXT.
Text fields in a
CROSSTAB
QUERY will not
have as many
calculation
options as
numeric fields.
6. Identify the field that you want to be calculated, and how you want it
calculated. Click NEXT.
Crosstab queries
are depicted
with an
icon in the
Queries object
window.
Lesson Example
You are curious about how many students take classes in each city by
classifications.
STEPS
1) Create a query in design view that has the Students, Join and You can go into
Classes table with the following fields: DESIGN VIEW
Classes: Title for a
ClassID CROSSTAB
Students: Classification QUERY and
change row and
2) Run the query. column
headings.
3) Name the query Classification Class Breakdown and close it.
Statistical Queries
OVERVIEW
STEPS
1. Create a new query and add the appropriate fields, or use an existing
query.
3. In the field that you want to perform the calculation, click in the
TOTAL line, and select from several calculations that are listed.
TOTAL will default to GROUP BY, which defines the groups where
you want to perform the calculations. For example, to show material
costs by class title, select GROUP BY for the Title field.
You want to create a query to calculate how many students are enrolled in
each class, and how much money students are paying in material fees per
class.
STEPS
2. Click the TOTALS button. This will give you a new line called
TOTAL in the QBE grid at the bottom of the query window.
ClassID – GROUP BY
Title – GROUP BY
MaterialCost – SUM
StudentID - COUNT
4. Run the query. Save as Total Material Costs and close it.
EXERCISE:
1) Create a query in Design View using the Title and LabFee fields
from the Classes table. Sum the lab fees for any classes that
have them. Save as Classes With Lab Fees. (Hint: Use the
Sum statistical function and type >0 in the Criteria field for
LabFee).
Calculated Fields
OVERVIEW
In addition to the statistical queries that calculate groups of records, there are
other types of calculations you can perform in a query that modify individual
fields. For example, you can multiply the values in two fields, or calculate
the date three months from the current date. When you display the results of
a calculation in a field, the results aren't actually stored in the underlying
table.
STEPS
1. Create a new query and add the appropriate fields, or use an existing
query.
When working
with percentages
in calculations,
type 0.10
instead of 10%.
Helpful Hint:
If you type an
expression and
get a parameter
box when you
run the query, it
means that one
of the field
names is
misspelled and
correct it in the
formula.
Lesson Example
STEPS
EXERCISE:
Normally, the majority of the queries you will create are Select queries. You It is a good
specify criteria and run the query, it tallies the data and displays the results in idea to save all
datasheet view. Occasionally, you may need the query to do more, such as queries as
make a new table, or add data from one table into another; those tasks require select queries,
an action query to be built. An action query is a query that makes changes to not as action
many records in just one operation. There are four types of action queries: queries. This
make-table, update, append, and delete. prevents other
users from
o Make-Table Query: Creates a new table from all or part of the data accidentally
in one or more tables. Make-table queries are helpful for: running an
action query
Creating a table to export to other Microsoft Access by opening it.
databases. For example, you might want to create a table that
contains several fields from your Employees table, and then export
that table to a database used by your personnel department.
STEPS
1. Create a query using the necessary fields from the appropriate table.
2. RUN the query and note how many records there are. Save the query.
o To create an APPEND query, identify which table you want to Did You Know?
append into, and click OK.
The
DATASHEET
VIEW button
will allow
you to see what
data will be
affected by the
action query
without actually
carrying out the
action. To run
the query, you
o To create a DELETE query, indicate any criteria that will identify
must click the
the records to be deleted in the CRITERIA row. WHERE appears
RUN button.
under all fields, FROM will appear if an entire table is sent to the
QBE grid.
6. Click the RUN button . Access will perform the action query that
you requested. You may have to click YES if a message box appears
(depends on the action query selected).
Lesson Example
You want to split the Students table, so that you can use the data for other
purposes, without recreating it. Create a table for Clerk Typist II’s using
the MAKE-TABLE feature.
STEPS
1. Create a query in DESIGN VIEW. Use all of the fields from the
Students table. Save the query as Make Clerk Typist II
Students.
6. Name the new table Clerk Typist II Students and place it in this
database. Click OK.
7. Click the RUN button, then click YES. Access will create a new
table called Clerk Typist II Students and will tell you how many
records got pasted into it.
8. Save the query, close the query and notice the icon for a MAKE-
TABLE QUERY.
9. Click on the TABLES object in the OBJECTS bar and see that the
new table has been placed there.
3) View the Students table to see that 5 new records were added.
Notice that information is inserted only where the field names
were an exact match.
4) Material Costs will be 10% less than they are now. Create a
new query in Design View based on the Classes table to it. Use
the ClassID, Title, and MaterialCost fields. Save as Update
Material Costs.
6) View the Classes table to see that the material costs have
decreased 10%.
STEPS
1. To move a text box and its label, click on the box once. Move your
mouse pointer so that it is between any of the handles (small black
boxes on the perimeter). When you see a little hand , click and drag
the field to the new location.
2. To move a text box or label, click on the box once. Move your
cursor to the upper left corner. When you see a pointing hand , click
and drag the field to the new location.
3. To resize a control (a.k.a. box), click on the box once. Move your
cursor so that it is over one of the handles. When you get the double
headed arrow mouse pointer , , or , click and drag to resize.
5. To add color to the text of a selected control, click the TEXT button
on the toolbar to color the text, or use the drop-down arrow to
choose another color.
6. To add color to a line, select the line and click the LINE button
on the toolbar to change the effect of the line, or use the drop-
down arrow to choose another color.
11. Select the new background that you want. Click OK.
12. Click the PRINT PREVIEW button on the toolbar to see the
report
Lesson Example
STEPS
4. Click in the Detail section to select it, then click the arrow next to
the FILL/BACK COLOR button and select navy blue.
5. Select all the text boxes in the Detail section by holding down
Shift and clicking on each box.
6. Change each text box font color to white by clicking on the arrow
next to the FONT/FORE COLOR button and selecting white.
8. Click the PRINT PREVIEW button to view the report and then
close.
EXERCISE:
2) On Your Own: Make any other manual changes you like to the
report. Save your changes.
3. Click the check box below the calculation (SUM, AVG, MIN, MAX)
you would like to use for the field(s) you would like to compute in the
report.
Writing Expressions
OVERVIEW
Just like you can perform calculations in queries, you can perform them in a
report. The results of the calculations are not stored in any table.
STEPS
3. Click the TEXT BOX button on the Toolbox Toolbar, and then
click on the new location.
4. To change the label name, click and drag over the Text # (the label)
and add a new label name, or you may want to get rid of it entirely by
deleting it.
5. To add an expression in the text box, click the text box, and type the
new expression (Example: =[Hours]*[Hourly Wage]).
6. To use the expression builder to help create the formula, click the
PROPERTIES button on the toolbar.
Build button
8. To get help with the expression, click the BUILD button to the
right.
Lesson Example
Create a report that will calculate each student’s material costs and lab
fees.
STEPS
5. Place your mouse at the top of the PAGE FOOTER bar, with the
two-headed arrow, click and drag down to make the STUDENTID
FOOTER approximately ¼ inch larger.
6. Click the TEXT BOX tool, and then click in the StudentID footer
section and below the Sum of Material Cost text box.
7. Click and drag over the label and rename it Total Costs.
11. Click on the text box and click the BOLD button. You may need
to resize your text box to accommodate the data.
14. Click on the PROPERTIES tool, and click on the FORMAT tab.
15. Select CURRENCY from the drop down list in the FORMAT row.
16. Save, view, and then close the Student Costs report.
EXERCISE:
Concatenation
OVERVIEW
You can use the concatenation feature to combine two fields into one,
seamlessly, so that gaping spaces are eliminated. One common area where
concatenation is used is to combine the First Name field with the Last Name
field to eliminate problems with huge spaces between those fields. (Example:
MARIA MATTISON)
STEPS
1. Select a report and then click the DESIGN VIEW button on the
toolbar.
Helpful Hint: 2. Click the TEXT BOX button , and then click on the new location.
You may type 3. Click and drag over the label and add a new label name, or you may
the expression want to get rid of it entirely by deleting it.
directly into the
text box if you 4. Click on the text box. Click the PROPERTIES button on the
prefer. toolbar.
5. Click on the DATA tab, and click in the CONTROL SOURCE field.
Build button
7. Scroll down in the listing of controls that are on your report (middle
panel). Double click FirstName (not FirstName_ Label), type a &“
”& (ampersand quote space quote ampersand), and double click
LastName, as shown below.
Lesson Example
You want the students’ first and last names to appear at the top of each
page in the Student Transcript report. But, when you add the text boxes
there is a huge gap between the two fields.
STEPS
2. Click on the PAGE BREAK button and then click in the lower
right-hand corner of the STUDENTID FOOTER.
3. Click the TEXT BOX button, and then click below the Zip label in
the STUDENTID HEADER section.
4. Click and drag over the label and add the new label name
Student:.
6. Click on the DATA tab, click the CONTROL SOURCE field, and
then click the BUILD button to the right.
7. Scroll down the list of controls that are in your report (middle
panel). Double-click FirstName (not FirstName_ Label).
EXERCISE:
2) Move the Address label and textbox directly below the Student:
label.
3) Add another text box below the address that concatenates the
City, State, and ZIP fields.
LESSON 4: SWITCHBOARDS
OVERVIEW
A switchboard is a form that may contain buttons that you can click to open
other forms and reports, exit Access, or even customize the switchboard to
meet specific needs. A switchboard gives the user direct access to the major
tasks performed in the database and can be used to deny access to certain
areas in the database.
Creating a Switchboard
OVERVIEW
STEPS
Lesson Example
You want to create a switchboard for your database. We’ll add the
Students form, as well as the Students report.
STEPS
5. Click NEW.
7. Click NEW.
10. View your switchboard by clicking the FORMS object and double
clicking the SWITCHBOARD form. Close the form.
EXERCISE:
Once you have created your switchboard, you can customize it so that it looks
like your other forms and gives the database a professional look.
STEPS
Helpful Hint:
Do not delete
the controls
where
switchboard
items will be
displayed, or
the
switchboard
will not work
properly.
Lesson Example
STEPS
EXERCISE:
Creating a Macro
OVERVIEW
When you create a macro, you record the actions that you want to carry out.
Unlike Word or Excel, Access doesn’t allow you to perform the steps to
record them, you need to type the action arguments in, for this reason you
may find that it is helpful to do the steps and write them down. That way,
when you create the macro, it will be easier to remember all of the steps.
STEPS
1. Click the MACROS button in the object window, and then click NEW.
2. In the first row, click the drop-down arrow to choose the action you
want.
7. To create a macro that will automatically run when the Access file
is opened, name the macro Autoexec.
Lesson Example
You want to create a macro that will open the RegisterStudents form
maximized, in a new record, so that it will make entering new students
and registering them for classes easier.
STEPS
1. Click on the MACRO button on the OBJECTS bar, and then click
NEW.
4. In the next ACTION row, click the drop down arrow and select
MAXIMIZE.
STEPS
5. Click NEXT.
7. To have the button display text, type the text in the TEXT line.
9. Click NEXT.
10. Type a name for the command button and click FINISH.
Display Options
You may want to have a command button on your form that will print the
current record. If you do not want the button to print along with the form,
then you need to change the display properties.
STEPS
Lesson Example
You want to create a button that will print out the current form.
STEPS
6. Click NEXT.
8. Click NEXT.
EXERCISE:
6) Set the button properties to only display on the screen, save the
form and return to Form View.
EXERCISE:
2) Create a crosstab query to find out how much each location will
generate in Material Costs. Use Location as the Row Heading;
Title as the column heading, and Sum MaterialCost.
3) Use the Material Cost per Location query. Save as Material Cost
per Location_Crosstab.
4) Create a query based on the Classes table that will show Title,
Material Cost and Lab Fee. Create a calculated field that will add
together material costs and lab fees. Save as Total Fees.
6) Create a report using the wizard based on all the fields in the Total
Student Fees query. Group it by Title, make it Landscape
orientation, and add an expression that will give totals for fees for
each class. In Design View, arrange fields so they fit better on the
page. Save it as Total Student Fees.
8) Update the colors on the switchboard and add different clipart and
graphics to the buttons.
9) Create a new macro that will open up the Total Fees query and
view it in Design View. Name it Total Fee Update.
STEPS
Lesson Example
Delete the Autoexec macro, the Student Costs report and the copy of the
Advanced Access database that we worked on today.
STEPS
Mouse Pointers
Text Selector - appears while among text; click to place insertion point or
click and drag to select a section of text
Field Selector - appears on the left side of a field in Datasheet View; click to
select the contents of the field
Column Selector - appears when pointing at field names in Datasheet View;
click to select an entire row
Row Selector - appears in the gray box to left of a record in Datasheet View;
click to select the entire record
Column Resize - appears between field names in Datasheet view or on a
vertical border in Design View of a Form or Report; click and drag to increase
or decrease width
Row Resize - appears on a horizontal border in Design View of a Form or
Report; click and drag to increase or decrease height
Normal Select - allows you to click to choose an object; also allows you to
click and drag a rectangle to select a group of objects
Move - in Design View of a Form or Report, this pointer appears when you
point at the middle a selected control; click and drag to move the control
Move Separately - appears when pointing at the upper left corner of a selected
control; allows you to click and drag a label separately from a text box and
vice versa
Horizontal Resize - appears when you point at a resizing handle (small black
square) on the edge of a control; click and drag away from the object to
enlarge, toward the object to make smaller
Diagonal Resize - see above
Add Label - appears when the Label tool is selected in the Toolbox; click to
insert a standard label, or click and drag to draw a specific size
Add Text Box - when the Text tool is selected in the Toolbox, this mouse
pointer will appear; click to insert a standard text box and label, or click and
drag to draw the size you desire
The View buttons change the perspective of the active object. This button
allows you to go to Design View of any object.
This View button sends you to Datasheet View of a Table or Report.
Page 54
AutoFilter removes any record not including the selected entry.
Filter by Form allows you to filter records by more than one entry.
The Filter button becomes activated when AutoFilter is used. Pushing this
button will remove the current filter. When Filter by Form is used, this
button will turn on the filter once criteria are established, then turn it off
when you wish to see all records.
Find lets you search for an entry.
New Record sends you to a blank record for data entry. Some databases
require a different button to be used.
Delete Record will remove the active record.
Database Window will place the Database Window in front of any other
open windows. You may also use the F11 key.
The Primary Key button will establish the active field as the unique
identifier of the records in a table.
Page 55
Keyboard Shortcuts
Keystroke
Effect
Combination
F1 Opens Access Help
F6 Moves from Design Grid of Table to Properties section
F9 Updates the active object
F11 Brings the Database Window to the front
Tab Moves you ahead one field
Shift + Tab Moves you backward one field
Enter Moves you ahead one field
Spacebar Toggles a checkmark on and off in a Yes/No field
Ctrl + Alt + down
Opens a drop-down list
arrow
Ctrl + Tab Moves you out of a subform to the next form field
Ctrl + Home Sends you to the beginning of the first record
Ctrl + End Sends you to the end of the last record
Ctrl + ‘ Copies the previous record's entry into the current field
Home Sends you to the beginning of the active record
End Sends you to the end of the active record
Arrow (Cursor) Keys Send you one field in the arrow's direction
Page 56