In Operator Example (DAO)

Microsoft Jet SQL Reference

In Operator 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