Solved

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

Posted on 2011-03-16
6
681 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
[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
  • 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 500 total points
ID: 35151986
are you sure you are not confusing the error to actually happen in some other place of the code?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

617 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