Solved

Empty Recordset

Posted on 1998-06-29
3
190 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
ID: 1464540

    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
ID: 1464541
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
ID: 1464542
deighton,
of course...
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

809 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