Creating a Query

As stated previously, a QUERY is a tool that is used to ask questions about the contents of your database. Queries may be used to find records from within your database. Queries may also be used to perform calculations on the selected information once it is found.

To create a query, you must first click on Queries in the Database window under Objects along the left. 

Now you have three choices. You can create a query by:
  • double-clicking on Create query in Design view 
    • this will allow you to define and design your own query
  • double-clicking on Create query by using wizard 
    • the wizard will walk you through the steps of creating a Simple Query 
  • clicking the New button on the toolbar
    • clicking this button gives you access to additional wizards

Using the Query Wizard

Let's create a simple Parent Volunteer List. 
  • Begin by double-clicking on Create query by using wizard 
  • In the Available Fields box, select the following fields by double-clicking on them
    • Parents
    • Phone (H)
    • Phone (W)
    • Room Parent
    • Read to Class
    • Provide Snacks
    • Organize Field Trips
  • The dialog box will now look like this:

  • Click 
    • Make sure that Detail (shows every field of every record) is selected
  • Click 
    • Change the title of the query to Parent Volunteer List 
    • Make sure that Open the query to view information is selected 
  • Click
A new table will open entitled Parent Volunteer List : Select Query that lists all of the parents in your database with their home and work telephone numbers, and the volunteer activity they are willing to do (remember, if the activity is checked, it means “Yes, I am willing to do this”.).
If you return to the Student List : Database window with Queries selected, you will see a new item in the window. Anytime you want to see a list of parents with their volunteer activities, simply double-click on Parent Volunteer List 

Try creating other simple queries using the wizard

Creating a Query in Design View

We are going to create another Parent Volunteer List but take advantage of the capabilities of the design view to allow you to specify a Sort order and one or more Filter Criteria

Specifying which table(s) are to be used in the query

  • double-click on Create query in Design view in the Student List : Database window
  • the Query1 : Select Query window will open with the Show Table dialog box on top of it
    • the [Tables] tab in this dialog box should be selected; if not select it
    • the Field Names table (the only one in our database right now) will be listed and selected
    • clickto add this table to the query window
    • since there are no other tables in our database, click

Adding the desired fields to the query

The Query Design Window
Field names have been added to the query

Specifying a sort order

  • under the Names field name in the bottom portion of the window click in the Sort row
  • set the sort order to Ascending as shown
  • now click on the check mark in the Show row to remove it
    • we are only using this field for sorting, there is no need to display the student's name
    • however in order to use it for this query, it must be part of the query

  • under the Room Parent field name in the bottom portion of the window click on the check mark in the Show row to remove it
    • since we are going to select only those records of parents that are willing to act as a Room parent there is no need to actually display this field
    • however in order to use it for this query, it must be part of the query
  • type Yes in the Criteria row in this column
    • in other words, we want to only display those records that have been checked
To summarize what we have just done: We have designed a Query to select only those parents that have agreed to be Room Parents. The list we will get will be sorted by the name of the student.

Viewing the results of the Query

  • switch to Datasheet view
  • you will now have a table of parents willing to serve as Room Parents, sorted in alphabetical order!
    • if necessary you can increase or decrease the width of the columns so that all of the data is visible

Saving this Query

  • Click on the close box
    • do not click onas this will close the entire file
    • you only want to close the Query window
  • You will be asked if you want to save the query
  • Do so, and give it the name Room Parents
  • When you return to the Student List : Database window with Queries selected, you will see a new item in the window. Anytime you want to see a list of parents willing to serve as Room Parents, simply double-click on Room Parents 

Can you design a query to produce a list of parents willing to organize field trips? to provide snacks? to read to class and provide snacks? Try designing these and other queries!


Go Back


Copyright © 2003
last updated August 12, 2003