How to check if a recordset is opened ?
I have declare a recordset
VB Code:
public rs as new ADODB.recordset
It is used in many functions that I have in my form.
However sometimes, I encounter problem when I try to open it again as it says it is already opened. Reason because I allow the user to break the loop and exit function hence, sometimes the recordset is not closed.
Question : How can I check if a particular recordset is already opened ?
If I can check if it is opened then I can do a rs.close which will solve my problem.
Anyone with solution please help !!!
Re: How to check if a recordset is opened ?
When the loop is exited close the recordset. :)
Re: How to check if a recordset is opened ?
My function is complex .... I know that by exiting the loop I can close it, however, when the user break the loop .... it can sometimes bypass the recordset.close
Again, once the recordset is closed, it cannot be close again. A error will be prompted.
Also, is there a way to turn off error messages in VB6 ?
Sometime like in access where you can docmd.setwarnings = false ...
but in VB6 you cannot .... :(
Re: How to check if a recordset is opened ?
Ok problem solved.
Apparaently, there is a property .state which allow me to check if it is opened or not.
VB Code:
if rs.state = adStateOpen then rs.close
That solved my problem.
Cheers !!!