Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

MS Access query criteria


May 16, 2021 MS Access


Table of contents


Query criteria can help you retrieve specific items from the Access database. ia. f you want to limit the results of a query based on the values in the field, you use query criteria.

  • The query condition is that Access compares the query field value to determine whether to include an expression for the record that contains each value.

  • Some standards are simple and use basic operators and constants. Others are complex, using functions, special operators, and include field references.

  • To add some conditions to a query, you must open the query in the design view.

  • Then, determine the field for which you want to specify the criteria.

Example

Let's look at a simple example, and we'll use conditions in the query. First open your Access database, then go to the Create tab, and then click Query Design.

MS Access query criteria

In the Table tab of the Display Table dialog box, double-click the tblEmployees table, and then close the dialog box.

MS Access query criteria

Now let's add some fields to the query grid, such as ImployeeID, FirstName, LastName, JobTitle, and Email, as shown in the screenshot below.

MS Access query criteria

Now let's run your query and you'll only see these fields as the result of the query.

MS Access query criteria

If you only want to see those whose JobTitle is a marketing coordinator, you need to add conditions to it. Let's go to query design again and enter the Marketing Coordinator in jobTitle's Criteria line.

MS Access query criteria

Let's run your query again and you'll see that only the marketing coordinator's title is retrieved.

MS Access query criteria

If you want to add conditions to more than one field, simply add conditions in more than one field. Let's say that we just want to retrieve data from the Marketing Coordinator and accounting assistant; We can specify the OR line operator, as shown in the following screenshot -

MS Access query criteria

Let's run your query again and you'll see the following results.

MS Access query criteria

If you need to use the functionality of the AND operator, you must specify additional conditions in the Conditions row. me.

MS Access query criteria

Now let's run the query again and you'll see the following results.

MS Access query criteria