Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / September 2006

Tip: Looking for answers? Try searching our database.

ADO test for empty recordset

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
BillyRogers - 26 Sep 2006 15:34 GMT
How do i test a recordset before using the fields?  Can you simply test for

If not (rst.eof) and not (rst.bof) then

      debug.print rst.fields(0)

End If

My only concern with this test is that I don't know if a recordset can open
at EOF or BOF even if it's not empty.  I only want to skip empty recordsets
to avoid errors.  My recordset is a SQL query.

Signature

Billy Rogers

Dallas,TX

Currently Using Office 2000  and Office 2003

Douglas J. Steele - 26 Sep 2006 16:24 GMT
What you've got is the appropriate check.

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

> How do i test a recordset before using the fields?  Can you simply test
> for
[quoted text clipped - 10 lines]
> recordsets
> to avoid errors.  My recordset is a SQL query.
Alex Dybenko - 26 Sep 2006 16:31 GMT
Hi,
yes, this is a right approach

Signature

Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com

> How do i test a recordset before using the fields?  Can you simply test
> for
[quoted text clipped - 10 lines]
> recordsets
> to avoid errors.  My recordset is a SQL query.
Dirk Goldgar - 26 Sep 2006 16:50 GMT
> How do i test a recordset before using the fields?  Can you simply
> test for
[quoted text clipped - 8 lines]
> can open at EOF or BOF even if it's not empty.  I only want to skip
> empty recordsets to avoid errors.  My recordset is a SQL query.

If you *know* the recordset has just been opened, then you need only
check for either rst.EOF or rst.BOF.  The recordset will be opened at
the first record, if there are any records in it.  However, if there's
any question that the recordset's current record pointer may have been
moved since it was opened -- and especially if you've just been handed a
recordset from somewhere -- checking for both conditions is the right
way to do it.

Signature

Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.