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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

While condition not looping... 1

Status
Not open for further replies.

SWTpaul

Technical User
Nov 11, 2003
27
US
Some reason the WHILE condition will not loop while the 3 functions (highlighted) are there. If I comment out the functions like so (]<%'=sQtyPrior1(sItemNo)%>), the while loop will work.

When it is not commented it will display the information for the first record, then gives the following message.

I copied one of the functions below the main code, they are all similar with different SQL information.

Any ideas? Thanks!

----------[ ERROR MESSAGE ]--------
Microsoft VBScript runtime error '800a01a8'
Object required

/report_displayinventory_prt.asp, line 99

----------[ CODE ]--------
<%
sSQL = "SELECT imitno,imitd1,imitcl,imitsc FROM itmst WHERE imitcl='DS' AND imitsc<>'99'"
Set Rs = MyConn.Execute(sSQL)

While Not Rs.EOF
Counter = Counter + 1
sItemNo = Rs("imitno")
sItemDesc = Rs("imitd1")

If RowColor = "#FFFFFF" Then
RowColor = "#E5E5E5"
Else
RowColor = "#FFFFFF"
End If
%>
<tr>
<td align="right" bgcolor="<%=RowColor%>"><%=Counter%>.</td>
<td bgcolor="<%=RowColor%>"></td>
<td bgcolor="<%=RowColor%>"><%=sItemNo%></td>
<td bgcolor="<%=RowColor%>"></td>
<td bgcolor="<%=RowColor%>"><%=sItemDesc%></td>
<td bgcolor="<%=RowColor%>"></td>
<td align="right" bgcolor="<%=RowColor%>">[highlight]<%=sQtyPrior2(sItemNo)%>[/highlight]</td>
<td bgcolor="<%=RowColor%>"></td>
<td align="right" bgcolor="<%=RowColor%>">[highlight]<%=sQtyPrior1(sItemNo)%>[/highlight]</td>
<td bgcolor="<%=RowColor%>"></td>
<td align="right" bgcolor="<%=RowColor%>">[highlight]<%=sQtyYTD(sItemNo)%>[/highlight]</td>
</tr>
<%
[highlight]Rs.MoveNext[/highlight] <--- Line 99
Wend

Rs.Close
Set Rs = Nothing
%>


<%
Function sQtyYTD(sItemNo)
sSQL = "SELECT iaitno,iatrqt,iatrcd,iatrdt,imitno FROM iahst INNER JOIN itmst ON iahst.iaitno=itmst.imitno WHERE imitno='"&sItemNo&"' AND iawhid='CC' AND (iatrcd='Z' OR iatrcd='I') AND (iatrdt>'050101' AND iatrdt<'051231')"
Set Rs = MyConn.Execute(sSQL)

While Not Rs.EOF
sQtyYTD = sQtyYTD + cInt(Rs("iatrqt"))
Rs.MoveNext
Wend

Rs.Close
Set Rs = Nothing
End Function
%>
 
what i see here is you are calling a function...and in your function you are setting Rs.Close. Which means you are closing your recordset object...then how can you think that Rs.MoveNext will work??

-DNG
 
rs as a global object variable because it is not separately defined inside your function...so when you close it in the function, you close one being used by the loop.

Either declare it locally to the function with Dim rs or use a different variable name.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top