CHAPTER 3 Access More Skills 14 Use a Query to Find Unmatched Data Unmatched data is a condition where the data in one field does not have a corresponding value in a related table. The Find Unmatched Query Wizard quickly compares the common fields from two related tables and displays all records that do not have a corresponding value. To complete this database, you will need the following file: a03_spa_services You will save your file as: a03_spa_services_your_name 1. Start Access, and then open a03_spa_services. Save the database in your Access Chapter 3 folder as a03_spa_services_your_name If the security message displays, enable the content. 2. Display the Database Tools tab, and then in the Show/Hide group, click the Relationships button. Compare your screen with Figure 1. The relationship between the Spa Services and Spa Appointments tables is an indeterminate relationship. Indeterminate relationship Figure 1 Microsoft Access Chapter 3 - Creating Queries and Reports More Skills: SKILL 14 Page 1 of 6
3. Right-click the Relationships line that joins the Spa Services and Spa Appointments tables. In the displayed shortcut menu, click Edit Relationship. If the Edit Relationship command does not display on the menu, click a blank area in the Relationships window, and then try again. 4. In the displayed Edit Relationships dialog box, select the Enforce Referential Integrity check box, and then click OK. Compare your screen with Figure 2. The message indicates that because there are unmatched records, a relationship with referential integrity cannot be created. Referential integrity can t be created Unmatched records may exist Figure 2 5. In the displayed message, click OK. Clear the Enforce Referential Integrity check box, and then click OK. 6. Right-click the Relationships line that joins the Spa Services and Spa Appointments tables. In the displayed shortcut menu, click Delete. If the Delete command does not display on the menu, click a blank area in the Relationships window, and then try again. Read the displayed message, and then click Yes. 7. Display the Create tab, and then in the Other group, click the Query Wizard button. 8. In the displayed New Query dialog box, select Find Unmatched Query Wizard, and then click OK. Compare your screen with Figure 3. Microsoft Access Chapter 3 - Creating Queries and Reports More Skills: SKILL 14 Page 2 of 6
Spa Appointments table selected Figure 3 9. Click Next, and then select Table: Spa Services as shown in Figure 4. In this screen, the table that will be searched for unmatched records is selected. Table: Spa Services selected Figure 4 Microsoft Access Chapter 3 - Creating Queries and Reports More Skills: SKILL 14 Page 3 of 6
10. Click Next, and then under Fields in Spa Appointments, select Service. Click the Compare Fields button, and then compare your screen with Figure 5. The query will search the Spa Appointments table for appointments that offer services that are not listed in the Spa Services table. Service fields designated as matching fields Figure 5 11. Click Next, and then click the Move All button. 12. Click Next, and then in the What would you like to name your query box, type Unmatched Services Your Name Click Finish, and then compare your screen with Figure 6. The query results indicate that 24 appointments were made for the Massage: Swedish service. For this service, no match was found in the Services table. Microsoft Access Chapter 3 - Creating Queries and Reports More Skills: SKILL 14 Page 4 of 6
Massage: Swedish service is unmatched Figure 6 13. From the Office menu, point to Print, and then click Print Preview. In the Page Layout group, click Landscape. 14. If your instructor asks you to print this project, print the datasheet. 15. Click Save, and then in the Close Preview group, click the Close Print Preview button. 16. Close the query. In the Navigation Pane, double-click the Spa Services table to open it in Datasheet view. 17. Locate the record with the Service currently displayed as Message: Swedish. Change the spelling of Message to Massage 18. Close the table. In the Navigation Pane, double-click the Unmatched Services Your Name query to run the query and display the datasheet. No records should display. If any records do display, carefully check your typing from the previous step and correct as needed. Close the query. 19. In the displayed Relationship window, drag the Service field from the Spa Services table to the Service field in the Spa Appointments table. Microsoft Access Chapter 3 - Creating Queries and Reports More Skills: SKILL 14 Page 5 of 6
20. In the displayed Edit Relationships dialog box, select the Enforce Referential Integrity check box, and then click Create. Compare your screen with Figure 7. A one-to-many relationship with referential integrity is created. One-to-many relationship created Figure 7 21. Display the Design tab, and then in the Tools group, click the Relationship Report button. 22. If your instructor asks you to print your work, print the relationships report. 23. Click Save, and then in the displayed Save As dialog box, click OK. 24. Close the report, Close the Relationships window, and then Exit Access. You have completed More Skills 14 Microsoft Access Chapter 3 - Creating Queries and Reports More Skills: SKILL 14 Page 6 of 6