Solved

Empty Recordset

Posted on 1998-06-29
3
187 Views
Last Modified: 2010-05-03
Code Example:
...
sq = "SELECT * FROM..."
Set rec = ...
X = rec!SomeThing

Problem:
If no "SomeThing" is found in the database or "SomeThing" is "empty", there will be an error.

Workaround:
On Error Resume next
...
recTest = ""
recTest = rec!SomeThing
If recTest <> "" Then ...

Solution:
What is the "value" of rec!SomeThing, if SomeThing is not found or empty?
0
Comment
Question by:soeding1
  • 2
3 Comments
 
LVL 18

Accepted Solution

by:
deighton earned 50 total points
Comment Utility

    sq = "SELECT * FROM..."
    Set rec = ...
    if rec.RecordCount > 0 then

    X = rec!SomeThing

   else
     msgbox "Ooops"
end if

0
 
LVL 18

Expert Comment

by:deighton
Comment Utility
To clarify my answer

If the recordset is empty then you cant' access the field value without error.  You check for this with rec.RecordCount = 0 (indicates empty record set)


0
 

Author Comment

by:soeding1
Comment Utility
deighton,
of course...
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now