In and Between Queries

Queries let you answer a particular question by selecting records which match some test or criterion. Most simple queries use an equals sign in the criterion and they will find all records matching the value that you specify. Use the "In" and "Between" expressions for more flexibility.

In

For example you could use an "In" expression to find customers in the UK, France, and Germany:

[Access Query Designer showing an IN clause]

You could of course have written this on three lines of the grid as "=UK", "=Germany" and "=France" but the shorter form saves typing.

The criterion can be inverted as "Not In(UK, France, Germany)" to give customers outside these three countries.

SQL subqueries take this concept one stage further but you do need to know a little SQL to be able to use them.

Between

The meaning or "Between" is probably obvious, it gives you the records which lie between two values. For example:

[Access Query Designer showing a Between clause]

There is a subtle problem with this example. It will give you all the countries between "A" and "G" but it won't give you "Germany". The reason is that "G" comes before "Germany" in the alphabet. If you wanted to get all the countries beginning with "G"as well then change the criterion to something like Between "A" and "Gzzzzz".

Related Items

FoxPro cursors

FoxPro cursors

Using cursors in FoxPro

Read More

Using a FoxPro cursor in a combo box

Using a cursor to fill a combo box or list box in FoxPro

Read More

Linking two listboxes in Microsoft Access

Linking parent and child listboxes in Microsoft Access so that selecting a new value in one listbox changes the values displayed in the other.

Read More

SQL Subqueries in Microsoft Access

Using SQL queries and subqueries in Microsoft Access

Read More

Faster SQL queries in Microsoft Access

How to improve the speed of SQL queries in an Access database

Read More