Download presentation
Presentation is loading. Please wait.
Published byMagdalene McDowell Modified over 9 years ago
1
Office 2003 Introductory Concepts and Techniques M i c r o s o f t Access Project 2 Querying a Database Using the Select Query Window
2
Access Project 2: Querying a Database Using the Select Query Window 2 Objectives Create and run queries Include fields in the design grid Use text and numeric data in criteria Create and use parameter queries Save a query and use the saved query
3
Access Project 2: Querying a Database Using the Select Query Window 3 Objectives Use compound criteria in queries Sort data in queries Join tables in queries Perform calculations in queries Use grouping in queries
4
Access Project 2: Querying a Database Using the Select Query Window 4 Opening the Database 1.Open Microsoft Office Access 2003 2.If the Access window is not maximized, Double-click its title bar 3.If the Language bar appears, Right-click and Close 4.Open the file: Ashton James College
5
Access Project 2: Querying a Database Using the Select Query Window 5 1.The Tables object should be highlighted 2.The Client table should be highlighted 3.Click New Object arrow on the toolbar Create a Query - Reference Book: Page AC 68-69
6
Access Project 2: Querying a Database Using the Select Query Window 6 1.Click Query 2.With Design View selected, click OK Create a Query - Reference Book: Page AC 68-69
7
Access Project 2: Querying a Database Using the Select Query Window 7 1.Maximize Query1 : Select Query window 2.Drag the line separating the two panes to the approximate position shown below 3.Drag the lower edge of the “Client” field box down far enough so all fields in the Client table are displayed Create a Query - Reference Book: Page AC 68-69
8
Access Project 2: Querying a Database Using the Select Query Window 8 1.Double-click Client Number to include in the query 2.Double-click Name to include in the query 3.Double-click Trainer Number to include in the query 4.Click Run button to run query Include Fields in Design Grid and Run - Reference Book: Page AC 71
9
Access Project 2: Querying a Database Using the Select Query Window 9 The results of the query should look similar to this. You have pulled all records but only show the fields Client Number, Name, and Trainer Number.
10
Access Project 2: Querying a Database Using the Select Query Window 10 1.Click View button arrow on the toolbar 2.Click Design View Return to Select Query Window - Reference Book: Page AC 72
11
Access Project 2: Querying a Database Using the Select Query Window 11 1.Click Close Window button for the Query1 : Select Query window 2.Click “No” to save changes Closing a Query - Reference Book: Page AC 73
12
Access Project 2: Querying a Database Using the Select Query Window 12 Include All Fields in a Query - Reference Book: Page AC 74 1.Click the Query Object 2.Click Design
13
Access Project 2: Querying a Database Using the Select Query Window 13 Include All Fields in a Query - Reference Book: Page AC 74 1.Add Client table to Query
14
Access Project 2: Querying a Database Using the Select Query Window 14 1.Maximize Query1 : Select Query window 2.Resize the panes as before 3.Expand the Client table field list Include All Fields in a Query - Reference Book: Page AC 74
15
Access Project 2: Querying a Database Using the Select Query Window 15 1.Double-click the asterisk at the top of the field list (this includes every field from the table) 2.Click Run Include All Fields in a Query - Reference Book: Page AC 74
16
Access Project 2: Querying a Database Using the Select Query Window 16 1.Click View - Design View Include All Fields in a Query - Reference Book: Page AC 74 The results of the query should look similar to this. You have pulled all records and all fields in the table.
17
Access Project 2: Querying a Database Using the Select Query Window 17 1.Click Edit on the menu bar 2.Click Clear Grid Clearing the Design Grid - Reference Book: Page AC 75
18
Access Project 2: Querying a Database Using the Select Query Window 18 1.Double-click Client Number 2.Double-click Name 3.Double-click Amount Paid 4.Double-click Current Due Use Text Data in a Criterion - Reference Book: Page AC 76
19
Access Project 2: Querying a Database Using the Select Query Window 19 1.Click the Criteria row for Client Number 2.Type “CP27” as the criterion 3.Click Run Use Text Data in a Criterion - Reference Book: Page AC 76
20
Access Project 2: Querying a Database Using the Select Query Window 20 The results of the query should look similar to this. Notice that you have only pulled records where the Client Number is equal to “CP27”. The fields shown are: Client Number, Name, Amount Paid, Current Due. Use Text Data in a Criterion - Reference Book: Page AC 76
21
Access Project 2: Querying a Database Using the Select Query Window 21 1.Click View - Design View 2.Click the Criteria row below the Client Number field 3.Use DELETE or BACKSPACE to delete (CP27) 4.Click the Criteria row below the Name field 5.Type “Fa*” as the criterion 6.Click Run NOTE: The * is a wildcard. Use a Wildcard - Reference Book: Page AC 77
22
Access Project 2: Querying a Database Using the Select Query Window 22 The results of the query should look similar to this. Notice that you have only pulled records where the Name begins with “Fa” and followed by anything. The fields shown are: Client Number, Name, Amount Paid, Current Due. Use a Wildcard - Reference Book: Page AC 77
23
Access Project 2: Querying a Database Using the Select Query Window 23 1.Click View - Design View 2.Click Edit then Clear Grid 3.Include these fields in the query: Client Number, Name, Address, Amount Paid, City 4.Type “Lake Hammond” as the criterion for the City field 5.Click the Show check box to remove the check mark 6.Click Run Use Criteria for a Field Not Included in the Results - Reference Book: Page AC 78
24
Access Project 2: Querying a Database Using the Select Query Window 24 The results of the query should look similar to this. You have only pulled records where the City is “Lake Hammond” The fields shown are: Client Number, Name, Address, Amount Paid Even though City is a criterion, it is not shown. Use Criteria for a Field Not Included in the Results - Reference Book: Page AC 78
25
Access Project 2: Querying a Database Using the Select Query Window 25 1.Click View - Design View 2.Erase the current criterion in the City column 3.Type “[Enter City]” as the new criterion 4.Click Run Create and Run a Parameter Query - Reference Book: Page AC 79
26
Access Project 2: Querying a Database Using the Select Query Window 26 1.Type “Tallmadge” in the Enter City text box 2.Click OK Create and Run a Parameter Query - Reference Book: Page AC 79
27
Access Project 2: Querying a Database Using the Select Query Window 27 Create and Run a Parameter Query - Reference Book: Page AC 79 The results of the query should look similar to this. You have pulled records where the City is “Tallmadge” The fields shown are: Client Number, Name, Address, Amount Paid
28
Access Project 2: Querying a Database Using the Select Query Window 28 1.Click the Close Window for Query1 : Select Query window 2.Click Yes to save the changes to the design of the query 3.Type “Client-City Query ” in the Query Name text box 4.Click OK to save the query Save a Query - Reference Book: Page AC 80
29
Access Project 2: Querying a Database Using the Select Query Window 29 1.Click Tables object on Objects bar 2.Client table should be selected 3.Click New Object button arrow on Database toolbar 4.Click Query 5.Click OK Use Numeric Data in Criterion - Reference Book: Page AC 82
30
Access Project 2: Querying a Database Using the Select Query Window 30 1.Drag the line separating the two panes to the approximate position shown below 2.Drag the lower edge of the “Client” field box down far enough so all fields in the Client table are displayed Use Numeric Data in Criterion - Reference Book: Page AC 82
31
Access Project 2: Querying a Database Using the Select Query Window 31 Use Numeric Data in Criterion - Reference Book: Page AC 82 1.Include these fields: Client Number, Name, Amount Paid, Current Due 2.Type “0” as the criterion for the Current Due field. Do not enter a dollar sign or decimal point. 3.Click Run
32
Access Project 2: Querying a Database Using the Select Query Window 32 Use Numeric Data in Criterion - Reference Book: Page AC 82 The results of the query should look similar to this. You have pulled records where the Current Due is = 0 The fields shown are: Client Number, Name, Amount Paid, Current Due
33
Access Project 2: Querying a Database Using the Select Query Window 33 1.Click View - Design View 2.Erase the 0 in the Current Due column 3.Type “>20000” as the criterion for the Amount Paid field. DO NOT enter a dollar sign, comma, or decimal point 4.Click Run Use a Comparison Operator in a Criterion - Reference Book: Page AC 83
34
Access Project 2: Querying a Database Using the Select Query Window 34 The results of the query should look similar to this. You have pulled records where the Amount Paid is > 20000 The fields shown are: Client Number, Name, Amount Paid, Current Due Use a Comparison Operator in a Criterion - Reference Book: Page AC 83
35
Access Project 2: Querying a Database Using the Select Query Window 35 1.Click View - Design View 2.Include Trainer Number the query 3.Type “48” as the criterion for the Trainer Number field 4.Click Run Use a Compound Criterion Involving AND - Reference Book: Page AC 84 Notice that >20000 and 48 are on the same line This means AND
36
Access Project 2: Querying a Database Using the Select Query Window 36 The results of the query should look similar to this. You have pulled records where the Amount Paid is > 20000 AND Trainer Number = 48 The fields shown are: Client Number, Name, Amount Paid, Current Due, Trainer Number Use a Compound Criterion Involving AND - Reference Book: Page AC 84
37
Access Project 2: Querying a Database Using the Select Query Window 37 1.Click View - Design View 2.Erase the 48 in the criteria row 3.Type “48” in the OR row for Trainer Number 4.Click Run Use a Compound Criterion Involving OR - Reference Book: Page AC 85
38
Access Project 2: Querying a Database Using the Select Query Window 38 The results of the query should look similar to this. You have pulled records where the Amount Paid is > 20000 OR Trainer Number = 48 The fields shown are: Client Number, Name, Amount Paid, Current Due, Trainer Number Use a Compound Criterion Involving OR - Reference Book: Page AC 85
39
Access Project 2: Querying a Database Using the Select Query Window 39 1.Click View - Design View 2.Click Edit - Clear Grid 3.Include City in the design grid 4.Click the Sort row arrow below City 5.Click Ascending 6.Click Run Sort Data in a Query - Reference Book: Page AC 86
40
Access Project 2: Querying a Database Using the Select Query Window 40 The results of the query should look similar to this. You have pulled all records and show the cities Notice that duplicates, or identical rows, are included; We will omit duplicates next. Sort Data in a Query - Reference Book: Page AC 86
41
Access Project 2: Querying a Database Using the Select Query Window 41 1.Click View - Design View 2.Click the second field in the design grid. 3.Click the Properties button on the toolbar Omit Duplicates - Reference Book: Page AC 87
42
Access Project 2: Querying a Database Using the Select Query Window 42 1.Click the arrow next to Unique Values property 2.Click Yes 3.Close Query Properties 4.Click Run Omit Duplicates - Reference Book: Page AC 87
43
Access Project 2: Querying a Database Using the Select Query Window 43 Omit Duplicates - Reference Book: Page AC 87 The results of the query should look similar to this. You have pulled the cities. Notice that you no longer have duplicate cities.
44
Access Project 2: Querying a Database Using the Select Query Window 44 1.Click View - Design View 2.Click Edit - Clear Grid 3.Select: Client Number Name Trainer Number – Ascending Sort Order Amount Paid – Ascending Sort Order 4.Click RUN Sort on Multiple Keys - Reference Book: Page AC 88
45
Access Project 2: Querying a Database Using the Select Query Window 45 Sort on Multiple Keys - Reference Book: Page AC 88 The results of the query should look similar to this. The clients are sorted by trainer number. Within the collection of clients having the same trainer, the clients are sorted by amount paid.
46
Access Project 2: Querying a Database Using the Select Query Window 46 1.Click View - Design View 2.Click the Top Values box on the Query Design toolbar 3.Type “4” as the new value 4.Click Run Create a Top-Values Query - Reference Book: Page AC 89
47
Access Project 2: Querying a Database Using the Select Query Window 47 1.Close the Query Window 2.Click No to save changes The results of the query should look similar to this. You have pulled the 1 st 4 records of the query. This was based on the original way you set up the sorting. Create a Top-Values Query - Reference Book: Page AC 89
48
Access Project 2: Querying a Database Using the Select Query Window 48 JOINING ONE OR MORE TABLES You may need fields from more than one table in a query. A Join is required to do this. In the example at left: We join the Client Table to the Trainer Table based on the Trainer Number. From this, we can then pull in the Last Name and First Name from the Trainer Table along with the Client Number and Name from the Client Table. Thus, our query can then contain data from both of these tables.
49
Access Project 2: Querying a Database Using the Select Query Window 49 1.With the Tables object selected and the Trainer table selected: 2.Click the New Object button arrow 3.Click Query 4.Click OK Join Tables - Reference Book: Page AC 92-93
50
Access Project 2: Querying a Database Using the Select Query Window 50 1.Drag the line separating the two panes to the approximate position shown below 2.Drag the lower edge of the Trainer box down far enough so all fields are displayed Join Tables - Reference Book: Page AC 92-93
51
Access Project 2: Querying a Database Using the Select Query Window 51 1.Click the Show Table button on the Query Design toolbar 2.Be sure the Client table is selected, and then click the Add button Join Tables - Reference Book: Page AC 92-93
52
Access Project 2: Querying a Database Using the Select Query Window 52 Join Tables - Reference Book: Page AC 92-93 1.Close the Show Table dialog box 2.Expand the Client table field list 3.Include: Trainer Number – Ascending Last Name First Name Client Number– Ascending Name 4.Click Run Trainer Client
53
Access Project 2: Querying a Database Using the Select Query Window 53 The results of the query should look similar to this. You have pulled all of the records from the Client and the Trainer Tables where both are joined on trainer number. Records were sorted by trainer number and within trainer number by client number. Join Tables - Reference Book: Page AC 92-93
54
Access Project 2: Querying a Database Using the Select Query Window 54 1.Click View - Design View 2.Right-click the middle portion of the join line (the portion of the line that is not bold) 3.Click Join Properties on the shortcut menu Changing Join Properties - Reference Book: Page AC 94
55
Access Project 2: Querying a Database Using the Select Query Window 55 1.Click option button 2 (Include all records from the Trainer table) This means they will be pulled wheter they match clients or not. 2.Click OK 3.Click Run Changing Join Properties - Reference Book: Page AC 94
56
Access Project 2: Querying a Database Using the Select Query Window 56 Changing Join Properties - Reference Book: Page AC 94 The results of the query should look similar to this. You have pulled the records from the Client and the Trainer Tables. Notice, that trainer Marty Danville does not have a client.
57
Access Project 2: Querying a Database Using the Select Query Window 57 1.Click View - Design View 2.Add Amount Paid field 3.Type “>20000” as the criterion for Amount Paid 4.Click Show check box to remove the check mark 5.Click Run Restricting the Records in a Join - Reference Book: Page AC 95
58
Access Project 2: Querying a Database Using the Select Query Window 58 The results of the query should look similar to this. You have pulled the records from the Client and the Trainer Tables. Notice, that you see fewer records. These are those clients where the amount paid is > 20000. Restricting the Records in a Join - Reference Book: Page AC 95
59
Access Project 2: Querying a Database Using the Select Query Window 59 1.Click View - Design View 2.Right-click any field in the Client table field list 3.Click Remove Table on the shortcut menu 4.Click Edit - Clear Grid 5.Include: Trainer Number Last Name Hourly Rate YTD Earnings Use a Calculated Field in a Query - Reference Book: Page AC 96
60
Access Project 2: Querying a Database Using the Select Query Window 60 1.Right-click the Field row (in the first open column in the design grid) 2.Click Zoom Use a Calculated Field in a Query - Reference Book: Page AC 96
61
Access Project 2: Querying a Database Using the Select Query Window 61 1.Type “Hours Worked:[YTD Earnings]/[Hourly Rate]“ Click OK 2.Click Run Use a Calculated Field in a Query - Reference Book: Page AC 96
62
Access Project 2: Querying a Database Using the Select Query Window 62 Use a Calculated Field in a Query - Reference Book: Page AC 96 The results of the query should look similar to this. Access has calculated and displayed the number of hours worked for each trainer.
63
Access Project 2: Querying a Database Using the Select Query Window 63 1.Click View - Design View 2.Click the Hours Worked field in the design grid 3.Click the Properties button on the toolbar Change a Format and a Caption - Reference Book: Page AC 98
64
Access Project 2: Querying a Database Using the Select Query Window 64 1.Click the Format box arrow 2.Click Fixed 3.Click the Decimal Places box 4.Type “1” as the number of decimal places 5.Close the Field Properties Change a Format and a Caption - Reference Book: Page AC 98
65
Access Project 2: Querying a Database Using the Select Query Window 65 1.Click the Hourly Rate field 2.Click the Properties button on the toolbar 3.Click the Caption box 4.Type Rate as the caption 5.Click Run Change a Format and a Caption - Reference Book: Page AC 98
66
Access Project 2: Querying a Database Using the Select Query Window 66 1.Close the Select Query window 2.When asked if you want to save changes, click No The results of the query should look similar to this. The number of hours now displays with one decimal place. The Hourly Rate now displays as “Rate”. Change a Format and a Caption - Reference Book: Page AC 98
67
Access Project 2: Querying a Database Using the Select Query Window 67 1.With the Tables object selected and the Client table selected 2.Click the New Object button arrow on the Database toolbar 3.Click Query 4.Click OK Calculate Statistics - Reference Book: Page AC 100
68
Access Project 2: Querying a Database Using the Select Query Window 68 1.Drag the line separating the two panes to the approximate position shown below 2.Drag the lower edge of the Client box down far enough so all fields are displayed Calculate Statistics - Reference Book: Page AC 100
69
Access Project 2: Querying a Database Using the Select Query Window 69 1.Click the Totals button on the Query Design toolbar 2.Double-click the Amount Paid field Calculate Statistics - Reference Book: Page AC 100
70
Access Project 2: Querying a Database Using the Select Query Window 70 1.Click the Totals button on the Query Design toolbar 2.Double-click the Amount Paid field 3.Click the Total row in the Amount Paid column 4.Click the row arrow that appears 1.Click the Total row 2.Click AVG 3.Click Run Calculate Statistics - Reference Book: Page AC 100
71
Access Project 2: Querying a Database Using the Select Query Window 71 The results of the query should look similar to this. The result shows the average amount paid for all clients. Calculate Statistics - Reference Book: Page AC 100
72
Access Project 2: Querying a Database Using the Select Query Window 72 1.Click View - Design View 2.Include Trainer Number 3.Produce the list of available options for the Total row (as you did when you selected Avg) 4.Scroll down and Click Where Use Criteria in Calculating Statistics - Reference Book: Page AC 101
73
Access Project 2: Querying a Database Using the Select Query Window 73 1.Type “42” as the criterion Trainer Number 2.Click Run Use Criteria in Calculating Statistics - Reference Book: Page AC 101
74
Access Project 2: Querying a Database Using the Select Query Window 74 Use Criteria in Calculating Statistics - Reference Book: Page AC 101 The results of the query should look similar to this. The result shows the average amount paid for clients of Trainer 42.
75
Access Project 2: Querying a Database Using the Select Query Window 75 1.Click View - Design View 2.Click Edit - Clear Grid 3.Include: Trainer Number Amount Paid - Click Avg in the Total row 4.Click Run NOTE: Notice how Trainer Number Total line says GROUP BY Use Grouping - Reference Book: Page AC 103
76
Access Project 2: Querying a Database Using the Select Query Window 76 1.Close the Query window 2.Say No to save changes The results of the query should look similar to this. The result shows the average amount paid for the clients of each trainer. Since we grouped on trainer number, there is a single row for each. Use Grouping - Reference Book: Page AC 103
77
Access Project 2: Querying a Database Using the Select Query Window 77 Closing a Database and Quitting Access Click the Close Window button for the Ashton James College : Database window Click the Close button for the Microsoft Access window
78
Access Project 2: Querying a Database Using the Select Query Window 78 Summary Create and run queries Include fields in the design grid Use text and numeric data in criteria Create and use parameter queries Save a query and use the saved query
79
Access Project 2: Querying a Database Using the Select Query Window 79 Summary Use compound criteria in queries Sort data in queries Join tables in queries Perform calculations in queries Use grouping in queries
80
Office 2003 Introductory Concepts and Techniques M i c r o s o f t Access Project 2 Complete Any questions?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.