I'm having a problem dealing with a recordset closing. The problem occurs when I got an error message.
"Operation is not allowed when the object is open."
So I get the bright idea to test if the recordset (rs) is open as in
if rs.state = 1 then
rs.close
end if
But, when it executes this line I get an error "Operation is not allowed in this context".
Seems like I'm dammed if I do and dammed if I don't. Is there some other way to handle the recordset state?
I have the recordset defined in a module as in:
Dim rs As New ADODB.Recordset
I assumed that once declared all I would have to do is open and close the recordset. Can someone explain the error messages and their cause.
How do I handle a situation where the code encounters an error condition in the main body of code and goes to an error handler? Should I be testing to see if the recordset is open in the event handler and if so close it or will the recordset close when the sub procedure closes?
Thanks,
Tom
"Operation is not allowed when the object is open."
So I get the bright idea to test if the recordset (rs) is open as in
if rs.state = 1 then
rs.close
end if
But, when it executes this line I get an error "Operation is not allowed in this context".
Seems like I'm dammed if I do and dammed if I don't. Is there some other way to handle the recordset state?
I have the recordset defined in a module as in:
Dim rs As New ADODB.Recordset
I assumed that once declared all I would have to do is open and close the recordset. Can someone explain the error messages and their cause.
How do I handle a situation where the code encounters an error condition in the main body of code and goes to an error handler? Should I be testing to see if the recordset is open in the event handler and if so close it or will the recordset close when the sub procedure closes?
Thanks,
Tom