Designing a Simple Query

When designing an Access query it can be simple or more complex. In Access simple query guidelines let you pull important data.

One-table queries

Let's familiarize ourselves with the query-building process by building the simplest query possible: a one-table query.

We will run a query on the Customers table of our bakery database. Let's say our bakery is having a special event, and we want to invite our customers who live nearby because they are the most likely to come. This means we need to see a list of all customers who live close by, and only those customers.

We want to find our customers who live in the city of Raleigh, so we'll search for "Raleigh" in the City field. Some customers who live in the suburbs live fairly close by, and we'd like to invite them as well. We'll add their zip code, 27513, as another criteria.

If you think this sounds a little like applying a filter, you're right. A one-table query is actually just an advanced filter applied to a table.

To create a simple one-table query:

  1. Select the Create tab on the Ribbon, and locate the Queries group.
  2. Click the Query Design command.
    Clicking the Query Design Command
  3. Access will switch to Query Design view. In the Show Table dialog box that appears, select the table you want to run a query on. We are running a query on our customers, so we'll select the Customers table.
    Selecting a table to use in the query
  4. Click Add, then click Close.
  5. The selected table will appear as a small window in the Object Relationship pane. In the table window, double-click the field names you want to include in your query. They will be added to the design grid in the bottom part of the screen. In our example, we want to mail invitations to customers who live in a certain area, so we'll include the First Name, Last Name, Street Address, City, and Zip Code fields.
    Selecting fields to add to the query
  6. Set the search criteria by clicking the cell in the Criteria: row of each field you want to filter. Typing criteria into more than one field in the Criteria: row will set your query to include only results that meet all criteria. If you want to set multiple criteria but don't need the records shown in your results to meet all of them, type the first criteria in the Criteria: row and additional criteria in the or: row and the rows beneath it. Because we want to find customers who either live in Raleigh or in the 27513 zip code, we'll type "Raleigh" in the City field and "27513" into the or: row of the Zip Code field. The quotation marks will search these fields for an exact match.
    Setting the search criteria so that the query will find records with either "Raleigh" in the City field or "27513" in the Zip Code field.
  7. After you have set your criteria, run the query by clicking the Run command on the Design tab.
    Clicking Run
  8. The query results will be displayed in the query's Datasheet view, which looks like a table. If you want, save your query by clicking the Save command in the Quick Access Toolbar. When prompted to name it, type the desired name, then click OK.
    Naming the new query to save it

Now you know how to create the simplest type of query with only one table. In the next lesson, you'll learn how to create a query that uses multiple tables.