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]
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.