COURSE DESCRIPTION Course Name Queries in Microsoft Access Audience need This course is designed for users with a to create queries in Microsoft Access. Prerequisites * Keyboard and mouse skills * An understanding of basic Windows and basic Access skills Objectives the Duration Upon successful completion of this class, participant will be able to: * Create a simple query * Set criteria to extract records * Sort the data in a query * Hide fields in a query 1 hour class. Questions Contact Computer Services, ext. 4340
QUERIES IN MICROSOFT ACCESS FOR WINDOWS TRAINING CREATING A QUERY...3-4 SETTING CRITERIA...5 SORTING DATA IN A QUERY...6 HIDING A FIELD...7 2
QUERIES A query is a request for a particular collection of data. A query defines a group of records. You can base a form or report on a query. The easiest method of creating a query is to use the Simple Query Wizard. A Wizard will walk you through a series of questions, then create the query for you. Create a Query: 1. Open Access, then open the database. 2. In the database window, click the Queries Tab. 3. Click on the New button. The New Query window will appear on your screen. 4. Highlight the option Simple Query Wizard by clicking on it one time. 5. Click the OK button one time. 6. The Simple Query Wizard window will appear on your screen. 7. In the Tables/Queries box, select the appropriate table to base your query on. A drop down menu list will appear when you click on the down arrow one time. 8. The Available Fields box displays a list of all the field names from the table you selected in step #7. You can choose one field at a time or all fields at one time to be included in the query. 9. Highlight a field name in the Available Fields box by clicking on it one time. Now click on the single arrow button between the boxes. The field name now becomes part of the Selected Fields box. Field names must be in the Selected Fields box to be included in a query. 3
10. Repeat Step #9 as many times as needed to include all necessary field names for the query. 11. Click the Next button. 12. Type a name for the query in the box provided. 13. Click the Finish button. 14. The query is now complete. 4
SETTING CRITERIA To limit the records that you see in a query, you must specify criteria. The criteria will tell Microsoft Access which records to retrieve. 1. With the Query open, click on the View option from the menu bar. Click on the Query Design option from the drop down list. 2. The Query Design window appears and you will see the following boxes: Field - shows field names included in the query Table - shows the table name the query is based on Sort - allows you to choose a field to sort the query data Show - shows check marks indicating that the field and data will appear in the query no check mark indicates that the filed and data will be hidden Criteria - allows you to set criteria in a field 3. Click in the Criteria box under the appropriate column. 4. Type in the criteria you want to base your extraction of records on, then hit the Enter key. 5. To see the records that meet the criteria you specified in Step #4, click on the View option from the Menu bar. 6. From the drop down menu list, click on the Datasheet option. Your records (from the query) are displayed. NOTE: You can set criteria in more than one field at a time. Do Step #3 in each field you want criteria specified. 5
SORTING You can specify the order in which the records are displayed, either in ascending (a-z) or descending (z-a), in the query. 1. With the Query open, click on the View option from the menu bar. Click on the Query Design option from the drop down list. 2. Click on the appropriate field in the Sort box. 3. Click on the down arrow one time. Choose ascending from the drop down menu list by clicking on it one time. 4. Click on the View option from the Menu bar, then click on Datasheet. The records in the query will now appear in the correct sort order. 6
HIDING FIELDS A field may be included in a query because you need to use it to set criteria, but it doesn t need to be seen in the final query. You can use the Show box to hide or unhide a field. 1. With the Query open, click on the View option from the menu bar. Click on the Query Design option from the drop down list. 2. Click in the Show box to clear the check mark from the field you want to hide. The absence of the check mark means a field will be hidden. The presence of a check mark means the field will be displayed. 3. Click on the View option from the Menu bar, then click on the Datasheet option from the drop down menu list. The field is hidden from the final query, therefore, the field and its data is not displayed. 7