M
markmarko
I'm wondering about the difference in declaring a recordset as a recordset or
as an object. For example, the difference between these two decalrations
Dim rs1 as recordset
Dim rs2 as object
When declared as object, I can reference fields in this manner:
rs2.ID or rs2.LastName, etc.
When declard as recordset, those same references error.
rs1.ID results in error "Compile error: Method or data member not found"
HOW does one reference fields in a recordset when it's declared as a
recordset?
ALSO, regarding closing open recordsets, I generally use this code...
For Each TempRsForClosing In CurrentDb.recordsets
If TempRsForClosing.Name = rsSales Then rsSales.Close
If TempRsForClosing.Name = rsInstalls Then rsInstalls.Close
Next TempRsForClosing
The idea being to check that a given recordset is in fact open, then close
it (to avoid errors if it tries to close a recordset that is not open).
THE main question is that this closing code isn't working for me. My
recordsets are currently declared as objects, and when it gets to the For
Each loop, it bypasses it, even though I'm certain there are recordsets
variables still defined.
Should I use a different For Each statement? Should I instead declare
recordsets as recordsets (as opposed to objects)? If so, how do I reference
the fields in that recordset?
as an object. For example, the difference between these two decalrations
Dim rs1 as recordset
Dim rs2 as object
When declared as object, I can reference fields in this manner:
rs2.ID or rs2.LastName, etc.
When declard as recordset, those same references error.
rs1.ID results in error "Compile error: Method or data member not found"
HOW does one reference fields in a recordset when it's declared as a
recordset?
ALSO, regarding closing open recordsets, I generally use this code...
For Each TempRsForClosing In CurrentDb.recordsets
If TempRsForClosing.Name = rsSales Then rsSales.Close
If TempRsForClosing.Name = rsInstalls Then rsInstalls.Close
Next TempRsForClosing
The idea being to check that a given recordset is in fact open, then close
it (to avoid errors if it tries to close a recordset that is not open).
THE main question is that this closing code isn't working for me. My
recordsets are currently declared as objects, and when it gets to the For
Each loop, it bypasses it, even though I'm certain there are recordsets
variables still defined.
Should I use a different For Each statement? Should I instead declare
recordsets as recordsets (as opposed to objects)? If so, how do I reference
the fields in that recordset?