-
Is there a way to determine whether a recordset has been instantiated ?
For eg.If I have
Option Explicit
Dim rstDetail As ADODB.recordset
:
:
:
:
Set rstDetail = Conn.Execute("SELECT * FROM Table",,adcmdText)
:
:
If there is a runtime error when executing the above statement, the program will exit. During the exiting function, I will close every recordset that I dimmed but for the above recordset, I will have an error coz' the recordset is not created. So, is there anyway to check the status ? I tried to use 'rstDetail.state = adStateOpen' but failed because this cannot determine whether the recordset has been instantiated.
-
Check if it is nothing, or empty or null or something. Don't know which becuse i haven't used a recordset in ages.
-
I don't know if it works, but try setting it to nothing first:
Code:
Set rstDetail = Nothing
-
When I close a form, I close all my recordsets when I unload the form. If any of the recordsets are not open, and error ocurrs (3704) which I just trap and resume next.
It works for me :)