In 运算符示例 (DAO)

In 运算符示例

下列示例使用在 Northwind.mdb 数据库的订单表创建查询,且该查询包含所有送货到 Lancashire 和 Essex 的数据及送货日期。

此示例调用过程 EnumFields 过程,且可以在 SELECT 语句示例中找到该过程。

Sub InX()

   Dim dbs As Database, rst As Recordset

   ' 在您的计算机中修改此行使其正确指到 Northwind 的路径。

   Set dbs = OpenDatabase("Northwind.mdb")

   ' 对运费超过 $100 的订单,

   ' 选择订单表中其 ShipRegion 值为

   ' Lancashire 或 Essex 的记录。

   Set rst = dbs.OpenRecordset("SELECT " _

       & "CustomerID, ShippedDate FROM Orders " _

       & "WHERE ShipRegion In " _

       & "('Lancashire','Essex');")

 

   ' populateRecordset。

   rst.MoveLast

 

   ' 调用EnumFields打印此内容

   ' populateRecordset。

   EnumFields rst, 12

   dbs.Close

End Sub