Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to avoid error 80020009 if there is no record in the table

Posted on 2011-03-12
4
Medium Priority
?
682 Views
Last Modified: 2012-06-21
When I have records in the database this code works fine:
<%If IsNull(rs2("Certified")) or rs2("Certified")="" Then %>No<%else%>Yes<%end if%>
If there are no records I get the error 80020009 message
I'm using classic ASP and the database is MS Access.
Can somebody please help?
Thank you
0
Comment
Question by:baxtalo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 35118799
you have to first test if rs2.eof and rs2.bof then , if both properties return true, there is no record in the recordset. ...
0
 

Author Comment

by:baxtalo
ID: 35118918
my page identifies the logged in user. If the logged in user's emp_id is present in the database there is no error message, regardless if the Certified field is checked or it's empty. But sometimes my page is visited by users whose emp_id is not in the database. This is when the error 80020009 message appears, and the rest of the page is not displayed.
I wonder if this can be avoided.
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 35118943
>If there are no records I get the error 80020009 message
that is exactly what I suggested with my first comment ...

<%
If rs2.EOF and rs2.BOF Then 
  %>New<% 
Else If IsNull(rs2("Certified")) or rs2("Certified")="" Then 
  %>No<%
else
  %>Yes<%
 end if 'else from Certified test
end if 'else from eof/bof test
%>

Open in new window

0
 

Author Closing Comment

by:baxtalo
ID: 35118968
Perfect, thank you very much.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

610 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