Click to See Complete Forum and Search --> : If state returning exception error 0x80020009


Rashar
08-26-2004, 09:34 AM
Good morning,

My Goal: error check for duplicate Sales_ID's.

Not sure what's wrong with the If statement as it seems logical enough to me...but when the code is executed, I get exception error 0x80020009 on the line at the If statement.

Any suggestions?

Thank you.


**************************************************
<%
dim submitCon, newSales_ID
Set submitCon = ' my connection string
set rsSubmit = server.CreateObject("ADODB.Recordset")
rsSubmit.ActiveConnection = submitCon

dim sqlSubmit, Sales_ID

sqlSubmit = "SELECT * FROM TBLRMS"
%>
<%
rsSubmit.CursorType = 2
rsSubmit.CursorLocation = 3
rsSubmit.LockType = 3
rsSubmit.Open sqlSubmit
%>
<%
do while not rsSubmit.EoF
Response.Write rsSubmit("Sales_ID") '*** I inserted this statement to see the value of Sales_ID ***

rsSubmit.MoveNext
Loop
%>
<%
If rsSubmit("Sales_ID") = Request.Form("Sales_ID") Then
Response.Write "Salesman already created! Please try again."
%>
<%
Else
%>

<%
rsSubmit.AddNew
rsSubmit.Fields("Sales_ID") = Request.Form("Sales_ID")
rsSubmit.Fields("Sales_fName") = Request.Form("Sales_fName")
rsSubmit.Fields("Sales_lName") = Request.Form("Sales_lName")
rsSubmit.Fields("Location") = Request.Form("Location")
rsSubmit.Fields("officeNum") = Request.Form("officeNum")
rsSubmit.Fields("homeNum") = Request.Form("homeNum")
rsSubmit.Fields("homeNum") = Request.Form("homeNum")
rsSubmit.Fields("Location") = Request.Form("Location")
rsSubmit.Fields("cellNum") = Request.Form("cellNum")
rsSubmit.Fields("otherNum") = Request.Form("otherNum")
rsSubmit.Fields("date_Created") = Request.Form("date_Created")
rsSubmit.Update
%>
<%
End If
%>
<%
rsSubmit.Close
submitCon.Close
%>
**************************************************

CardboardHammer
08-26-2004, 12:31 PM
You're looping all the way through the recordset before you get to the "If", at which point, you're trying to read past the end of the recordset. If the "If" is supposed to be inside the loop, move both "rsSubmit.MoveNext " and "Loop" past "End If".