Solved

How to avoid BOF EOF error when there is no record in the database

Posted on 2011-03-16
6
673 Views
Last Modified: 2012-05-11
With the following line I retrieve the checkmark as a letter (ü) from my column named EIT:

<%If rs3.BOF and rs3.EOF then Response.Write "&nbsp;" Else response.write rs3.fields("EIT") End If%>

I would like to do the same when I use a checkbox, but it gives me the BOF EOF error. Could you please help me modify the code below so that the checkbox shows even when there is no record.
Thank you


<%
If Not rs3.EOF Then
  If rs3("EIT") = "ü" Then %>
     <input name="EIT" value="ü" checked type="checkbox">
  <% Else %>
     <input name="EIT" value="ü" type="checkbox">
  <% End IF
End IF
%>

Open in new window

0
Comment
Question by:baxtalo
  • 3
  • 2
6 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
it's still the same code:
<%
If Not ( rs3.EOF and rs3.BOF) Then
  If rs3("EIT") = "ü" Then %>
     <input name="EIT" value="ü" checked type="checkbox">
  <% Else %>
     <input name="EIT" value="ü" type="checkbox">
  <% End IF
End IF
%>

Open in new window

0
 

Author Comment

by:baxtalo
Comment Utility
It gives me this error message:

ADODB.Field error '80020009'

Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

/EIT/00.asp, line 0

It would be nice if the error would be replaced by &nbsp; like in the case of my first line when there is no record.
 
0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
Comment Utility
are you sure you are not confusing the error to actually happen in some other place of the code?
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 10

Expert Comment

by:ALaRiva
Comment Utility
That error is not related to the BOF/EOF directly. You have no current record.

Can you post the entire piece of code?
0
 

Author Comment

by:baxtalo
Comment Utility
I was absolutely sure that the problem was caused by this peace of code. It was right at the end of the page, just before the submit button. Angellll, when you asked if I was sure, I just cut it out to see what happens. The error was still there, so I knew you were right. What else was on the page? A hidden field before the submit button:
<input type="hidden" name="ID" value="<%=rs3("ID")%>">
I replaced with the code below, and now the problem is fixed.
<input type="hidden" name="ID" value="<%If rs3.BOF and rs3.EOF then Response.Write "&nbsp;" Else response.write rs3.fields("ID") End If%>">
I'm sorry for the confusion. Angellll, I did this to you for the second time. Thanks for your patience with me and I hope you won't ignore my questions in the future.
0
 

Author Closing Comment

by:baxtalo
Comment Utility
Thank you very much
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
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…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

763 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

6 Experts available now in Live!

Get 1:1 Help Now