In operator (Microsoft Access SQL)

Applies to: Access 2013 | Access 2016

Determines whether the value of an expression is equal to any of several values in a specified list.


expr [ Not ] In( value1, value2, … )


The In operator syntax has these parts:

Part Description
expr Expression identifying the field that contains the data you want to evaluate.
value1, value2 Expression or list of expressions against which you want to evaluate expr.

If expr is found in the list of values, the In operator returns True; otherwise, it returns False. You can include the Not logical operator to evaluate the opposite condition (that is, whether expr is not in the list of values).

For example, you can use In to determine which orders are shipped to a set of specified regions:

FROM Orders 
WHERE ShipRegion In ('Avon','Glos','Som')


The following example uses the Orders table in the Northwind.mdb database to create a query that includes all orders shipped to Lancashire and Essex and the dates shipped.

This example calls the EnumFields procedure, which you can find in the SELECT statement example.

Sub InX() 
    Dim dbs As Database, rst As Recordset 
    ' Modify this line to include the path to Northwind 
    ' on your computer. 
    Set dbs = OpenDatabase("Northwind.mdb") 
    ' Select records from the Orders table that 
    ' have a ShipRegion value of Lancashire or Essex. 
    Set rst = dbs.OpenRecordset("SELECT " _ 
        & "CustomerID, ShippedDate FROM Orders " _ 
        & "WHERE ShipRegion In " _ 
        & "('Lancashire','Essex');") 
    ' Populate the Recordset. 
    ' Call EnumFields to print the contents of 
    ' the Recordset. 
    EnumFields rst, 12 
End Sub

See also

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.