" If a match is found, print the value of
" the specified field.
If Not .EOF Then
Debug.Print .Fields(strDisplayField).Value
End If
" Close the Recordset object.
.Close
End With
" Close connection and destroy object variables.
cnn.Close
Set rst = Nothing
Set cnn = Nothing
End Sub
例如,用主键索引查询“罗期文商贸”示例数据库中“订单明细”表的“订单编号”等于10255并且产品编号等于16的”数量”的值,可以使用下面的代码:
SeekRecord “c:\Program Files\Microsoft Office\Office\Samples\Northwind.mdb”, _
“PrimaryKey”, “Order Details”, Array(10255,16), ”Quantity”
(译者注:如果你安装的是简体中文版要将示例中引用的相应的字段名改成中文)