MS Access 可以在手表 window 中看到项目,但抛出错误 "item not found in this collection"

MS Access can see item in the watch window but error thrown saying "item not found in this collection"

正在尝试将一个 DAO 记录集的值分配给另一个。并收到错误 3265 "Item not found in this collection"。但是,当我查看手表 window 时,collection 项和值可用。我在这里使用的语法不正确吗?

所以'rs'中涉及的'Select'从数据库中抓取一条查询语句 查询在 rs2 中执行,第一个字段应该回发到第一个记录集中

If Not (rs.EOF And rs.BOF) Then
rs.MoveFirst 'Unnecessary in this case, but still a good habit
Do Until rs.EOF = True

     qry = rs!Query

     'process the query
     Set rs2 = db.OpenRecordset(qry)
     If Not (rs2.EOF And rs2.BOF) Then
        rs2.MoveFirst
        Do Until rs2.EOF = True
            rs!NewValue = rs2.Fields(1).value

            rs2.MoveNext

            DoEvents

        Loop
     End If
...

当我查看 rs2.Fields 下的手表 window 时,Count=1 和 'Item 1' 具有预期的值。然而,与代码执行一样,如果我查看 rs2.Field(1) 它会报告 "Item not found in this collection."

有什么想法吗?

记录集中的字段从 0 开始索引。试试这个:

rs!NewValue = rs2.Fields(0).value