Using Action Queries

72
SESSION 8.2 Action Queries - In this session we will explore the 4 types of action queries. Microsoft Access 2000 Class #6

description

SESSION 8.2. Action Queries - In this session we will explore the 4 types of action queries. Using Action Queries. 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!. - PowerPoint PPT Presentation

Transcript of Using Action Queries

Page 1: Using Action Queries

SESSION 8.2

Action Queries - In this session we will explore the 4 types of action queries.

Microsoft Access 2000 Class #6

Page 2: Using Action Queries

TheThe MajorMajor Steps of a Steps of a MicroSoft Access MicroSoft Access

DatabaseDatabase TablesTables QueriesQueries FormsForms MacrosMacros ReportsReports ModulesModules

On our road map, we are here!On our road map, we are here!

Page 3: Using Action Queries

Queries can do more than display answers to the questions you ask; they can also perform actions on the data in your database.

Page 4: Using Action Queries

Once you understand the basics of Select Queries, Action Queries are very simple, yet extremely

Page 5: Using Action Queries

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.

Page 6: Using Action Queries

An Action Query is a query that adds, changes, or deletes multiple table records at one time.

Page 7: Using Action Queries

Before you can create an Action Query however, you must first create a Select Query, testing the query by “Viewing” the datasheet.

Page 8: Using Action Queries

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.

Page 9: Using Action Queries

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.

Page 10: Using Action Queries

By clicking on the selection arrow to the right of the button, you will see a list of query types that can be used

Page 11: Using Action Queries

Action Queries come in four flavors.

Make Table QueryAppend QueryDelete QueryUpdate (modify) Query

Page 12: Using Action Queries

A “Make Table” query creates a new table from one or more existing tables.

Page 13: Using Action Queries

The new table can be an exact copy of the records in an existing table.

Page 14: Using Action Queries

The new table can be a subset of the fields and records of an existing table.

Page 15: Using Action Queries

The new table can be a combination of the fields and records from two or more tables.

Page 16: Using Action Queries

To create a Make Table query, first, right click on an existing query in the Database window.

To create a Make Table query, first, right click on an existing query in the Database window.

Page 17: Using Action Queries

Then select Design View from the resulting Short Cut Menu.

Then select Design View from the resulting Short Cut Menu.

Page 18: Using Action Queries

Access will then open the query in the design view, and your are ready to begin converting it to a Make Table Query.

Page 19: Using Action Queries

Step two is to click on the Queries type button on the tool bar and then select Make-Table Query.

Step two is to click on the Queries type button on the tool bar and then select Make-Table Query.

Page 20: Using Action Queries

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.

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.

Page 21: Using Action Queries

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.

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.

Page 22: Using Action Queries

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.

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.

Page 23: Using Action Queries

At this point, all that we have done is to create the Action Query. We still must RunRun the query in order to make the Action happen.

At this point, all that we have done is to create the Action Query. We still must RunRun the query in order to make the Action happen.

Page 24: Using Action Queries

Before we RunRun the query however, what is it that we must do in order to test it?

Before we RunRun the query however, what is it that we must do in order to test it?

Page 25: Using Action Queries

We really should View the query in its datasheet view first, just to make sure that the criteria is set up correctly.

We really should View the query in its datasheet view first, just to make sure that the criteria is set up correctly.

Page 26: Using Action Queries

The final step, once we know that it will act upon only the records that we want it to, is to RunRun the Query.

The final step, once we know that it will act upon only the records that we want it to, is to RunRun the Query.

Page 27: Using Action Queries
Page 28: Using Action Queries

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 F11F11 Function key which will show us the database window.

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 F11F11 Function key which will show us the database window.

Page 29: Using Action Queries

Click on the Tables Tab to View the Tables

The new table will be shown in the list of Table Objects.

Page 30: Using Action Queries

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.

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.

Page 31: Using Action Queries

An “Append Query” adds records from an existing table or query to the end of another table.

Page 32: Using Action Queries

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.

Page 33: Using Action Queries

The data that you selected, will be added to the end

of another already existing table.

Page 34: Using Action Queries

To create an Append query, first, right click on an existing query in the Database window.

To create an Append query, first, right click on an existing query in the Database window.

Page 35: Using Action Queries

Then select Design View from the resulting Short Cut Menu.

Then select Design View from the resulting Short Cut Menu.

Page 36: Using Action Queries

Access will then open the query in the design view, and your are ready to begin converting it to an Append Query.

Page 37: Using Action Queries

Step two is to click on the Queries type button on the tool bar and then select Append Query.

Step two is to click on the Queries type button on the tool bar and then select Append Query.

Page 38: Using Action Queries

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.

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.

Page 39: Using Action Queries

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.

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.

Page 40: Using Action Queries

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.

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.

Page 41: Using Action Queries

At this point, all that we have done is to create the Action Query. We still must RunRun the query in order to make the Action happen.

At this point, all that we have done is to create the Action Query. We still must RunRun the query in order to make the Action happen.

Page 42: Using Action Queries

Before we RunRun the query however, what is it that we must do in order to test it?

Before we RunRun the query however, what is it that we must do in order to test it?

Page 43: Using Action Queries

We really should View the query in its datasheet view first, just to make sure that the criteria is set up correctly.

We really should View the query in its datasheet view first, just to make sure that the criteria is set up correctly.

Page 44: Using Action Queries

The final step, once we know that it will act upon only the records that we want it to, is to RunRun the Query.

The final step, once we know that it will act upon only the records that we want it to, is to RunRun the Query.

Page 45: Using Action Queries
Page 46: Using Action Queries

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.

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.

Page 47: Using Action Queries

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.

Page 48: Using Action Queries

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.

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.

Page 49: Using Action Queries

DeleteDelete and UpdateUpdate Queries are Created, Created, TestedTested and RunRun in muchthe same way.

Let’s consider thisimportant note ofinterest 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.

Page 50: Using Action Queries

DeleteDelete and UpDateUpDate Queries will modifymodify the data in the table thatthey are based on, ratherthan acting on other tables.

Page 51: Using Action Queries

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.

Page 52: Using Action Queries

Figure 8-19 Design View for the Delete Query

Selection criteriaSelection criteria

Delete Row insertedDelete Row inserted

When you create a delete query, one additional row in created in your design grid.

Page 53: Using Action Queries

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.

Page 54: Using Action Queries

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

Selection criteriaSelection criteria

UpDate ExpressionUpDate Expression

Page 55: Using Action Queries

The Expression BuilderThe Expression Builder

If you need help creating a complicated expression, you can create it using the Expression Builder.

Page AC 8.28

Page 56: Using Action Queries

The Expression BuilderThe Expression Builder

The Expression Builder is an Access tool that contains an expression box in which the expression is entered,

Page 57: Using Action Queries

The Expression BuilderThe Expression Builder

buttons for common operators used in an expression,

Page 58: Using Action Queries

The Expression BuilderThe Expression Builder

and one or more lists of expression elements, such as table and field names.

Page 59: Using Action Queries

The Expression BuilderThe 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.

Page 60: Using Action Queries

Page AC 8.30

Quick Check ReviewQuick Check Review

Page 61: Using Action Queries

Quick Check Quick Check ReviewReview

Let’s take a fewmoments to break upinto discussion groups.Each group will discussthe quick check questions on Page AC 8.30Page AC 8.30 in your books. We will then review the answers at the end of the discussion.

Page 62: Using Action Queries

Quick Check Review Quick Check Review Session 8.2Session 8.2

1) What is an action query?

Page 63: Using Action Queries

Quick Check Review Quick Check Review Session 8.2Session 8.2

2) What precautions should you take before running an action query?

Page 64: Using Action Queries

Quick Check Review Quick Check Review Session 8.2Session 8.2

3) What is the difference between a make-table query and an append query?

Page 65: Using Action Queries

Quick Check Review Quick Check Review Session 8.2Session 8.2

4) What does a delete query do?

Page 66: Using Action Queries

Quick Check Review Quick Check Review Session 8.2Session 8.2

5) What does an Update Query do?

Page 67: Using Action Queries

Quick Check Review Quick Check Review Session 8.2Session 8.2

6) How does the design grid change when you create an update query?

Page 68: Using Action Queries

Quick Check Review Quick Check Review Session 8.2Session 8.2

7) What is the Expression Builder?

Page 69: Using Action Queries

Here we goagain !

Page 70: Using Action Queries

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!

Page 71: Using Action Queries

Your task today is to complete the exercises in Tutorial #8 Tutorial #8 Page A8.04 through Page A8.30

Tutorial #8Level 3 Disk1Dining.mdb

Page 72: Using Action Queries

Please make a note that the disks to use for today’s class are:

Tutorial #8Level 3 Disk1