Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old February 23rd, 2004, 10:57 PM
abdulnetod abdulnetod is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 2 abdulnetod User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Empty Recordset Problem

Hi every one ! I am new to the VBA and wondering if some one can hlep me, I am trying to run a simple Select statement by using the CurrentDb.OpenRecordset function which works fine if there are more than zero records but if Select statement does not return any thing it displays an error message. Can any one tell how can I check if there are more than zero records before I use CurrentDb.OpenRecordset function. Follwoing is the Code I am using

Dim memberDetailsREc As DAO.Recordset
If Len(memberDetailsREc!memberClubId) > 0 Then
Set memberClubREc = CurrentDb.OpenRecordset("SELECT tblClubDetails.*, tblRefClubResources.* FROM `tblClubDetails`, `tblRefClubResources` WHERE CInt( tblClubDetails.clubProfileId) = tblRefClubResources.courseDetailId AND tblClubDetails.clubId = " & memberDetailsREc!memberClubId & ";")
End If

Reply With Quote
  #2  
Old February 24th, 2004, 12:28 AM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 19 h 13 m
Reputation Power: 180
I don't use DAO, but it's probably similar to how you test an ADO recordset for emptiness.

Code:
if rs.bof and rs.eof then
  'rs is empty
else
  'there is something in the recordset
end if
__________________
======
Doug G
======
I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain

Reply With Quote
  #3  
Old February 24th, 2004, 07:08 PM
abdulnetod abdulnetod is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 2 abdulnetod User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Empty Recordset Problem

Doug G
My Problem is still there, I am thinking of way where I can Check The SQL select statement if it returns any records or not, before I call the OpenRecordset method on my SQL select statement. Whereas in your technique I have to open the record set

Reply With Quote
  #4  
Old February 24th, 2004, 09:29 PM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
ASP Free God 14th Plane (11500 - 11999 posts)
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,751 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 3 h 32 m 46 sec
Reputation Power: 443
My suggestion would be to not use DAO, since it an outdated technology and no longer supported. I would recommend using ADO or ADO.NET.

Reply With Quote
  #5  
Old February 25th, 2004, 02:18 AM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 19 h 13 m
Reputation Power: 180
Quote:
Doug G
My Problem is still there, I am thinking of way where I can Check The SQL select statement if it returns any records or not, before I call the OpenRecordset method on my SQL select statement. Whereas in your technique I have to open the record set

How in the world could you tell if a recordset is empty before you create the recordset? That would take some kind of prescience.

Reply With Quote
  #6  
Old May 14th, 2004, 05:22 AM
RvK RvK is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 2 RvK User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thumbs up

try enclosing the error inside a error handler

Ex:
On error go to err_handler
...
Your stuff
exit sub
Err_handler:
err.description (err is the error handler object)
err.clear
end sub

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Empty Recordset Problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway