Access for 365 Access 2021 Access 2019 Access 2016 Access 2013 Access 2010 Access 2007 More...Less

When you desire to choose specific information from one or even more sources, you can usage a select query. A pick query helps you retrieve only the data that you desire, and also helps you integrate information from several information resources. You have the right to use tables and also various other pick queries as data sources for a select query. This topic gives an overview of choose queries, and also provides steps for producing a pick query, by making use of the Query Wizard or in Design see.

You are watching: What does the type of criterion you enter, along with the way you enter the criterion, depend on?

If you desire to use the Northwind sample database to learn even more around exactly how queries occupational, watch the short article Introduction to queries.

In this article


When you want to usage data, you seldom desire to use all of the data from one table. For instance, once you desire to use information from a Contacts table, you normally want to look at one certain record, or perhaps simply the telephone number. Sometimes you desire to incorporate information from even more than one table, such as combining Customer indevelopment with Order indevelopment. To choose the data that you desire to use, you usage a pick query.

A choose query is a database object that shows indevelopment in Datasheet view. A query does not save data, it screens information that is stored in tables. A query deserve to display information from one or more tables, from various other queries, or from a mix of the 2.

Benefits of making use of a query

A query allows you:

View data just from the areas you are interested in viewing. When you open a table, you view all the fields. A query is a handy method to conserve a choice of areas.

Note: A query just points to information, it does not keep information. When you save a query, you are not conserving a copy of the information.

Combine data from a number of data sources. A table commonly only display screens information that it stores. A query lets you pick and pick areas from assorted sources, and also specify how the indevelopment should be linked.

Use expressions as fields. For example, you might use the Date attribute as a field, or you might use the Layout attribute with a area to regulate the way the data from the area is formatted in the query outcomes.

View documents that accomplish criteria that you specify. When you open a table, you see all the documents. A query is a handy means to conserve a selection of records.

Basic procedures to produce a pick query

You have the right to develop a pick query by making use of the Query Wizard or by working in Deauthorize check out. Some design facets are not available when you usage the wizard, but you have the right to add these facets later by using Design watch. Although the two methods are rather various from each other, the standard procedures are basically the same:

Choose the tables or queries that you want to usage as resources of information.

Specify the fields that you want to encompass from the information resources.

Optionally, specify criteria to limit the records that the query retransforms.

After you have produced a select query, you run it to see the results. To run a choose query, you open up it in Datasheet watch. If you save the query, you can reusage it whenever before you require, for example, as a data source for a kind, report, or another query.

Use the Query Wizard to create a pick query

You can use the Query Wizard to automatically create a choose query. When you use the wizard, you have actually less manage over the details of the query style, yet the query is commonly developed faster than if you did not usage the wizard. Moreover, the wizard can catch some straightforward style mistakes and also prompt you to perform a different action.

Before you begin

If you usage areas from data resources that are not pertained to each various other, the Query Wizard asks you if you desire to create relationships. The wizard opens up the Relationships window for you, yet you need to rebegin the wizard if you edit any kind of relationships. As such, before you run the wizard, think about producing any type of relationships that your query needs.

For even more information about developing table relationships, see the write-up Guide to table relationships.

Use the Query Wizard

On the Create tab, in the Queries group, click Query Wizard

In the New Query dialog box, click Simple Query Wizard, and also then click OK.

Next, you include fields. You have the right to add approximately 255 areas from as many as 32 tables or queries.

For each field, percreate these 2 steps:

Under Tables/Queries, click the table or query that has the field.

Under Available Fields, double-click the area to include it to the Selected Fields list. If you want to add all fields to your query, click the button through the double best arrows (>>).

When you have included all the areas that you desire, click Next.


If you did not add any number areas (areas that contain numeric data), skip ahead to step 9. If you added any kind of number fields, the wizard asks whether you desire the query to return details or summary data.

Do one of the following:

If you want to check out individual records, click Detail, and also then click Next. Skip ahead to step 9.

If you desire to check out summarized numeric information, such as averages, click Summary, and also then click Overview Options.


In the Rundown Options dialog box, specify which fields you want to summarize, and just how you want to summarize the data. Only number fields are noted.

For each number area, choose among the following functions:

Sum The query returns the sum of all the worths of the area.

Avg The query returns the average of the values of the area.

Min The query retransforms the smallest worth of the field.

Max The query returns the largest worth of the field.


If you want the query results to include a count of the records in a documents resource, select the appropriate Count records in data resource name examine box.

Click OK to cshed the Summary Options dialog box.

If you did not add a date/time field to the query, skip ahead to step 9. If you included a date-time area to the query, the Query Wizard asks you how you would like to team the date values. For instance, mean you added a number field ("Price") and a date/time area ("Transaction_Time") to your query, and also then stated in the Rundown Options dialog box that you want to check out the average worth of the number field "Price". Because you had a date/time area, you could calculate summary values for each distinctive date/time value, for each day, for each month, for each quarter, or for every year.


Select the time duration that you desire to use to team the date/time worths, and also then click Next.

Note: In Design view, you can usage an expression to team by any type of time duration you want, yet the wizard only provides these selections.

On the last page of the wizard, provide the query a title, specify whether you desire to open or modify the query, and then click Finish.

If you select to open the query, the query display screens the schosen information in Datasheet view. If you choose to modify the query, the query opens in Design see.

Top of Page

Create a query by working in Deauthorize view

You deserve to use Design see to manually develop a pick query. When you use Deauthorize check out, you have actually even more regulate over the details of the query design, however it is less complicated to make architecture mistakes, and also it can take much longer than utilizing the wizard.

Create a query

Tip 1: Add data sources

When you use Design see, to add data sources, you add the information resources and also fields in sepaprice steps. However, you deserve to always include even more information sources later on if you desire.

On the Create tab, in the Other team, click Query Design

Double-click each data resource that you desire to usage or select each data resource and then click Add.


Automatic joins

When you include the data sources, if the resources already have actually relationships identified in between them, those relationships are immediately added to the query as joins. Joins specify just how data from associated sources should be unified. Access additionally automatically creates a join between two tables if they have fields have compatible data varieties and one area is a major essential.

You can desire to adjust the joins that Access creates. Access determines what kind of join to produce based on the partnership the join represents. If Access creates a join but tright here is no characterized connection, Access creates an inner sign up with.

If Access instantly creates the correct joins once you include the information resources, you deserve to skip ahead to Tip 3: Add output areas.

Use the exact same data source several times

In some instances, you desire to join two duplicates of the same table or query, referred to as a self-join, that combines documents from the very same table when tright here are matching values in the joined areas. For instance, say you have an Employees table in which the ReportsTo field for each employee"s record display screens his or her manager"s ID instead of name. You could use a self-join to screen the manager"s name in each employee"s document rather.

When you add a documents resource a second time, Access appends _1 to the name of the second circumstances. For instance, if you included the Employees table twice, the second instance would certainly be named Employees_1.

Step 2: Join associated information sources

If the information resources that you add to a query currently have relationships, Access automatically creates an inner join for each partnership. If referential integrity is applied, Access also displays a "1" over the join line to present which table is on the "one" side of a one-to-many connection and also an infinity symbol () to show which table is on the "many" side.

If you include queries to your query, and also have not developed relationships in between those queries, Access does not instantly develop joins in between those queries, or in between queries and tables that are not related. If Access does not produce joins as soon as you include data sources, you must normally add them yourself. Documents resources that are not joined to any other data source deserve to reason troubles with the query outcomes.

You could likewise desire to change the form of a sign up with from an inner sign up with to an outer join, so that your query consists of even more records.

Add a join

To include a join, drag a field from one data source to a corresponding area on one more data source.

Access screens a line in between the 2 areas to show that a join has actually been created.


Change a join

Double-click the sign up with you desire to readjust.

The Join Properties dialog box shows up.


In the Join Properties dialog box, evaluation the three alternatives.

Click the option that you desire to usage, and then click OK.

After the joins are ready, you add output fields — fields that have data that you want in the query outcomes.

Step 3: Add output fields

You can quickly add a field from any kind of of the data resources that you included in action 1.

To add a field, drag the field from a file resource in the upper pane of the query style window dvery own to the Field row of the design grid, in the bottom pane of the query architecture window.

When you include a area this way, Access immediately fills in the Table row of the architecture grid to reflect the data source of the area.

Tip: If you desire to quickly include all areas down to the Field row of the query architecture grid, double-click the table or query name from the top pane to highlight all the fields in that resource and also then drag them all dvery own to the architecture grid at the very same time.

Use an expression as an output field

If you want to percreate calculations or use a duty to create query output, you deserve to usage an expression as an output field. An expression can usage data from any type of of the query data resources, as well as features, such as Layout or InStr, and also can likewise has constants and also arithmetic operators.

In an empty column of the query design grid, right-click the Field row, and then click Zoom on the shortreduced food selection.

Tip 4: Specify criteria

This step is optional.

You use criteria to limit the documents that your query retransforms, on the basis of whether area worths satisfy the criteria that you specify.

Specify criteria for an output field

Specify any kind of alternate criteria in the Or row, below the Criteria row.

If you specify alternative criteria, a area value deserve to meet any type of of the detailed criteria and be consisted of in the query outcome.

Multiple field criteria

You can use criteria via multiple fields. When you execute, all the criteria in a provided Criteria or Or row need to be true for the document to be had.

Specify criteria by making use of a area that you do not want to output

You can add a field to your query design and also not incorporate the field"s information in the query output. You carry out this if you desire to usage the field"s worths to limit the query outcomes, however don"t want to check out the area values.

Add the area to the architecture grid.

Clear the check box in the Show row for the field.

Specify criteria as you would certainly for an output area.

Tip 5: Summarize data

This action is optional.

You might want to summarize data, specifically if your data is numeric. For instance, you could want to check out the average price, or complete sales.

To summarize information in a query, you use the Total row. By default, the Total row is not displayed in Design check out.

With the query open up in Design check out, on the Deauthorize tab, in the Show/Hide team, click Totals.

Access screens the Total row in the query design grid.

Tip 6: View the results

To watch the query outcomes, on the Deauthorize tab, click Run. Access displays the outcomes of your query in Datasheet check out.

To make further alters to the query, click Home > View > Design View to switch earlier to Deauthorize check out.

See more: A Decrease In Variability Leads To An Increase In What Safe Agile

Change your fields, expressions, or criteria and rerun the query until it returns the information that you desire.