Problem with DAO FindFirst

I'm getting an error message on the FindFirst line in the following code.
The error message is "Run-time error '3251'   Operation is not supported for this type of object."
Can someone tell me what I am doing wrong?

    Dim rs As DAO.Recordset
    Dim rs2 As DAO.Recordset
    Dim i As Long
    Dim reccount As Long
   

    Set rs = CurrentDb.OpenRecordset("2015and2016ServicePartsOrders")
    Set rs2 = CurrentDb.OpenRecordset("ItemPriceHistory")
    reccount = DCount("*", "2015and2016ServicePartsOrders")
    rs.MoveFirst
    For i = 1 To reccount
        rs2.FindFirst ("[ItemNumber]= ' " & rs!ItemNumber & " ' ")
        If rs2.NoMatch Then
            rs.Edit
            rs![List Price] = 0
            rs.Update
        Endif
        If i = reccount Then
            Exit For
        Else
           rs.MoveNext
        End If
  next I
  rs.close
  rs2.close
dsoderstromAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bill PrewIT / Software Engineering ConsultantCommented:
Try this small change:

    Set rs2 = CurrentDb.OpenRecordset("ItemPriceHistory", dbOpenDynaset)

Open in new window


»bp
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bill PrewIT / Software Engineering ConsultantCommented:
I also notice you have extra spaces, please adjust this line as well so the matches will be found:

        rs2.FindFirst ("[ItemNumber] = '" & rs!ItemNumber & "' ")

Open in new window


»bp
0
Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
    Dim db as DAO.Database
    Dim rs As DAO.Recordset
    Dim rs2 As DAO.Recordset

   Set db = CurrentDB()
    Set rs = db.OpenRecordset("2015and2016ServicePartsOrders")
    Set rs2 = db.OpenRecordset("ItemPriceHistory")

   Do until rs.EOF
        rs2.FindFirst  "[ItemNumber]= ' " & rs!ItemNumber & " ' "
        If rs2.NoMatch Then
            rs.Edit
            rs![List Price] = 0
            rs.Update
        Endif

        rs.MoveNext
   loop

  rs.close
  Set rs = nothing

  rs2.close
  set rs2 = nothing

  set db = nothing

Open in new window

0
dsoderstromAuthor Commented:
That fixed the problem.  Thank You.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.