I was trying to use the Recordset.FindFirst
method with DAO recordsets, in Access VBA, when I came across the error:
Error 3251: "Operation is not supported for this type of object."
After some brief investigation on the MSDN, I discovered that the method only works on dynaset-type
or snapshot-type
recordsets. I changed my code from this:
Set rs2 = db.OpenRecordset("table_name")
rs2.FindFirst [search criteria]
to this:
Set rs2 = db.OpenRecordset("table_name", dbOpenDynaset)
rs2.FindFirst [search criteria]
and all was working fine.
However, I have another database where I have been using FindFirst
on table-type
recordsets without error.
Set rs = db.OpenRecordset("tblUsers")
rs.FindFirst [search criteria]
My questions are
dbOpenDynaset
type recordsets instead?答案 0 :(得分:2)
当您对查询或附加表执行OpenRecordset()时,Access默认为动态集类型(dbOpenDynaset)。
当你在本地表上使用OpenRecordset()时,它默认为表类型(dbOpenTable。)