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

Loop through records

Status
Not open for further replies.

danieljoo

MIS
Oct 9, 2002
43
0
0
US
I need help to loop through a set of records that have been "checked" for printing.



<%
'Open Connection to the database
set conn = Server.CreateObject(&quot;ADODB.Connection&quot;)
conn.Open xDb_Conn_Str
dim arrPostedCheckValue, arrNameValuePairs, arrCustomerInfo, arrFirstNameInfo, arrLastNameInfo, strCustomerNumber, strFirstName, strLastName

arrPostedCheckValue=Request.Form(&quot;Print&quot;)
response.write arrPostedCheckValue
arrNameValuePairs=Split(arrPostedCheckValue,&quot;|&quot;)
arrCustomerInfo=Split(arrNameValuePairs(0),&quot;,&quot;)
arrFirstNameInfo=Split(arrNameValuePairs(1),&quot;,&quot;)
arrLastNameInfo=Split(arrNameValuePairs(2),&quot;,&quot;)

numCustomerNumber = arrCustomerInfo(1)
strFirstName = arrFirstNameInfo(1)
strLastName = arrLastNameInfo(1)

strsql = &quot;select * from Customer WHERE CUSTOMERNUMBER=&quot; & numCustomerNumber & &quot;&quot;

set rs = Server.CreateObject(&quot;ADODB.Recordset&quot;)
rs.Open strsql, conn, 1, 2
%>
<!--
<LINK href=&quot;stylesheet.css&quot; rel=STYLESHEET><!--<body link=&quot;#ffffff&quot; >-->
<body topmargin=&quot;15&quot; leftmargin=&quot;0&quot;>
<BR>
<BR>
<div align=&quot;left&quot;>
<table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;border-collapse: collapse&quot; bordercolor=&quot;#111111&quot; width=&quot;378&quot; height=&quot;198&quot;>
<tr>
<td width=&quot;378&quot; td height=&quot;62&quot; NOWRAP style=&quot;line-height: .90&quot;>
<CENTER>
<font face=&quot;Bernard MT Condensed&quot; style=&quot;font-size: 52pt&quot;>
<%
response.write ucase(strFirstName) 
%>
</font>
</CENTER>
</TD>
</tr>
<tr>
<td width=&quot;378&quot; td height=&quot;22&quot; NOWRAP style=&quot;line-height: .90&quot;>
<CENTER>
<font face=&quot;Bernard MT Condensed&quot; style=&quot;font-size: 18pt&quot;>
<%
response.write ucase(strFirstName)& &quot; &quot;
response.write ucase(strLastName)
%>
</font>
</CENTER>
</TD>
</tr>
<tr>
<td width=&quot;378&quot; td height=&quot;22&quot; NOWRAP style=&quot;line-height: .90&quot;>
<CENTER>
<font face=&quot;Bernard MT Condensed&quot; style=&quot;font-size: 18pt&quot;>

<%
x_CustomerName = rs(&quot;CustomerName&quot;)

response.write ucase(x_CustomerName)
%>
</font>
</CENTER>
</TD>
</tr>
<tr>
<td width=&quot;378&quot; td height=&quot;22&quot; NOWRAP style=&quot;line-height: .90&quot;>
<CENTER>
<font face=&quot;Bernard MT Condensed&quot; style=&quot;font-size: 18pt&quot;>
<%
x_CustomerCity = rs(&quot;CustomerCity&quot;)
x_CustomerState = rs(&quot;CustomerState&quot;)

response.write ucase(x_CustomerCity)& &quot;, &quot;
response.write ucase(x_CustomerState)
%>
</font>
</CENTER>
</TD>
</tr>

</table>
</div>
<SCRIPT TYPE=&quot;text/javascript&quot;>
var wndOpener = self.opener.parent
if (window.self) window.print();
timer = setTimeout(&quot;window.close()&quot;,1000);
wndOpener.location.reload(true);
</SCRIPT>


</BODY>
<html>
<%
' Close recordset and connection
rs.Close
Set rs = Nothing
conn.Close
Set conn = Nothing %>
 
can you be slightly more detailed then that. what do you want to loop through seeing as the code has no loop in it at this point. more to the point, at which stage of the ouput to the screen do you want the records extracted written per number of results in the rs for the best results to your questions: FAQ333-2924
Is your question a most FAQ?? Find out here FAQ333-3048
 
at this point from looking at the code is it all your looking for is after your initial table formatting

do while not rs.EOF

code you have now

rs.movenext
loop

before table close
for the best results to your questions: FAQ333-2924
Is your question a most FAQ?? Find out here FAQ333-3048
 
basically need to loop through what is in the <table>
 
that would be all you do then in my last reply. remember that the looping may effect the formatting of the table and you may need to adjust certain aspects of it such as headings etc.. for the best results to your questions: FAQ333-2924
Is your question a most FAQ?? Find out here FAQ333-3048
 
Several people have told me to just add the do while not rs.EOF, code and then rs.movenext loop, but its not working. No errors, shows the first record and does not loop. Notice the response.write arrPostedCheckValue in the code. Here is sample output with 2 records checked (note the first reocord is printed correctly below):


CustomerNumber,244521|AttendeeFirstName,BOB|AttendeeLastName,VIUGTEVEEN, CustomerNumber,244531|AttendeeFirstName,KEVIN|AttendeeLastName,SCNOOZER


BOB
BOB VIUGTEVEEN
SCHMUCK CO.
RAPID CITY, MI



Here is my code with the loop:


<%
'Open Connection to the database
set conn = Server.CreateObject(&quot;ADODB.Connection&quot;)
conn.Open xDb_Conn_Str
dim arrPostedCheckValue, arrNameValuePairs, arrCustomerInfo, arrFirstNameInfo, arrLastNameInfo, strCustomerNumber, strFirstName, strLastName

arrPostedCheckValue=Request.Form(&quot;Print&quot;)
response.write arrPostedCheckValue
arrNameValuePairs=Split(arrPostedCheckValue,&quot;|&quot;)
arrCustomerInfo=Split(arrNameValuePairs(0),&quot;,&quot;)
arrFirstNameInfo=Split(arrNameValuePairs(1),&quot;,&quot;)
arrLastNameInfo=Split(arrNameValuePairs(2),&quot;,&quot;)

numCustomerNumber = arrCustomerInfo(1)
strFirstName = arrFirstNameInfo(1)
strLastName = arrLastNameInfo(1)

strsql = &quot;select * from Customer WHERE CUSTOMERNUMBER=&quot; & numCustomerNumber & &quot;&quot;
'response.write strsql
set rs = Server.CreateObject(&quot;ADODB.Recordset&quot;)
rs.Open strsql, conn, 1, 2
%>
<!--
<LINK href=&quot;stylesheet.css&quot; rel=STYLESHEET><!--<body link=&quot;#ffffff&quot; >-->
<body topmargin=&quot;15&quot; leftmargin=&quot;0&quot;>
<BR>
<BR>
<div align=&quot;left&quot;>
<%do while not rs.eof%>
<table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;border-collapse: collapse&quot; bordercolor=&quot;#111111&quot; width=&quot;378&quot; height=&quot;198&quot;>
<tr>
<td width=&quot;378&quot; td height=&quot;62&quot; NOWRAP style=&quot;line-height: .90&quot;>
<CENTER>
<font face=&quot;Bernard MT Condensed&quot; style=&quot;font-size: 52pt&quot;>
<%
response.write ucase(strFirstName) 
%>
</font>
</CENTER>
</TD>
</tr>
<tr>
<td width=&quot;378&quot; td height=&quot;22&quot; NOWRAP style=&quot;line-height: .90&quot;>
<CENTER>
<font face=&quot;Bernard MT Condensed&quot; style=&quot;font-size: 18pt&quot;>
<%
response.write ucase(strFirstName)& &quot; &quot;
response.write ucase(strLastName)
%>
</font>
</CENTER>
</TD>
</tr>
<tr>
<td width=&quot;378&quot; td height=&quot;22&quot; NOWRAP style=&quot;line-height: .90&quot;>
<CENTER>
<font face=&quot;Bernard MT Condensed&quot; style=&quot;font-size: 18pt&quot;>

<%
x_CustomerName = rs(&quot;CustomerName&quot;)

response.write ucase(x_CustomerName)
%>
</font>
</CENTER>
</TD>
</tr>
<tr>
<td width=&quot;378&quot; td height=&quot;22&quot; NOWRAP style=&quot;line-height: .90&quot;>
<CENTER>
<font face=&quot;Bernard MT Condensed&quot; style=&quot;font-size: 18pt&quot;>
<%
x_CustomerCity = rs(&quot;CustomerCity&quot;)
x_CustomerState = rs(&quot;CustomerState&quot;)

response.write ucase(x_CustomerCity)& &quot;, &quot;
response.write ucase(x_CustomerState)
%>
</font>
</CENTER>
</TD>
</tr>

</table>
<%
rs.movenext
loop
%>
</div>



</BODY>
<html>
<%
' Close recordset and connection
rs.Close
Set rs = Nothing
conn.Close
Set conn = Nothing %>





 
are you certain you are not reaching the EOF after that record?
more to teh point is that the only return based on the query criteria of numCustomerNumber _________________________________________________________
for the best results to your questions: FAQ333-2924
Is your question a most FAQ?? Find out here FAQ333-3048
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top