none
Recordset.movefirst generates runtime error 91 RRS feed

  • Question

  • I have a recordset  and its clone that are declared as private at the top of the code:

    Private Rst(1 to 2) as recordset

    I fill Rst(1) in the Form Load event from a table as dbopendynaset.

    I clone it for a small subroutine that identifies a specific pattern within the table.

    In another subroutine when the code encounters Rst(1).MoveFirst, I get a runtime error 91 "Object variable or With block not set."

    In the Watch window it reports that the Rst(1) is Nothing.  I can find nothing that would close this dataset in my code.

    I encountered this before I added the clone process, so I don't think they are related, but I am baffled.

    Any input is appreciated.

    Marj Weir

    Tuesday, November 3, 2015 5:16 PM

All replies

  • Update.  

    I have moved the creation of the recordset to the Open Event instead of the Load event and the problem seems to have gone away!

    Marj Weir

    Tuesday, November 3, 2015 5:38 PM
  • I don't know about anybody else, but I'd need to see the code.

    In debugging, you could set a watch on Rst(1) and step through the code to see at which point it becomes Nothing.


    Dirk Goldgar, MS Access MVP
    Access tips: www.datagnostics.com/tips.html

    Tuesday, November 3, 2015 5:40 PM
  • Thanks.  I can't explain it, but moving the code to the Open Event seems to have solved this problem.

    Marj Weir

    Thursday, November 5, 2015 4:34 AM