dbTalk Databases Forums  

Looking for a slick way to test for an unopened recordset

comp.database.ms-access comp.database.ms-access


Discuss Looking for a slick way to test for an unopened recordset in the comp.database.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
MyndPhlyp
 
Posts: n/a

Default Looking for a slick way to test for an unopened recordset - 05-24-2004 , 02:00 AM






I've tried IsNull() and IsEmpty() on an uninitialized ADODB.Recordset, but
they both return False.

VBA, at least under Access 2000, doesn't like the test:

If rs = Nothing Then ...

Is there an easy test to determine if a recordset is open?



Reply With Quote
  #2  
Old   
Michael
 
Posts: n/a

Default Re: Looking for a slick way to test for an unopened recordset - 05-24-2004 , 07:14 PM






Hi there,

This ought to do it:

if rs.EOF and rs.BOF then


Ie if rs.end of file and rs.beginning of file

the recordset cursor is simultaneously set to point to the beginning
and the end of the recordset when there are no records.





"MyndPhlyp" <nobody (AT) home (DOT) now> wrote

Quote:
I've tried IsNull() and IsEmpty() on an uninitialized ADODB.Recordset, but
they both return False.

VBA, at least under Access 2000, doesn't like the test:

If rs = Nothing Then ...

Is there an easy test to determine if a recordset is open?

Reply With Quote
  #3  
Old   
MyndPhlyp
 
Posts: n/a

Default Re: Looking for a slick way to test for an unopened recordset - 05-24-2004 , 09:34 PM




"Michael" <westmj (AT) hotmail (DOT) com> wrote

Quote:
Hi there,

This ought to do it:

if rs.EOF and rs.BOF then


Ie if rs.end of file and rs.beginning of file

the recordset cursor is simultaneously set to point to the beginning
and the end of the recordset when there are no records.
That only tells me if there are no records in the recordset. I'm trying to
determine if the recordset is open.

I think I have a solution from another NG, and I've also found a correction
to my syntax problem:

If IsObject(rs) Then
If rs Is Nothing Then
'.. recordset is not open
End If
End If




Reply With Quote
  #4  
Old   
Scott McDaniel
 
Posts: n/a

Default Re: Looking for a slick way to test for an unopened recordset - 05-25-2004 , 07:37 AM



An ADO recordset returns the State property which can be read. For Example:

Dim rs As ADODB.Recordset

Set rs = New ADODB.Recordset

if rs.State = adStateOpen Then
etc etc

Check the Object Browser for the ObjectStateEnum collection in the ADODB
library ...

--
Scott McDaniel
CS Computer Software
Visual Basic - Access - Sql Server - ASP

"Smash forehead on keyboard to continue ... "


"MyndPhlyp" <nobody (AT) home (DOT) now> wrote

Quote:
I've tried IsNull() and IsEmpty() on an uninitialized ADODB.Recordset, but
they both return False.

VBA, at least under Access 2000, doesn't like the test:

If rs = Nothing Then ...

Is there an easy test to determine if a recordset is open?





Reply With Quote
  #5  
Old   
MyndPhlyp
 
Posts: n/a

Default Re: Looking for a slick way to test for an unopened recordset - 05-25-2004 , 02:25 PM




"Scott McDaniel" <scott (AT) no (DOT) spam.thedatabaseplace.net> wrote

Quote:
An ADO recordset returns the State property which can be read. For
Example:

Dim rs As ADODB.Recordset

Set rs = New ADODB.Recordset

if rs.State = adStateOpen Then
etc etc
Cool. Looks better than what I was using ...

If rs.ActiveConnection Is Nothing Then

Using rs.State certainly documents better. Thanx.




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.