empty recordset

  • Thread starter chewbacca via AccessMonster.com
  • Start date
C

chewbacca via AccessMonster.com

Hello,

How do I keep an empty recordset from showing an error page? When I open my
form, the recordset populates the form and allows it to be updated. But if
the recordset is empty the form won't open. I want that form to open even if
the recorset is empty so that it can be filled by the user.

Please help me
THANK'S
 
D

Dirk Goldgar

chewbacca via AccessMonster.com said:
Hello,

How do I keep an empty recordset from showing an error page? When I open
my
form, the recordset populates the form and allows it to be updated. But
if
the recordset is empty the form won't open. I want that form to open even
if
the recorset is empty so that it can be filled by the user.


A form normally has no objection to being opened with an empty recordset --
it just goes to a blank "new" record. That's assuming the recordsource and
form properties permit a nerw record to be added; otherwise the form is
just blank. If you're getting an error, I suspect there's something
non-standard about your form.

Is this a bound form?

Do you have code in one of the form events that tries to navigate within the
form's recordset?
 
C

chewbacca via AccessMonster.com

Thanks Dirk for your response

I get the following typical error every time i try to open the popup page
that contains the form:

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

I have another form on the site that works perfectly and is very similar
except for a dropdown select with a do while statement in it.

You're right, maybe I need a statement like this : if rs.recordcount=true
then... (But I don't know what to say after that...)
thank you

Dirk said:
[quoted text clipped - 5 lines]
if
the recorset is empty so that it can be filled by the user.

A form normally has no objection to being opened with an empty recordset --
it just goes to a blank "new" record. That's assuming the recordsource and
form properties permit a nerw record to be added; otherwise the form is
just blank. If you're getting an error, I suspect there's something
non-standard about your form.

Is this a bound form?

Do you have code in one of the form events that tries to navigate within the
form's recordset?
 
D

Dirk Goldgar

chewbacca via AccessMonster.com said:
I get the following typical error every time i try to open the popup page
that contains the form:

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

I have another form on the site that works perfectly and is very similar
except for a dropdown select with a do while statement in it.

You're right, maybe I need a statement like this : if rs.recordcount=true
then... (But I don't know what to say after that...)


I'm not sure what you mean by "the popup page that contains the form". Is
this something different from just opening the form? Are you talking about
a main form/subform arrangement, or what?

Anyway, I think you must be running some code that is trying to go to the
last record on the form, or something like that. Please post:

(a) the code where you open the form, and any lines of code immediately
thereafter, and

(b) any code in the Open, Load, or Current events from the form being
opened, and

(c) (if there's a subform involved) any code Open, Load, or Current events
from the subform.
 
C

chewbacca via AccessMonster.com

Dirk said:
I get the following typical error every time i try to open the popup page
that contains the form:
[quoted text clipped - 8 lines]
You're right, maybe I need a statement like this : if rs.recordcount=true
then... (But I don't know what to say after that...)

I'm not sure what you mean by "the popup page that contains the form". Is
this something different from just opening the form? Are you talking about
a main form/subform arrangement, or what?

Anyway, I think you must be running some code that is trying to go to the
last record on the form, or something like that. Please post:

(a) the code where you open the form, and any lines of code immediately
thereafter, and

(b) any code in the Open, Load, or Current events from the form being
opened, and

(c) (if there's a subform involved) any code Open, Load, or Current events
from the subform.

Ok Dirk thanks

The thing is, the form is part of an order website.
the user pushes a button that opens a popup window with the form in it to
enter a construction site adress.
So i made a form page and also a form modification page for the updating
The web site is french so bare with me:

to open the form
<input type="button" onClick="window.open('chantier.asp')" value="Adresse du
Chantier" name="bouton_chantier" />

the form page:
Set adocon = Server.CreateObject("ADODB.Connection")
adocon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath
("sdo2.mdb")
Set rstChantier = Server.CreateObject("ADODB.Recordset")

theSQL = "SELECT soumission.id_soumission, soumission.id_chantier, chantier.
id_chantier, chantier.nom_chantier, chantier.adresse, chantier.ville,
chantier.province, chantier.code_postal, chantier.telephone FROM soumission
INNER JOIN chantier ON soumission.id_chantier = chantier.id_chantier WHERE
id_soumission=" & var_id_soumission

rstChantier.Open theSQL, adoCon
.............
one third of the form:

<form action="chantier_modif.asp" method="post" name="chantier"
id="chantier">
<div align="center">

<div align="center">
<table width="62" border="0" cellpadding="1">
<tr>
<td width="56" height="30"><div align="center"><input type="text"
value="<%=var_no_soumission%>" maxlength="20" name="txt_no_soumission"
size="20" /></div></td>
</tr>
</table>
<table width="600" border="1" cellpadding="1">
<tr>
<td height="30" bordercolor="1"><div align="center"><strong>Adresse
du chantier</strong></div></td>
</tr>
</table>
<table width="600" border="1" cellpadding="1">
<tr>
<td width="225" height="30" bordercolor="1"><div
align="center"><strong>Nom du Chantier </strong></div></td>
<td bordercolor="1"><div align="center">
<input name="txt_nom_chantier" type="text" value="<% =
rstChantier.fields("nom_chantier") %>" size="45" maxlength="100" />
.............

and the closing statement:

<%

rstChantier.Close
Set rstChantier = Nothing
Set adoCon = Nothing
%>


Thank you so much for taking the time
 
D

Dirk Goldgar

chewbacca via AccessMonster.com said:
The thing is, the form is part of an order website.
the user pushes a button that opens a popup window with the form in it to
enter a construction site adress.
So i made a form page and also a form modification page for the updating
The web site is french so bare with me:

to open the form
<input type="button" onClick="window.open('chantier.asp')" value="Adresse
du
Chantier" name="bouton_chantier" />

the form page:
Set adocon = Server.CreateObject("ADODB.Connection")
adocon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &
Server.MapPath
("sdo2.mdb")
Set rstChantier = Server.CreateObject("ADODB.Recordset")

theSQL = "SELECT soumission.id_soumission, soumission.id_chantier,
chantier.
id_chantier, chantier.nom_chantier, chantier.adresse, chantier.ville,
chantier.province, chantier.code_postal, chantier.telephone FROM
soumission
INNER JOIN chantier ON soumission.id_chantier = chantier.id_chantier WHERE
id_soumission=" & var_id_soumission

rstChantier.Open theSQL, adoCon
............
one third of the form:

<form action="chantier_modif.asp" method="post" name="chantier"
id="chantier">
<div align="center">

<div align="center">
<table width="62" border="0" cellpadding="1">
<tr>
<td width="56" height="30"><div align="center"><input type="text"
value="<%=var_no_soumission%>" maxlength="20" name="txt_no_soumission"
size="20" /></div></td>
</tr>
</table>
<table width="600" border="1" cellpadding="1">
<tr>
<td height="30" bordercolor="1"><div align="center"><strong>Adresse
du chantier</strong></div></td>
</tr>
</table>
<table width="600" border="1" cellpadding="1">
<tr>
<td width="225" height="30" bordercolor="1"><div
align="center"><strong>Nom du Chantier </strong></div></td>
<td bordercolor="1"><div align="center">
<input name="txt_nom_chantier" type="text" value="<% =
rstChantier.fields("nom_chantier") %>" size="45" maxlength="100" />
............

and the closing statement:

<%

rstChantier.Close
Set rstChantier = Nothing
Set adoCon = Nothing
%>

Aha! Now I see: Access and its forms aren't actually involved here; in
fact, though you're using a Jet database which may have been created by
Access, this isn't really an Access question at all. This is an ASP
question.

But that doesn't mean I can't tell you what's going on and, roughly, how to
fix it. You're getting an error because, in building your HTML form, you're
referring to fields of the recordset to get the initial text for fields.
But if the recordset is empty, there's no current record. So you get the
ADO error message you reported.

I'm not much of an ASP coder myself, but you're going to have to put in some
conditional logic to avoid referring to fields of a record that doesn't
exist. Maybe something along the lines of this:

<input name="txt_nom_chantier" type="text" value="
<%
If rstChantier.EOF = False Then
Response.Write rstChantier.fields("nom_chantier")
End If
%>
" size="45" maxlength="100" />

Or you could make it more efficent by loading up a set of variables at the
top of your logic, conditional upon whether the recordset is empty, and then
use those variables in building your form. Along these lines:


<%

' ...

Dim vNomChantier, vAddresse, vVille

rstChantier.Open theSQL, adoCon
With rstChantier
If .EOF Then
vNomChantier = ""
vAddresse = ""
vVille = ""
Else
vNomChantier = .Fields("nom_chantier")
vAddresse = .Fields("adresse")
vVille = .Fields("ville")
End If
.Close
End With
%>
<form action="chantier_modif.asp" method="post" name="chantier"
id="chantier">
<div align="center">

<div align="center">
<table width="62" border="0" cellpadding="1">
<tr>
<td width="56" height="30"><div align="center">
<input type="text" value="<%=var_no_soumission%>
" maxlength="20" name="txt_no_soumission"
size="20" /></div>
</td>
</tr>
</table>
<table width="600" border="1" cellpadding="1">
<tr>
<td height="30" bordercolor="1"><div align="center">
<strong>Adresse du chantier</strong></div>
</td>
</tr>
</table>
<table width="600" border="1" cellpadding="1">
<tr>
<td width="225" height="30" bordercolor="1">
<div align="center"><strong>Nom du Chantier </strong></div>
</td>
<td bordercolor="1"><div align="center">
<input name="txt_nom_chantier" type="text" value="
<%=vNomChantier%>" size="45" maxlength="100" />

and so on for the other fields.
 
C

chewbacca via AccessMonster.com

Dirk said:
The thing is, the form is part of an order website.
the user pushes a button that opens a popup window with the form in it to
[quoted text clipped - 61 lines]
Set adoCon = Nothing
%>

Aha! Now I see: Access and its forms aren't actually involved here; in
fact, though you're using a Jet database which may have been created by
Access, this isn't really an Access question at all. This is an ASP
question.

But that doesn't mean I can't tell you what's going on and, roughly, how to
fix it. You're getting an error because, in building your HTML form, you're
referring to fields of the recordset to get the initial text for fields.
But if the recordset is empty, there's no current record. So you get the
ADO error message you reported.

I'm not much of an ASP coder myself, but you're going to have to put in some
conditional logic to avoid referring to fields of a record that doesn't
exist. Maybe something along the lines of this:

<input name="txt_nom_chantier" type="text" value="
<%
If rstChantier.EOF = False Then
Response.Write rstChantier.fields("nom_chantier")
End If
%>
" size="45" maxlength="100" />

Or you could make it more efficent by loading up a set of variables at the
top of your logic, conditional upon whether the recordset is empty, and then
use those variables in building your form. Along these lines:

<%

' ...

Dim vNomChantier, vAddresse, vVille

rstChantier.Open theSQL, adoCon
With rstChantier
If .EOF Then
vNomChantier = ""
vAddresse = ""
vVille = ""
Else
vNomChantier = .Fields("nom_chantier")
vAddresse = .Fields("adresse")
vVille = .Fields("ville")
End If
.Close
End With
%>
<form action="chantier_modif.asp" method="post" name="chantier"
id="chantier">
<div align="center">

<div align="center">
<table width="62" border="0" cellpadding="1">
<tr>
<td width="56" height="30"><div align="center">
<input type="text" value="<%=var_no_soumission%>
" maxlength="20" name="txt_no_soumission"
size="20" /></div>
</td>
</tr>
</table>
<table width="600" border="1" cellpadding="1">
<tr>
<td height="30" bordercolor="1"><div align="center">
<strong>Adresse du chantier</strong></div>
</td>
</tr>
</table>
<table width="600" border="1" cellpadding="1">
<tr>
<td width="225" height="30" bordercolor="1">
<div align="center"><strong>Nom du Chantier </strong></div>
</td>
<td bordercolor="1"><div align="center">
<input name="txt_nom_chantier" type="text" value="
<%=vNomChantier%>" size="45" maxlength="100" />

and so on for the other fields.

Thank you so much Dirk.

That second option of yours is what I had in mind but just couldn't put it
into words.

I will try that.
Thank you again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top