Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2011-03-16
6
Medium Priority
?
684 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 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 35151769
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
ID: 35151853
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 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 35151986
are you sure you are not confusing the error to actually happen in some other place of the code?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 10

Expert Comment

by:ALaRiva
ID: 35152316
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
ID: 35154088
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
ID: 35154091
Thank you very much
0

Featured Post

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Question has a verified solution.

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

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
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 …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Suggested Courses

916 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