0

I am trying to compare two tables Data with this code:

Set rstA = dbs.OpenRecordset("SerialAccount_a")
Set rstB = dbs.OpenRecordset("SerialAccount_b")

While Not rstB.EOF

  serialNumber = rstB.serial
  rstB.Filter = "serial = '" & serial & "'"
  Set rstFiltered = rstB

  Do While Not rstFiltered.EOF

    If rstA.Fields("serial") = rstB.Fields("serial") Then

      If rstA.Fields("accountnumber") <> rstB.Fields("accountnumber") Then

        accountMessage = "... do not match!"
        Debug.Print accountMessage

      ElseIf rstA.Fields("model_number") <> rstB.Fields("model_number") Then

        modelMessage = "... do not match!"
        Debug.Print modelMessage

      End If

    End If
  Wend

Wend

When I try to run it, the compiler gives me the error "Method or data member not found" on the line:

serialNumber = rstB.serial

And I don't understand why, serial is a column in both of those tables. Can someone clue me in as to why this error is popping up?

4

1 回答 1

4

您想要rstB!serialrstB.Fields("serial")。前者使用“bang”运算符 ( !) 作为后者的语法糖。

当你写rstB.serial你试图引用记录集的serial 属性。但是记录集对象没有serial属性,因此您收到“找不到方法或数据成员”错误。

于 2013-07-18T20:51:25.603 回答