Presentation is loading. Please wait.

Presentation is loading. Please wait.

Exploring Microsoft® Access® 2016 Series Editor Mary Anne Poatsy

Similar presentations


Presentation on theme: "Exploring Microsoft® Access® 2016 Series Editor Mary Anne Poatsy"— Presentation transcript:

1 Exploring Microsoft® Access® 2016 Series Editor Mary Anne Poatsy
Exploring Microsoft Office 2016 Series Editor Mary Anne Poatsy Cameron |Williams Series Created by Dr. Robert T. Grauer

2 Copyright © 2017 Pearson Education, Inc.
Chapter 6 In Chapter 6, you will learn how to use action queries to update, add, and delete data and create queries for specific purposes. Action and Specialized Queries Moving Beyond the Select Query Copyright © 2017 Pearson Education, Inc.

3 Copyright © 2017 Pearson Education, Inc.
Objectives Determine When to Use an Action Query Update Data with an Update Query Add Records to a Table with an Append Query Create a Table with a Make Table Query Delete Records with a Delete Query Summarize Data with a Crosstab Query Find Duplicate Records with a Query Find Unmatched Records with a Query The objectives for this chapter are: Determine When to Use an Action Query Update Data with an Update Query Add Records to a Table with an Append Query Create a Table with a Make Table Query Delete Records with a Delete Query Summarize Data with a Crosstab Query Find Duplicate Records with a Query Find Unmatched Records with a Query Copyright © 2017 Pearson Education, Inc.

4 Objective 1: Determine When to Use an Action Query
In this section, the skills include: Back Up a Database Skills:  Back Up a Database Copyright © 2017 Pearson Education, Inc.

5 Determine when to Use an Action Query
Action query—changes data Action query types: Update—changes data automatically based on criteria Append—adds records to a table from external sources Make table—creates a new table from existing data Delete query—removes records from a table based on criteria An action query changes data. There are four types of action queries: An update query is used to update or change data automatically based on specified criteria. An append query is used to add records to an existing table from sources such as an external database or a spreadsheet. A make table query automatically creates a new table from data that already exist in a database. A delete query automatically removes records from a table based on specified criteria. Because an action query changes data, Access displays a warning message. When using an action query, you should back up a database before you apply such a query. Copyright © 2017 Pearson Education, Inc.

6 Objective 2: Update Data with an Update Query
In this section, the skills include: Create an Update Query Test an Update Query Skills:  Create an Update Query  Test an Update Query Copyright © 2017 Pearson Education, Inc.

7 Update Data with an Update Query
Click Update Update to today Remember an update query changes the data values in one or more fields for all records that meet the specified criteria. For example, the Information System Management (ISM) will change its name to Computer Information Systems (CIS), which means all ISM courses like ISM101 will now be designated by CIS and the course will now be called CIS101. First you should backup your database, run a select query to see the results, and then run an update query. After testing your select query, view the select query in Design view, click Update in the Query Type group, and then enter the new value into the Update To row. In this example, orders with missing order dates will be updated to the current date. Missing OrderDate Copyright © 2017 Pearson Education, Inc.

8 Update Data with an Update Query
Required field Before running an update query, you can verify that the correct number of records will be updated by switching to Datasheet view. Once you have verified the data, click Run, and then click Yes to the warning message. Copyright © 2017 Pearson Education, Inc.

9 Objective 3: Add Records to a Table with an Append Query
In this section, the skills include: Create an Append Query Skills:  Create an Append Query Copyright © 2017 Pearson Education, Inc.

10 Add Records to a Table with an Append Query
Click Append Select destination table Remember an append query copies records from one or more tables—the source(s)—and adds them to an existing table—the destination. The appended records display in the destination table in primary key order, or if no primary key exists, then they are added to the bottom of the table. As was done with the update query, a selection query should be created first, data examined, and then an append query is created. Click Append in the Query Type group, click the table name arrow, select the destination table, and then click OK. In this example, former employee records are moved from the Employees table to the Former Employees table. Show row Copyright © 2017 Pearson Education, Inc.

11 Add Records to a Table with an Append Query
Append To row When a select query is converted to an append query, Access removes the Show row in the query design grid and adds the Append To row in its place. If the fields in the source and destination tables are the same, Access automatically inserts the correct field names into the Append To row. Field names in source and destination Copyright © 2017 Pearson Education, Inc.

12 Objective 4: Create a Table with a Make Table Query
In this section, the skills include: Create a Make Table Query Skills:  Create a Make Table Query Copyright © 2017 Pearson Education, Inc.

13 Create a Table with a Make Table Query
Click Make Table Enter table name Remember a make table query selects records from one or more tables and uses them to create a new table. Creating a make table query is similar to creating an append query. The difference is that a make table query creates the structure of the table and then adds the records to that table, where as an append query requires the destination table to already exist. You can use the make table query to copy some or all records from a source table to a destination table even if the destination table does not exist. If the destination table exists and you run the make table query, you will be prompted before the original table is deleted. After testing with a select query, you click Make Table in the Query Type group, specify the name of a new or existing table that you want to create in the Table Name box, and then click OK. Copyright © 2017 Pearson Education, Inc.

14 Objective 5: Delete Records with a Delete Query
In this section, the skills include: Create a Delete Query Skills:  Create a Delete Query Copyright © 2017 Pearson Education, Inc.

15 Delete Records with a Delete Query
Click Delete Order Data table Remember a delete query selects records and removes them from a table. Because of the destructive nature of this query, be sure you create a backup copy of the database prior to running a delete query. After testing with a select query, you click Delete in the Query Type group. Prior to running the query, switch to Datasheet view, verify that the previewed records are correct, return to Design view, click Run, and then click Yes when the warning message appears. In this example, all sales made on 6/10/2018 will be removed from the Order Data table. Delete row Copyright © 2017 Pearson Education, Inc.

16 Objective 6: Summarize Data with a Crosstab Query
In this section, the skills include: Use the Crosstab Query Wizard Modify a Crosstab Query Skills:  Use the Crosstab Query Wizard  Modify a Crosstab Query Copyright © 2017 Pearson Education, Inc.

17 Summarize Data with a Crosstab Query
Zak Behnke Access has three specialized queries that you can use to group and summarize data, find mismatched records, and locate duplicate records. The first of these is discussed in this objective. A crosstab query summarizes a data source (which can be a table or a query) into a grid of rows and columns. A crosstab query is usually created to show trends in values over time. The grouping in a crosstab query comes from the definitions of row and column headings. A field selected as a row heading displays values from that field along the left side of a crosstab query datasheet. A column heading displays values from a selected field name along the top of a crosstab query. The summarizing or aggregating data in a crosstab query are displayed at the intersection of the rows and columns. In this example, the salespersons’ names are displayed along the left side of the crosstab query, and their total revenue, 2nd quarter, and 3rd quarter sales are displayed along the top of the query. Looking at the query, we can see that Zack Behnke had a total revenue of and quarterly sales of and Copyright © 2017 Pearson Education, Inc.

18 Summarize Data with a Crosstab Query
The easiest way to build a crosstab query is to use the Crosstab Query Wizard. As with other wizards, a series of questions are asked, and you respond with the correct entries. To display the Crosstab Query Wizard, click the Query Wizard in the Queries group on the Create tab. Note the other two choices are the queries that we will look at in the next two objectives. Click Crosstab Query Wizard in the New Query dialog box, and then click OK. In the first step in the crosstab Query Wizard, you identify the data source, where one of the tables is Employees. The other table will be OrderData. Copyright © 2017 Pearson Education, Inc.

19 Summarize Data with a Crosstab Query
Select the fields for the row headings—LastName and FirstName. Select the fields for the column headings—OrderDates Copyright © 2017 Pearson Education, Inc.

20 Summarize Data with a Crosstab Query
Specify the Date/Time Interval, which in this example is quarterly. Select the value to be summarized, which in this example is the summation of the Revenue field. In the last step, you name the query with the option of viewing the query or modifying the design. Copyright © 2017 Pearson Education, Inc.

21 Summarize Data with a Crosstab Query
To modify a crosstab query, switch to Design view and then you can change row and column heading fields, modify the aggregate function, or alter the field selection for the aggregate calculation. You can include additional row heading fields and modify properties, fields, and field order for a crosstab query as you would in any select query. In this modified crosstab query, the grouping is changed from salespersons’ names to product categories. Copyright © 2017 Pearson Education, Inc.

22 Objective 7: Find Duplicate Records with a Query
In this section, the skills include: Create a Find Duplicate Records Query Using the Wizard Skills:  Create a Find Duplicate Records Query Using the Wizard Copyright © 2017 Pearson Education, Inc.

23 Find Duplicate Records with a Query
The second of the specialized Access queries is the find duplicates query, which helps identify duplicate values in a table. In this example we will search for duplicate customer addresses. In the New Query dialog box shown in Slide 18, you select Find Duplicates Query Wizard. In the first step in the Find Duplicate Query Wizard, you select the table or query that may have duplicate records, which will be the Customer table. Next we select the field to search for duplicates, which will be the customer’s address, which consists of the BillingAddress, City, State, and PostalCode fields. Copyright © 2017 Pearson Education, Inc.

24 Find Duplicate Records with a Query
Like the crosstab query, in the last step, you name the query with the option of viewing the query or modifying the design. As you can see, there are several duplicate records, where the first three are indicated on the slide. Note this query only identifies the duplicate records, it does not delete them. You have to delete them yourself. Copyright © 2017 Pearson Education, Inc.

25 Objective 8: Find Unmatched Records with a Query
In this section, the skills include: Create a Find Unmatched Query Using the Wizard Skills:  Create a Find Unmatched Query Using the Wizard Copyright © 2017 Pearson Education, Inc.

26 Find Unmatched Records with a Query
The last of the specialized Access queries is the find unmatched query, which compares records in two related tables and displays the records found in one table but not the other. In this example, we will find which items in the inventory have no sales. In the New Query dialog box shown on the left in Slide 18, you select Find Unmatched Query Wizard. The first step in the Find Unmatched Query Wizard, you select the table that will serve as the primary table source for this query, which will be the Inventory table. Next we select the second table that contains the related records, which is the OrderItem. Copyright © 2017 Pearson Education, Inc.

27 Find Unmatched Records with a Query
Next we select the common field, which is the SKU, and then select the output fields, which will be the PartID, SKU, and OnHandQty. Copyright © 2017 Pearson Education, Inc.

28 Find Unmatched Records with a Query
Like the two previous queries, in the last step, you name the query with the option of viewing the query or modifying the design. The final figure shows the inventory items that have not been sold. Copyright © 2017 Pearson Education, Inc.

29 Copyright © 2017 Pearson Education, Inc.
Summary Access provides action queries, which change the data You should always backup a database before performing these queries Access has specialized queries that help to analyze and improve the integrity of the data in a database Access provides action queries, which change the data by updating—Update Query, adding—Append Query and Make a Table Query, and deleting data—Delete Query. Because action queries alter a database, you should always backup the database before performing these queries. Access has specialized queries that help you to analyze and improve the integrity of the data in a database. These queries are used to group and summarize data—Crosstab Query, locate duplicate records—Find Duplicate Records Query, and find mismatched records—Find Unmatched Query. Copyright © 2017 Pearson Education, Inc.

30 Copyright © 2017 Pearson Education, Inc.
Questions ? It is important to understand how to use action queries to change data and how to create queries that analyze and improve the integrity of the data. Are there any questions? Copyright © 2017 Pearson Education, Inc.

31 Copyright Copyright © 2017 Pearson Education, Inc.


Download ppt "Exploring Microsoft® Access® 2016 Series Editor Mary Anne Poatsy"

Similar presentations


Ads by Google