© Paradigm Publishing, Inc. 1 Access 2010 Level 2 Unit 1 Advanced Tables, Relationships, Queries, and Forms Chapter 3 Advanced Query Techniques © Paradigm Publishing, Inc. 2 Advanced Query Techniques Quick Links to Presentation Contents Extract Records Using Select Queries Modify Join Properties in a Query CHECKPOINT 1 Create and Use Subqueries Select Records Using a Multiple-Value Field Perform Operations Using Action Queries CHECKPOINT 2 © Paradigm Publishing, Inc. 3 Extract Records Using Select Queries A select query is the type of query most often used in Access. Select queries extract records from a single table or from multiple tables according to criteria that you specify. © Paradigm Publishing, Inc. 4 Extract Records Using Select Queries…continued A filter is used in a datasheet or form to temporarily hide records that do not meet specified criteria. The subset of records can be edited, viewed, or printed. A filter is active until it is removed or until the datasheet or form is closed. © Paradigm Publishing, Inc. 5 Extract Records Using Select Queries…continued To save a filter as a query: 1. Open the table. 2. Filter the table as desired. 3. Click the Advanced Filter Options button in the Sort & Filter group in the Home tab. 4. Click the Filter By Form option at the drop-down list. continues on next slide… © Paradigm Publishing, Inc. 6 Filter By Form option Extract Records Using Select Queries…continued 5. Click the Advanced Filter Options button in the Sort & Filter group in the Home tab. 6. Click the Save As Query option in the drop-down list. continues on next slide… Save As Query option © Paradigm Publishing, Inc. 7 Extract Records Using Select Queries…continued 7. At the Save As Query dialog box, type the desired query name. 8. Click OK. 9. Close the Filter By Form datasheet. 10. Close the table. © Paradigm Publishing, Inc. Save As Query dialog box 8 Extract Records Using Select Queries…continued In a parameter query, specific criteria for a field are not stored with the query design. Instead, the field(s) used to select records have a prompt message that displays when the query is run. Enter Parameter Value dialog box © Paradigm Publishing, Inc. 9 Extract Records Using Select Queries…continued The message in the dialog box is created in the field to which the criterion will be applied. When the query is run, the user types the criterion at the Enter Parameter Value dialog box. Access then selects the records based on that criterion. If more than one field contains a parameter, Access prompts the user one field at a time. © Paradigm Publishing, Inc. 10 Extract Records Using Select Queries…continued To create a parameter query: 1. 2. 3. 4. 5. 6. 7. 8. 9. Start a new query in Design view. Add the desired table(s). Close the Show Table dialog box. Add the desired fields to the query design grid. Click in the Criteria row of the field to be prompted. Type the message text, encased in square brackets. Repeat Steps 5-6 for each additional criteria field. Save the query. Close the query. © Paradigm Publishing, Inc. 11 Criteria row Modify Join Properties in a Query The term join properties refers to the way in which Access matches the values in the common fields between two tables in a relationship. Access provides for three join types in a relationship: an inner join, a left outer join, and a right outer join. © Paradigm Publishing, Inc. 12 Modify Join Properties in a Query…continued To create a query with an inner join: 1. Create a new query in Design view. 2. Add the tables to the query window. 3. Double-click the join line between the tables. 4. At the Join Properties dialog box, click OK. 5. Add the desired fields to the query design grid. 6. Save and run the query. © Paradigm Publishing, Inc. 13 Join Properties dialog box Modify Join Properties in a Query…continued To create a query with a left outer join: 1. Create a new query in Design view. 2. Add the tables to the query window. 3. Double-click the join line between the tables. 4. At the Join Properties dialog box, click option 2. 5. Click OK. 6. Add the desired fields to the query design grid. 7. Save and run the query. © Paradigm Publishing, Inc. option 2 14 Modify Join Properties in a Query…continued To create a right outer join: 1. Create a new query in Design view. 2. Add the tables to the query window. 3. Double-click the join line between the tables. 4. At the Join Properties dialog box, click option 3. 5. Click OK. 6. Add the desired fields to the query design grid. 7. Save and run the query. © Paradigm Publishing, Inc. 15 option 3 Modify Join Properties in a Query…continued To remove a table from a query: 1. Open the query in Design view. 2. Right-click the table. 3. Click the Remove Table option at the shortcut menu. © Paradigm Publishing, Inc. Remove Table option 16 Modify Join Properties in a Query…continued To create a self-join query: 1. Create a new query in Design view. 2. Add two copies of the same table to the query. 3. Right-click the second table name. 4. Click the Properties option. continues on next slide… © Paradigm Publishing, Inc. Properties option 17 Modify Join Properties in a Query…continued 5. Click in the Alias property box and delete the existing table name. 6. Type the alias table name. 7. Close the Property Sheet. Alias property box continues on next slide… © Paradigm Publishing, Inc. 18 Modify Join Properties in a Query…continued 8. Drag the field name from the left table to the field name in the right table that contains the matching values. 9. Add fields to the query design grid as required. 10. Run the query. 11. Save the query. field name © Paradigm Publishing, Inc. 19 Modify Join Properties in a Query…continued If a query is created from two tables for which no join is established, Access will not know how to relate the records in each table. In the absence of a relationship, Access produces a datasheet representing every combination of records between the two tables. This type of query is called a cross product or Cartesian product query. If you add two tables to a query and no join line appears, create a join by dragging a field from one table to a compatible field in the other table. © Paradigm Publishing, Inc. 20 1) This is the type of query most often used in Access. a. append b. select c. update d. make-table Answer 3) The Advanced Filter Options button is located in this tab. a. Home b. Create c. External Data d. Database Tools Answer Next Question 2) This is used to temporarily hide records that do not meet specified criteria. a. screen b. section c. filter d. sort Answer Next Question 4) By default, Access uses this type of join between tables. a. inner b. outer c. left d. right Answer Next Question © Paradigm Publishing, Inc. Next Slide 21 Create and Use Subqueries When performing multiple calculations based on numeric fields, you may decide to create a separate query for each individual calculation and then use subqueries to generate the final total. A subquery is a query nested inside another query. Using subqueries to break the calculations into individual objects allows you to reuse a calculated field in multiple queries. © Paradigm Publishing, Inc. 22 Create and Use Subqueries…continued To nest a query within a query: 1. Start a new query in Design view. 2. At the Show Table dialog box, click the Queries tab. 3. Double-click the query to be used as a subquery. 4. Add other queries or tables as required. 5. Close the Show Table dialog box. 6. Add fields as required. 7. Save and run the query. © Paradigm Publishing, Inc. 23 Queries tab Select Records Using a Multiple-Value Field To show a multiple-value field in separate rows in a query: 1. Open the query in Design view. 2. Click in the Field list box of the multiple-value field in the design grid. 3. Move the insertion point to the end of the field name. 4. Type a period. 5. Press Enter to accept the .Value property. 6. Save the query. © Paradigm Publishing, Inc. 24 Field list box Perform Operations Using Action Queries Query Type Description Make Table A new table is created from selected records in an existing table. For example, you could create a new table that combines fields from two other tables in the database. Append Selected records are added to the end of an existing table. This action is similar to performing a copy and paste. Update A global change is made to the selected group of records based on an update expression. For example, you could increase the labor rate by 10 percent in one step. Delete A selected group of records is deleted from a table. © Paradigm Publishing, Inc. 25 Perform Operations Using Action Queries…continued To create a make-table query: 1. Create the query in Design view. 2. Add the desired table to the query. 3. Add the desired fields to the query design grid. 4. Enter the criteria to select records. 5. Run the query. 6. Switch to Design view. 7. Click the Make Table button in the Query Type group in the Query Tools Design tab. Make Table button continues on next slide… © Paradigm Publishing, Inc. 26 Perform Operations Using Action Queries…continued 8. Type a table name. 9. At the Make Table dialog box, select the destination database. 10. Click OK. 11. Run the query. 12. Click Yes. 13. Save the query. © Paradigm Publishing, Inc. Make Table dialog box 27 Perform Operations Using Action Queries…continued A delete query is used to delete, in one step, a group of records that meet specific criteria. You can use this action query in any instance in which the records you want to delete can be selected using a criteria statement. © Paradigm Publishing, Inc. 28 Perform Operations Using Action Queries…continued To delete records using a query: 1. 2. 3. 4. 5. 6. 7. 8. Right-click the make-table query. Click the Design View option at the shortcut menu. Click the Delete button in the Query Type group in the Query Tools Design tab. Click the File tab. Click Save Object As. Type the name and click OK. Run the query. A the Microsoft Access message, click Yes. © Paradigm Publishing, Inc. Microsoft Access message 29 Perform Operations Using Action Queries…continued To add records to a table using a query: 1. 2. 3. 4. 5. 6. 7. 8. Open the make-table query in Design view. Click the Append button in the Query Type group in the Query Tools Design tab. At the Append dialog box, click OK. Click the File tab. Click Save Object As. Type the name and click OK. Run the query. A the Microsoft Access message, click Yes. © Paradigm Publishing, Inc. 30 Append dialog box Perform Operations Using Action Queries…continued To create an update query: 1. 2. 3. Create the query in Design view. Add the desired table to the query. Add the desired fields to the query design grid. 4. Enter the criteria to select records. 5. Run the query. 6. Switch to Design view. 7. Click the Update button in the Query Type group in the Query Tools Design tab. 8. Click in the Update To box in the field to be changed. 9. Type the update expression. 10. Run the query. 11. Click Yes. 12. Save the query. © Paradigm Publishing, Inc. 31 Update To box 1) This is a query nested inside another query. a. make-table query b. update query c. append query d. subquery Answer Next Question 2) With this type of query, selected records are added to the end of an existing table. a. update b. delete c. append d. select Answer Next Question © Paradigm Publishing, Inc. 3) This type of query is used to delete, in one step, a group of records that meet specific criteria. a. update b. delete c. append Answer d. select Next Question 4) With this type of query, a global change is made to a selected group of records based on an expression. a. update b. delete c. append Answer d. select Next Slide 32 Advanced Query Techniques Summary of Presentation Concepts Save a filter as a query Create and run a parameter query to prompt for criteria Add tables to and remove tables from a query Create an inner join, left join, and right join to modify query results Create a self-join to match two fields in the same table Create a query that includes a subquery Assign an alias to a table and a field name Select records using a multiple-value field in a query Create a new table using a make-table query Remove records from a table using a delete query Add records to the end of an existing table using an append query Modify records using an update query © Paradigm Publishing, Inc. 33
© Copyright 2025 Paperzz