Hi out there,
How can I check if a recordset is open or closed? If I unload a form usually a recordset is still open, but on one occation it's closed.
The recordset is not nothing then.
Anybody got an Idea?
have a nice day,
Patzer
Printable View
Hi out there,
How can I check if a recordset is open or closed? If I unload a form usually a recordset is still open, but on one occation it's closed.
The recordset is not nothing then.
Anybody got an Idea?
have a nice day,
Patzer
For ADO, you can use the next code
If rst.state = adStateClosed then
Msgbox "Recordset is closed"
else
Msgbox "Recordset is open"
End If
Tom Cannaerts
[email protected]
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
thanx a lot!!!
simple when you know how (as always in VB).
have a nice day,
Patzer
you can use the state property of the recordset if the recordset is open the rs.state value will be 1 and if the recordset is closed the rs.state value will be 0.this will help you to determine whether the recordset is open or closed.
no.. it' not correct...
rs.state=0 then rs is closed...
bur rs.state=1 is not a correct test...
an rs can be in adStateOpen and adStateFetching ...so its state is 9...
the correct test is
'with reference
if rs.state and adstateopen then
'so i'm sure rs is open
end if
'without reference
if rs.state and 1 then
'so i'm sure rs is open
end if
hi,brt
<center>
<HR width=80%>
<img src='http://web.tiscali.it/bertaplanet/im...ertaplanet.gif'>
</center>
Hi,
I have to admit that I do not really understand your idea so:
If a recordset.state returns true for adStateFetching at a time, does it also return true for adStateOpen at that time?
I mean there are also other states for the rs, as of adstateconnecting and adstateexecuting, so could you please give a little more Information on that?
thx´
have a nice day,
Patzer
the rs.state is a sum of state...
adStateClosed = 0 'bynary ->0000
adStateOpen = 1 'bynary ->0001
adStateConnecting = 2 'bynary ->0010
adStateExecuting = 4 '0100
adStateFetching = 8 '1000
if U want tio check state U must have a bynary check rs.state AND constant -> but it is a bad test when rs.state=adstateopen
so if (rs.state and adstateopen)=false then rs is closed...
exaple rs.state=adstateopen+adstateexecuting
so rs.state=5 -> 0101...
hi,btr
<center>
<HR width=80%>
<img src='http://web.tiscali.it/bertaplanet/im...ertaplanet.gif'>
</center>
Hi Berta,
thx, took some time but then I understood (I think I did :-))
have a nice day,
Patzer