Table of contents
TOC
Collapse the table of content
Expand the table of content

In Operator (Microsoft Access SQL)

office 365 dev account|Last Updated: 6/12/2017
|
1 Contributor

Applies to: Access 2013 | Access 2016

In this articleSyntaxRemarks Example

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

Syntax

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

Remarks

The In operator syntax has these parts:

PartDescription
exprExpression identifying the field that contains the data you want to evaluate.
value1, value2Expression 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:

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

Example

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. 
    rst.MoveLast 

    ' Call EnumFields to print the contents of 
    ' the Recordset. 
    EnumFields rst, 12 

    dbs.Close 

End Sub

ACCESS SUPPORT RESOURCES
Access for developers forum on MSDN
Access help on support.office.com
Access help on answers.microsoft.com
Search for specific Access error codes on Bing
Access forums on UtterAccess
Access wiki on UtterAcess
Access developer and VBA programming help center (FMS)
Access posts on StackOverflow

© 2017 Microsoft