Share this Page URL

Chapter 1. The HelloWorld Database > Creating a Simple Query and Report - Pg. 13

The HelloWorld Database 13 Queries are used to select records from a database and also to perform operations such as updating or deleting groups of records. When you create a query, you often enter criteria with which to select the particular set of records that you want to analyze or review. The criteria you use might be a single value (for example, you want to see records for customers in London), or it might be an expression that shows you the records for which total sales are greater than $10,000. The records selected as the result of a query, as well as the records in a specific table, are known as a record- set. You can use a recordset that's created as a result of a query in the same way you can use a table's recordset. Reports are used to present data, often a set of records that are grouped and sorted or summarized. You can view reports online, but reports are usually designed for printing. You can also e-mail a report in a report snapshot format for others to review. Let's create the query we want first. In creating the query, we'll use another of the wizards that Access provides. Create a query 1. In the Database window, select Queries in the Objects list, and then double-click Create Query By Using Wizard. Because our database has only one table, Greetings, Access has selected it as the table the query will be based on. Queries often retrieve records from more than one table, and you can also base queries on other queries (selecting records from the recordsets the queries create), as you'll see in later chapters. From the list of available fields, move the CampaignID field and the Greeting field to the Se- lected Fields list, as shown here, and then click Next. 2. 3. 4. In the screen asking whether you want a detail or a summary query, leave the Detail option selected, and then click Next. Access provides a default title for the query, Greetings Query, as shown here. This title is fine for this example.