In Lesson 17, "Creating a Simple Query," you created a simple query using the Simple Query Wizard. This wizard allowed you to select the fields from a particular table and then create a standard select query. Although the Simple Query Wizard makes it easy to create a query based on one table, you will find that building more sophisticated queries is best done in the Query Design view.
The Query Design view provides two distinct areas as you work. A Table pane shows you the tables currently being used for the query. The bottom pane, the Query Design grid (see Figure 18.1) enables you to list the fields in the query and select how these fields will be sorted or the information in them filtered when you run the query.
Opening a Query in Query Design View
One thing that you can do in the Query Design view is edit existing queries, such as the simple query that you created in the previous lesson. You can change the fields used in the query and change the action that takes place on that field (or fields) when you run the query. To open an existing query in Query Design view, follow these steps:
Open the database that contains the query you want to edit (select File, Open ).
In the database window, click the Queries icon.
In the Query list, select the query you want to edit.
Click the Design button on the database window toolbar.
The query opens in the Query Design window.
Figure 18.1. The Query Design view is divided into a Table pane and a Query Design grid.
Starting a New Query in Query Design View
Creating a new query from scratch in the Query Design view allows you to select both the tables and the fields that you use to build the query. To begin a new query in Query Design view, follow these steps:
Open the database that holds the table or tables that you will use to build the query.
Click the Queries icon in the database window.
In the Query list, double-click Create Query in Design View. The Show Table dialog box appears, listing all the tables in the database (see Figure 18.2).
Figure 18.2. Choose which tables you want to include in the query.
Click a table that contains fields you want to use in the query, and then click the Add button. Repeat for each table you want to add.
Click Close when you finish adding tables. The Query Design view window opens.
The tables chosen for the query appear in the top pane of the Query Design view. Field names do not appear in the Query Design grid until you add them. Adding fields to the query is covered in the next section.
Create Table Relationships When you create queries from multiple tables, these tables must be related . See Lesson 11, "Creating Relationships Between Tables" for more information.