SESSION Action Queries - In this session we will
explore the 4 types of action queries.
8.2
Microsoft Access 2000 Class #6
The Major Steps of a
MicroSoft Access Database






Tables
Queries
Forms
Macros
Reports
Modules
On our road map, we are here!
Queries can do more than display
answers to the questions you ask;
they can also perform actions on the
data in your database.
Once you understand the basics of
Select Queries, Action Queries are
very simple, yet extremely
Action queries, combined with
macros, can literally make your
day! With Action queries and
macros you can automate many of
the tedious actions that once took
hours or even days to complete.
An Action Query is a query that
adds, changes, or deletes multiple
table records at one time.
Before you can create an Action
Query however, you must first
create a Select Query, testing the
query by “Viewing” the datasheet.
Once you are satisfied that the
query is going to act on only the
records that you have selected, then
you can convert the query to an
Action Query.
This is done from the Select Query’s
design window. All that you need to do is
select the appropriate query type from
the query type button on the tool bar.
By clicking on the selection arrow to the
right of the button, you will see a list of
query types that can be used
Action Queries come in four flavors.
Make Table Query
Append Query
Delete Query
Update (modify) Query
A “Make Table” query creates a new table from one
or more existing tables.
The new table can be an exact copy of the
records in an existing table.
The new table can be a subset of the fields and
records of an existing table.
The new table can be a combination of the fields
and records from two or more tables.
To create a Make Table
query, first, right click on an
existing query in the
Database window.
Then select Design View from
the resulting Short Cut Menu.
Access will then open the query
in the design view, and your are
ready to begin converting it to a
Make Table Query.
Step two is to click on the Queries type button on
the tool bar and then select Make-Table Query.
Alternatively you can click on the Query Option
from the Menu Bar and then select Make-Table
Query. The choice is yours, either way is the same.
Special Customers
You will then be prompted for the name of the new
table that you are making. Enter the name an then
click on the OK button.
This will bring you back to the
design view. The only change that
you will see is the type of query on
the tittle bar. It will now say Make
Table Query instead of Select Query.
At this point, all that we have done is
to create the Action Query. We still
must Run the query in order to
make the Action happen.
Before we Run the query however,
what is it that we must do in order to
test it?
We really should View the query in its
datasheet view first, just to make sure
that the criteria is set up correctly.
The final step, once we know that it will
act upon only the records that we want it
to, is to Run the Query.
Once we click “Yes” the Action Query
will do its thing and return us to the
Design view of the Query. To see if it
really worked, you can press the F11
Function key which will show us the
database window.
Click on the Tables Tab to View the Tables
The new table will be shown in the list of Table Objects.
To return to the design view of your query, simply left
click in the gray area of the query that is in the back
ground.
An “Append Query” adds records from an existing
table or query to the end of another table.
For an append query, you choose the fields you
want to append from one or more tables or queries;
the selected data remains in the original tables.
The data that you selected, will be added to the end
of another already existing table.
To create an Append query,
first, right click on an existing
query in the Database
window.
Then select Design View from
the resulting Short Cut Menu.
Access will then open the query
in the design view, and your are
ready to begin converting it to
an Append Query.
Step two is to click on the Queries type button on
the tool bar and then select Append Query.
Alternatively you can click on the Query Option
from the Menu Bar and then select Append Query.
The choice is yours, either way is the same.
Special Customers
You will then be prompted for the name of the table
that you are appending the data to. Enter the name
an then click on the OK button.
This will bring you back to the
design view. The only change that
you will see is the type of query on
the tittle bar. It will now say Append
Query instead of Select Query.
At this point, all that we have done is
to create the Action Query. We still
must Run the query in order to
make the Action happen.
Before we Run the query however,
what is it that we must do in order to
test it?
We really should View the query in its
datasheet view first, just to make sure
that the criteria is set up correctly.
The final step, once we know that it will
act upon only the records that we want it
to, is to Run the Query.
Once we click “Yes” the Action Query
will do its thing and return us to the
Design view of the Query. To see if it
really worked, you can press the F11
Function key which will show us the
database window.
Click on the Tables Tab to View the Tables
Open the table that you appended the data to. You should
see the additional records at the end.
To return to the design view of your query, simply left
click in the gray area of the query that is in the back
ground.
Delete and Update Queries are Created,
Tested and Run in much
the same way.
Let’s consider this
important note of
interest however. The Make-Table and
Append Queries, will copy data from
already existing tables and place the data
in either a new table or another already
existing table.
Delete and UpDate Queries will modify
the data in the table that
they are based on, rather
than acting on other tables.
A “Delete Query” deletes a group of records
(or all records) from one or more tables. You
choose which records you want to delete by
entering selection criteria.
Deleting records
removes them
permanently from the
database.
When you create a delete query, one additional row
in created in your design grid.
Figure 8-19
Design View for the Delete Query
Delete Row inserted
Selection criteria
An “Update” query changes selected
fields and records in one or more tables.
You choose the fields and records you
want to change by entering the selection
criteria and the update rules.
An update query will
permanently modify
data in the database.
As with a Delete Query, when you create an UpDate
Query a new row is added to your design grid.
Figure 8-22
Updating the Contact Field
UpDate Expression
Selection criteria
The Expression Builder
If you need help creating a complicated expression,
you can create it using the Expression Builder.
Page AC 8.28
The Expression Builder
The Expression Builder is an Access tool that contains
an expression box in which the expression is entered,
The Expression Builder
buttons for common operators used in an expression,
The Expression Builder
and one or more lists of expression elements, such as
table and field names.
The Expression Builder
The Expression Builder is activated by first clicking
in the Field that you want the expression in and then
clicking on the expression builder button on the
ToolBar.
Quick Check Review
Page AC 8.30
Quick Check
Review
Let’s take a few
moments to break up
into discussion groups.
Each group will discuss
the quick check questions on Page AC 8.30
in your books. We will then review the
answers at the end of the discussion.
Quick Check Review
Session 8.2
1) What is an action query?
Quick Check Review
Session 8.2
2) What precautions should you
take before running an action
query?
Quick Check Review
Session 8.2
3) What is the difference between
a make-table query and an append
query?
Quick Check Review
Session 8.2
4) What does a delete query do?
Quick Check Review
Session 8.2
5) What does an Update Query do?
Quick Check Review
Session 8.2
6) How does the design grid
change when you create an update
query?
Quick Check Review
Session 8.2
7) What is the Expression Builder?
Here we go
again !
The staff at Valle Coffee have just
finished their weekly meeting and
as you can expect, there are more
questions
than ever to
be answered!
Your task today is to complete the
exercises in Tutorial #8 Tutorial #8
Page A8.04 through Page A8.30
Tutorial #8
Level 3 Disk1
Dining.mdb
Please make a note that the disks
to use for today’s class are:
Tutorial #8
Level 3 Disk1