Sorting, Filtering, and Retrieving Data strQry = "SELECT CampaignID, Country, CampaignBudget " _ & "FROM MarketingCampaigns WHERE CampaignBudget > 20000" qry.SQL = strQry End Sub 224 This procedure uses the CreateQueryDef method of the DAO Database object to create the query named qryBigBudgets. It then uses the string variable strQry to store the SQL statement that selects the fields for the query from the MarketingCampaigns table and defines the criteria for the records we want to see. The SQL statement is then assigned to the QueryDef object's SQL property, which actually defines the query that is executed. If you want to test or modify this code, you can find it in the HelloWorld6 database in the module named modDemonstrations. You could use code similar to this as the start of a custom report feature, having a user select fields and define criteria with which to build a query and then creating a report on the basis of that query, displaying the report to the user. Chapter Summary Sometimes, simply by sorting the records in a table or a query, you can arrange the records in a way that lets you interpret and analyze the data more easily. Using criteria in a filter or a select query lets you examine a specific set of records. Queries, together with tables, are the backbone of a database. Queries bring related records together so that you can analyze the data in the records, including summarizing the data and performing calculations. Queries are also often used as the basis for forms and reports. In Chapter 9, you'll learn more about queries, including how to use action queries to update and delete records and how to create a cross-tab query (a query similar to