Creating Select Queries
Queries are a way to ask questions of your data. Queries have two views: Design view and Datasheet view. In Design view, you define your query - you tell Access which fields you want to see, which tables they come from, and the criteria that any record has to meet in order to appear on the resulting datasheet. In Datasheet view, you see the fields and records Access finds that meet your criteria.
You can use queries to do the following:
- Look at data from related tables
- Look at subsets of your data - a selective slice that meets certain criteria that you specify
- Sort and alphabetize data
- Create new calculated fields
You can make as many queries as you want to - usually some are made on the fly and not saved, and some are saved - even used as the basis for forms and reports.
To create a query, you need to know what data - more specifically, which fields - you want to see and which tables those fields are in. As you define the query, you may have criteria that limit the data. After you define the query, you can view the data in a datasheet. The datasheet created by a query is dynamic - that is, you see the data that meets the query definition each time you view the datasheet. If data has been added, edited, or deleted, the query datasheet may display different data.
To create a query, you use either a wizard or Design view (or both) to tell Access which data you want to see. The easiest way for a beginner to create a query is to use the Simple Query Wizard, but after you understand queries, you may prefer to go right to Design view.
We start this tutorial by telling you about the different types of queries that Access offers, and then introduce you to Design view. This tutorial concentrates on select queries, which are the most common type of query, and the skills you use to create select queries. Then we guide you through creating a query using the Simple Query Wizard. But because the Simple Query Wizard doesn't allow you to define criteria, you probably want to move quickly to the next sections on using Design view and criteria. At the end of the tutorial, you find all the details on working with your query data in a datasheet.
In this tutorial:
- Types of Queries
- Creating a Query in Design View
- Creating a Query with the Simple Query Wizard
- Viewing Your Query
- Tips for Creating a Query
- Editing a Query
- Sorting a query
- Changing the format of a query field
- Limiting Records with Criteria Expressions
- Using dates, times, text, and values in criteria
- Using multiple criteria
- Using lookup fields in criteria
- Working with Multiple Related Tables
- Working with Query Datasheets
- Saving Queries