I am consistently receiving an Access Error, "Object variable or With variable not set". I am beginning to believe that the scope of an open recordset is limited to a procedure but I hope this is not the case.
I use several recordsets in many procedures within the class module. I am declaring the database and the recordsets in the Declarations Section of the module. For example:
Option Compare Database
Option Explicit
Private dbs As Database
Private rst_RO As Recordset 'recordset of the Ordered Room
Then in the Form's OnOpen Event I am setting the database and all of the recordsets for example:
Private Sub Form_Open(Cancel As Integer)
Set dbs = CurrentDb
Set rst_RO = dbs.OpenRecordset("Room_Ordered", dbOpenDynaset)
My thought was that the recordsets would remain open until the Form's OnClose Event where I close the database and the recordsets.
However, I am being shot dead in the water with the above error!
I have looked in this forum and found one suggestion that the recordsets be opened on the Form's OnLoad event for them to have a scope covering the entire class module. Is there agreement to this? Or is the scope of a recordset limited to a single procedure?
I will greatly appreciate any responses to this question!
Regards, Sorrells
Regards, Sorrells
I use several recordsets in many procedures within the class module. I am declaring the database and the recordsets in the Declarations Section of the module. For example:
Option Compare Database
Option Explicit
Private dbs As Database
Private rst_RO As Recordset 'recordset of the Ordered Room
Then in the Form's OnOpen Event I am setting the database and all of the recordsets for example:
Private Sub Form_Open(Cancel As Integer)
Set dbs = CurrentDb
Set rst_RO = dbs.OpenRecordset("Room_Ordered", dbOpenDynaset)
My thought was that the recordsets would remain open until the Form's OnClose Event where I close the database and the recordsets.
However, I am being shot dead in the water with the above error!
I have looked in this forum and found one suggestion that the recordsets be opened on the Form's OnLoad event for them to have a scope covering the entire class module. Is there agreement to this? Or is the scope of a recordset limited to a single procedure?
I will greatly appreciate any responses to this question!
Regards, Sorrells
Regards, Sorrells