Solved

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

Posted on 2011-03-16
6
675 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]
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 142

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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

774 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