asp classic - ASP Do While loop totals and subtotals -
i don't claim classic asp guy, gotta gotta do. problem custom built report through asp , user wants running subtotals , grand total displayed well, , i'm not sure how go it. entire report wrapped this, way it's displayed doesn't matter issue.
<%do while (adorstrade.absolutepage = ipagecurrent) , (not adorstrade.eof) newrep = adorstrade("calincludedrep") if currep <> newrep or firsttime="t" , (not adorstrade.bof) %>
add values currep , display them 'subtotals'
<% firsttime="f" currep = adorstrade("calincludedrep") adorstrade.movenext loop %>
any appreciated mentioned not asp guru means. thank you, nickg
to update subtotal stuff; grand totals completed since can re-run while loop outside of loop displays of data , total it, easy-peezy (not really) run .movenext hit prior me being able check newrep; here totalling of sub-totals check if it's newrep means display sub-totals former rep
<%do while (adorstrade.absolutepage = ipagecurrent) , (not adorstrade.eof) newrep = adorstrade("calincludedrep") if currep = newrep curprincipal = adorstrade("mprincipal") totprincipal = totprincipal + curprincipal curinterest = adorstrade("minterest") totinterest = totinterest + curinterest curcommission = adorstrade("calcommission") totcommission = totcommission + curcommission cursecfee = adorstrade("msecfee") totsecfee = totsecfee + cursecfee cursvcfee = adorstrade("msvccharge") totsvcfee = totsvcfee + cursvcfee curnet = adorstrade("mnetamount") totnet = totnet + curnet end if if currep <> newrep or firsttime="t" , (not adorstrade.bof) if firsttime <> "t" then%> <tr> <td> <table class='fontstandardminus1' border=0 cellpadding=0 align='left' cellspacing=0 width="100%" bgcolor='#ffffff'> <tr> <td width="59%" align="left"><b>subtotals<!-- <%response.write(currep) %>-->:</b></td> <td width="10%" valign=top align=right><%=formatnumber(totprincipal,2)%></td> <td width="7%" valign=top align=right><%=formatnumber(totinterest,2)%></td> <td width="7%" valign=top align=right><%=formatnumber(totcommission,2)%></td> <td width="5%" valign=top align=right><%=formatnumber(totsecfee,2)%></td> <td width="4%" valign=top align=right><%=formatnumber(totsvcfee,2)%></td> <td width="9%" valign=top align=right><%=formatnumber(totnet,2)%></td> </tr> </table> </td> </tr> <%end if curprincipal = 0 totprincipal = 0 curinterest = 0 totinterest = 0 curcommission = 0 totcommission = 0 cursecfee = 0 totsecfee = 0 cursvcfee = 0 totsvcfee = 0 curnet = 0 totnet = 0 %> <tr> <td width="100%"> <table class='fontstandardminus1' border=0 cellpadding=0 align='left' cellspacing=0 width="100%" bgcolor='#ffffff'> <tr> <td width=100%><b><%=adorstrade("calincludedrep")%></b></td> </tr> </table> </td> </tr> <%end if%> <% firsttime="f" 'calcom = calcom + adorstrade("calcommission") currep = adorstrade("calincludedrep") adorstrade.movenext loop%>
so can see try reset values 0 after displaying them in table, table displayed after .movenext hit in hit, means though want display records 1-5 added up, record 6 hit .movenext , being discarded value set. sorry lengthiness of hate comments can't contain updated code. help
assuming output variables totprincipal, totinterest , totcommission after loop problem can think of datatype , rs.movefirst.
btw: try do in single loop performance reasons!
dim subtotprincipal: subtotprincipal = 0 dim totprincipal: totprincipal = 0 dim currep: currep = 0 dim newrep: newrep = 0 adorstrade.movefirst newrep = adorstrade("calincludedrep") ... subtotprincipal = subtotprincipal + clng(adorstrade("mprincipal")) totprincipal = totprincipal + clng(adorstrade("mprincipal")) ... if (currep <> newrep , not adorstrade.bof) or adorstrade.eof response.write subtotprincipal subtotprincipal = 0 end if currep = newrep adorstrade.movenext loop until adorstrade.eof response.write totprincipal
Comments
Post a Comment