You are on page 1of 3

Creating Queries from Scratch Part 1: Starting a New Query When you create a query from scratch, you

can select the tables and fields that you use to build a query and set parameters for the fields. 1. Open Access, then open the database that contains the table or tables you want to use to build the query. 2. Click the Queries icon in the window that appears.

3. ouble!click on Create Query in Design View. "he #how "able dialo$ bo% then appears, listin$ all of the tables in the database.

&. Click the name of the table that contains the fields you want to use in the query. Click the Add button. 'epeat for each table you want to add. (. Click Close when you finish addin$ tables. "he )uery esi$n *iew window then opens. "he tables you selected appear in the top pane of the )uery esi$n *iew. +ield names will not appear until you add them.

Query Design View Window

Part 2: Adding ields to a Query "he )uery esi$n ,iew allows you to add the table fields you want in your query. -e sure the tables that contain the fields you want to use are present in the desi$n window. 1. .n the first field column of the query $rid, click in the ield bo%. A drop!down arrow list then appears.

2. Click the drop!down list and select a field. /0ou may need to scroll throu$h the list to find the field you want to use.1

3. Click in the ne%t field column and repeat the procedure. 'epeat to add all of the desired fields. 2ote3 "he order that you add fields will be the order in which they appear in the query. .f you need to chan$e a field that you4*e placed in a particular column, use the +ield drop!down list in the column to select a different field. 0ou may delete any field you ha*e added to a query. Click anywhere in the column and select 5dit, then elete Columns.

Part !: Adding Criteria 0ou can set criteria for a query that can control how field information in selected fields appears in a completed query. 1. .n the )uery esi$n *iew, click the Criteria row in the desired field4s column. 2. "ype the criteria you want to use. #ee the #ample Criteria for )ueries below. Sam"le Criteria for Queries # $less than% ! 6atchin$ *alues must be less than /or before in case of dates1 the specified numerical strin$. $greater than% ! 6atchin$ *alues must be $reater than /or after in the case of dates1 the specified numerical strin$. #& $less than or e'ual to% ! 6atchin$ *alues must be equal to or less than the *alue used in the criteria. (& $greater than or e'ual to% ! 6atchin$ *alues must be equal to or $reater than the *alue used in the criteria. &$e'ual to% ! 6atchin$ *alues must be equal to the criteria strin$. "his symbol can be used both with te%t and numeric entries.

Not ! ,alues matchin$ the criteria strin$ will not be included in the results. 3. )ueries can contain multiple criteria. 'epeat step7s 1 and 2 as needed to add additional criteria to the field columns in the query. Part ): Adding Sim"le Calculations 0ou can set up a query to do simple calculations, such as totalin$ information in a specific field or a*era$in$ information. "o add calculations to a query, a "otal row has to be added to the )uery esi$n $rid. After the "otal row is a*ailable, different calculations can be chosen from a drop!down list for any of the fields that ha*e been selected for the query. 1. .n the )uery esi$n *iew, click the *otals button on the )uery esi$n toolbar. A "otal row is then added to the )uery esi$n $rid /8ust below the "able row1. 2. Click the *otal row for a field in the )uery esi$n $rid that contains numerical data. A drop! down arrow then appears. 3. Click the drop!down arrow to select the type of formula you want to place in the field4s "otal bo%. "he followin$ are some commonly used types of formulas3 Sum ! "otals all *alues in the field. A+g ! Calculates the a*era$e for all *alues in the field. ,in ! isplays the lowest *alue /the minimum1 found in the field. ,a- ! isplays the hi$hest *alue /the ma%imum1 found in the field. Count ! Calculates the number of entries in the field /this basically counts the entries1. StDe+ ! Calculates the standard de*iation for the *alues in the field. /"his basically measures how widely the *alues in the field differ from the field4s a*era$e *alue.1 &. 'epeat steps 2 and 3 to place formulas into other field columns. Part .: Viewing Query /esults

After you ha*e setup your query, you are ready to run it. 1. Click the Sa+e icon in the )uery esi$n toolbar. "ype in a name for the query and then click 01. Sa+e 2con

2. Click the /un icon on the )uery esi$n toolbar, or choose Query, then /un. "he query results then appear in a datasheet that looks like an Access table.

/un 2con 3. After you ha*e re*iewed the results, click the Design View button on the toolbar to return to the Query Design *iew.