How do I tell if the Recordset closed? 
Author Message
 How do I tell if the Recordset closed?

This should be a no brainer, but it's eluding me.  In ADO  you can check
rs.State to see if the recordset is closed.  How can I tell in DAO 3.51?

Thanks!

RobB



Sun, 28 Sep 2003 22:06:21 GMT  
 How do I tell if the Recordset closed?

Quote:

>This should be a no brainer, but it's eluding me.  In ADO  you can check
>rs.State to see if the recordset is closed.  How can I tell in DAO 3.51?

>Thanks!

>RobB

Rob

I don't think that you can. If you are trying to do something in the exit point
of a procedure, where you only want to close the Recordset and set it to
Nothing if needed, you can use On Error Resume Next.

Jon

Access tips & tricks - http://www.applecore99.com
Microsoft Access webring -
http://nav.webring.yahoo.com/hub?ring=microsoftaccess



Mon, 29 Sep 2003 03:09:05 GMT  
 How do I tell if the Recordset closed?
Rob:

'************
Dim varReturn as Variant
On Error Resume Next
varReturn = rs.Recordcount
If Err <> 0 then
    'rs must be closed
Else
    'rs must be open
End if
'************

Should work, for what its worth.
--
Bruce M. Thompson


Quote:
> This should be a no brainer, but it's eluding me.  In ADO  you can check
> rs.State to see if the recordset is closed.  How can I tell in DAO 3.51?

> Thanks!

> RobB



Mon, 29 Sep 2003 08:11:50 GMT  
 How do I tell if the Recordset closed?
I see 2 other answers but I still feel that I should answer too.

Would using the "is Nothing" test be useful?

Sub nnn()
Dim db As Database, rs As Recordset
 Set db = CurrentDb
 Set rs = db.OpenRecordset("people")
 If rs is Nothing then MsgBox "I have no rs"
 rs.Close
 If rs is Nothing then MsgBox " I have closed rs"
 Set rs = Nothing
 If rs Is Nothing Then  MsgBox "rs is nothing"
End Sub

--
Mark
( E-Mail Address Note: Texas is the lonestar not onestar)

Quote:

> This should be a no brainer, but it's eluding me.  In ADO  you can check
> rs.State to see if the recordset is closed.  How can I tell in DAO 3.51?

> Thanks!

> RobB



Mon, 29 Sep 2003 09:42:55 GMT  
 How do I tell if the Recordset closed?
Mark:

Testing for "rs Is Nothing" will only return True if "rs" has been set to
nothing or has not yet been set. It is still "Something" (not an actual
property) if it has merely been closed. In your example, only the last MsgBox
will come up.
--
Bruce M. Thompson


Quote:
> I see 2 other answers but I still feel that I should answer too.

> Would using the "is Nothing" test be useful?

> Sub nnn()
> Dim db As Database, rs As Recordset
>  Set db = CurrentDb
>  Set rs = db.OpenRecordset("people")
>  If rs is Nothing then MsgBox "I have no rs"
>  rs.Close
>  If rs is Nothing then MsgBox " I have closed rs"
>  Set rs = Nothing
>  If rs Is Nothing Then  MsgBox "rs is nothing"
> End Sub

> --
> Mark
> ( E-Mail Address Note: Texas is the lonestar not onestar)


> > This should be a no brainer, but it's eluding me.  In ADO  you can check
> > rs.State to see if the recordset is closed.  How can I tell in DAO 3.51?

> > Thanks!

> > RobB



Mon, 29 Sep 2003 20:59:49 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Please tell me what I am doing wrong - DAO parameter Append Query :(

2. How to tell when all a form and all it's elements are done loading

3. Will somebody tell me what I am doing wrong with this ListView Control

4. tell another program i am done

5. Does ADO Connection.Close ,Closes all open Recordsets

6. When closing a connection, recordset is also closed!

7. New Recordset and Closed Recordset

8. Set Recordset to Nothing vs Recordset.close

9. recordset.close vs. set recordset=nothing

10. Set Recordset = Nothing or Recordset.close

11. How do you tell when a program closed?

12. Going crazy, says object is closed yet I never told it to

 

 
Powered by phpBB® Forum Software