Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

For Next loop error expected end of statement problem 1

Status
Not open for further replies.

Japskunk72

Programmer
Feb 19, 2003
64
US
I have an ASP page that will get 2 dates, a begining and an end date to grab info from a SQL database. the for next loop will not work, I do not know why it wont work. I am new to ASP. please help, here is my code followed my the error in IE 6.0

********************Code *********************************
<form method=&quot;get&quot; action=&quot;WSCardDateReport.asp&quot;><body>
First Date: <input type=&quot;text&quot; name=&quot;firstdate&quot;><br />
Last Date: <input type=&quot;text&quot; name=&quot;lastdate&quot;><br /><br />
<input type=&quot;submit&quot; value=&quot;Submit&quot;>

<%@LANGUAGE=&quot;VBSCRIPT&quot;%>
<%
firstdate=request.querystring(&quot;firstdate&quot;)
lastdate=request.querystring(&quot;lastdate&quot;)

Set adors = Server.CreateObject(&quot;ADODB.Recordset&quot;)
Set objConn = Server.CreateObject(&quot;ADODB.Connection&quot;)
dim firstdate,lastdate,sqlstate,datestamp,timestamp,receivedby,cname,address,street,zip
dim phone,section,remarks,complaint,complaintrelay,timerelay,relaytype
dim complaintLEN,realcomplaint,X1,complaintnum
objConn.Open=&quot;DSN=wwtpmain;uid=user;pwd=pass&quot;
SQLState=&quot;Select * from Emergencycardsystem where [date] between '&quot; & firstdate & &quot;' and '&quot; & lastdate & &quot;' order by date&quot;
set adors= objconn.execute(sqlstate)


Do while not adors.eof
DateStamp=adors(&quot;Date&quot;).value
TimeStamp=adors(&quot;time&quot;).value
Receivedby=adors(&quot;recievedby&quot;).value
cname=adors(&quot;cname&quot;).value
address=adors(&quot;caddress&quot;).value
street=adors(&quot;cstreet&quot;).value
zip=adors(&quot;czip&quot;).value
phone=adors(&quot;cphone&quot;).value
section=adors(&quot;csection&quot;).value
remarks=adors(&quot;remarks&quot;).value
complaint=adors(&quot;complaint&quot;).value
complaintrelay=adors(&quot;Complaint_relay&quot;).value
timerelay=adors(&quot;time_relay&quot;).value
relaytype=adors(&quot;relay_type&quot;).value


ComplaintLen= Len(complaint)
if complaintlen > 0 then
for x1 = 0 to complaintLEN
ComplaintNum = mid(complaint,x1)
Select Case ComplaintNum
Case 0
REalcomplaint = realcomplaint & &quot;Water in Basement - Weather Related &quot;
Case 1
realcomplaint = realcomplaint & &quot;Var &quot;
Case 2
realcomplaint = realcomplaint & &quot;Var &quot;
Case 3
realcomplaint = realcomplaint & &quot;Var &quot;
Case 4
realcomplaint = realcomplaint & &quot;Var &quot;
Case 5
realcomplaint = realcomplaint & &quot;Var &quot;
Case 6
realcomplaint = realcomplaint & &quot;Var &quot;
Case 7
realcomplaint = realcomplaint & &quot;Var &quot;
Case 8
realcomplaint = realcomplaint & &quot;Var &quot;
Case 9
realcomplaint = realcomplaint & &quot;Var &quot;
End Select
next x1
end if
%>

<div align=&quot;center&quot;>
<center>
<table border=&quot;2&quot; cellspacing=&quot;1&quot; height=&quot;1&quot; width=&quot;558&quot;>
<tr>
<td height=&quot;27&quot; width=&quot;99&quot;><b>Date:</b><% response.write(datestamp) %> </td>
<td height=&quot;27&quot; width=&quot;90&quot;><b>Time:</b><%response.write(timestamp)%> </td>
<td height=&quot;27&quot; width=&quot;256&quot;><b>Relayed By:</b><%Response.write(Receivedby)%> </td>
<td height=&quot;27&quot; width=&quot;320&quot;><b>Time Relayed:</b><%response.write(timerelay)%> </td>
</tr>
<tr>
<td height=&quot;1&quot; colspan=&quot;3&quot; width=&quot;272&quot; valign=&quot;top&quot;><b>Caller Name:</b><%response.write(cname)%>
</td>
<td height=&quot;1&quot; valign=&quot;middle&quot; width=&quot;350&quot;><b>Phone:<%response.write(phone)%>
</b>
  </td> </tr> <tr>
<td height=&quot;26&quot; colspan=&quot;4&quot; width=&quot;628&quot;><b>Address:</b> <%response.write(address & &quot; &quot;)%> <%response.write(street)%></td> </tr> <tr>
<td height=&quot;1&quot; colspan=&quot;3&quot; width=&quot;272&quot; valign=&quot;top&quot;><b>Forwarded to:</b> <%response.write(complaintrelay)%> </td>
<td height=&quot;1&quot; width=&quot;350&quot; valign=&quot;top&quot;><b>Section:</b> <%response.write(section)%></td></tr> <tr>
<td height=&quot;19&quot; colspan=&quot;4&quot; width=&quot;622&quot;><b>Problem:</b> <%response.write(realcomplaint)%></td> </tr> <tr>
<td height=&quot;19&quot; colspan=&quot;4&quot; width=&quot;622&quot;><b>Remarks:</b><%response.write(remarks)%></td> </tr> </table> </center></div> <br><br>

<%
adors.movenext
loop
%>


</body>
</form>


********************Error*********************************

Error Type:
Microsoft VBScript compilation (0x800A0401)
Expected end of statement
/WSCardDateReport.asp, line 64, column 5
next x1

Thanks,
JT
 
Instead of next x1 it should just read next. The x1 value is implied in the for loop itself.

-----------------------------------------------------------------------------------------------------
&quot;If you can't explain something to a six-year-old, you really don't understand it yourself.&quot;
-- Albert Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top