- What Is a Query and When Should You Use One?
- Opening a Query in Datasheet View
- Opening a Query in Design View
- Running a Query
- Adding and Removing Fields
- Modifying the Sort Order of a Query
- Working with Simple Criteria
- Modifying the Datasheet View of a Query
- Saving a Query
- Printing Query Results
- Closing a Query
Adding and Removing Fields
When viewing a query in Design view, you might decide to modify the fields that you want to include in the query's output. In other words, you might want to add fields to or remove fields from the query grid. You would do this if you had an existing query and you realized that it was missing fields, if you had a new query and were adding fields for the first time, or if you were working with an existing query and realized that you no longer wanted to include a field in the query.
Adding a Field Between Other Fields
There are times when you need to insert a field between two existing fields. For example, your query might already contain the city and zip code, and you have decided to add a state field and place it between the city and the zip code fields. To do so, you simply drag the field from the field list to the grid and drop it where you want it to appear. The fields already included in the query then move over to the right.
Adding a Field to the End of the Query Grid
Sometimes you want to add a field to the end of the list of existing fields. Fortunately, the process is extremely easy. You simply double-click in the field list on the field that you want to add. Access adds the field at the end of the existing field list. This is the technique that I use to add fields to a new query as I build it. I generally double-click each field that I want to add to the query. Access simply adds each field to the query grid in the order in which I select the fields.
Adding a Group of Contiguous Fields to the Query Grid
It would be very tedious if you had to add each field, one field at a time, in order to add a contiguous group of fields from the field list to the query grid. Fortunately, Access allows you to add the fields as a group. The process is simple:
Click the first field that you want to add to the query.
Scroll through the field list until you can see the last field that you want to add to the query.
Hold down the Shift key as you click the last field that you want to add to the query.
Drag the fields as a group to the query grid. The fields are placed on the query grid at the position where you dropped them.
This is a great technique to use when you are lucky and several of the fields you want to include in the query appear together in the field list.
Adding a Group of Noncontiguous Fields to the Query Grid
The process for adding a noncontiguous group of fields from the field list to the query grid is much simpler than adding the fields one at a time. You would add a noncontiguous list of fields when there are several fields that you want to add to the query, but they do not appear together in the field list. Here's what you do:
Click the first field that you want to add.
Hold down the Ctrl key as you click each additional field that you want to add.
Drag the fields to the query grid by clicking any of the selected fields and dragging to the query grid. Access adds the selected fields to the query grid at the position at which you drop them.