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?

2
  • 2
    You're not even using that variable anywhere. Commented Jul 18, 2013 at 21:17
  • 1
    I imagine line 7 needs a fix ... will be noticed as soon as line 6 is figured out. :-) Commented Jul 18, 2013 at 23:24

1 Answer 1

4

You want either rstB!serial or rstB.Fields("serial"). The former uses the "bang" operator (!) as syntactical sugar for the latter.

When you write rstB.serial you are trying to reference the serial property of the recordset. But recordset objects have no serial property, hence the "Method or data member not found" error you received.

Sign up to request clarification or add additional context in comments.

1 Comment

This is a true story. See this article to know when you should bang. blogs.msdn.com/b/frice/archive/2004/02/18/75685.aspx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.