Where to enter expressions in queries and filters

Where to enter expressions in queries and filters

You can use expressions — in the design grid of a query or the Advanced Filter/Sort window, in an SQL statement in a query's SQL view, or in the Filter By Form window — to specify criteria that identify the records you want to work with. In queries, you can also use expressions to update values in a group of records or to create calculated fields.

In the design grid, you enter the expression in different places depending on the operation you're trying to perform. (The following table shows where you can enter expressions.) After you type an expression in the design grid and press the ENTER key, Microsoft Access displays the expression using syntax it understands. If you don't include an operator with the expression, Microsoft Access assumes you mean the = operator. For example, if you type Denmark as the criteria in a Country field, Microsoft Access displays "Denmark", and interprets the expression as Country="Denmark". If you include references to field names in the expression, the fields must be in one of the tables added to the query (unless you are using the DLookup function or a subquery). You can't drag the fields to the expression in the design grid, however.

To do this Type the expression in
Specify criteria for a select, crosstab, or action query, or for an advanced filter A Criteria cell in the design grid of a query or advanced filter.
Create a calculated field A Field cell in the design grid of a query or advanced filter.
Update records according to the results of the expression (update queries only) An Update To cell in the design grid of an update query.
Specify the records you want to work with, how they are grouped, the criteria for the groupings, or how records are sorted An SQL statement in SQL view.
Specify criteria when using Filter By Form A field in the Filter By Form window for a custom expression, or select an expression from the list in the field.

Note   You can see how Microsoft Access evaluates query expressions by switching to a query's SQL view to display its underlying SQL statements. To display a query in SQL view, click the arrow next to the View button on the toolbar, and then click SQL View. If your query includes linked tables, the values you specify in criteria on fields from the linked tables are case-sensitive — they must match the case of the values in the underlying table.