Suming data within a nested repeat region

M

Mangler

I will try my best to explain this....

I have 2 recordsets, one pulls the main info and the other pulls
detailed info for the specific record and it get repeated. So:

Record1 :
(Master recordset result)
Repair price : $20 Labor : $5
(Detail recordet result)
part 1 : $2
part 2 : $2

Record2 :
(Master recordset result)
Repair price : $25 Labor : $10
(Detail recordet result)
part 1 : $2
part 2 : $2
part 3 : $5


I cannot figure out how to get the sum for each individual record. I
figured out how it can be done with a single repeat region but not
with a nested one adding information with another region. The results
I am looking for are as follows :



Record1 :
(Master recordset result)
Repair price : $20 Labor : $5
(Detail recordet result)
part 1 : $2
part 2 : $2
Record1 Total :$29

Record2 :
(Master recordset result)
Repair price : $25 Labor : $10
(Detail recordet result)
part 1 : $2
part 2 : $2
part 3 : $5
Record2 Total :$44



Here is the code for the main repeat region with the nested one
inside :

<%
While ((Repeat_master1workOrder__numRows <> 0) AND (NOT
master1workOrder.EOF))
%>
<table width="100%" border="1" cellspacing="0"
cellpadding="0">
<tr>
<td><table width="100%" border="0">
<tr>
<td colspan="2"><span class="style4"><%=
(master1workOrder.Fields.Item("phoneModel").Value) & " ( " &
(master1workOrder.Fields.Item("phoneESN_IMEI").Value) & " )" & " ::
WO# " & (master1workOrder.Fields.Item("workOrderNumber").Value)%></
span> <em>
<% If (master1workOrder.Fields.Item
("outboundTrackingNumber").Value) <> "" Then %>
<span class="style3">Tracking : <%=
(master1workOrder.Fields.Item("outboundTrackingNumber").Value)%></
span>
<%End If%>
</em>
<table width="100%" border="0"
cellspacing="0" cellpadding="0">
<tr>
<td> <span class="style3"><em>Repair : <
%= FormatCurrency((master1workOrder.Fields.Item("salePrice").Value),
-1, -2, -2, -2) %> Labor : <%= FormatCurrency
((master1workOrder.Fields.Item("manHourCost").Value), -1, -2, -2, -2)
%> Shipping : <%= FormatCurrency((master1workOrder.Fields.Item
("shippingCost").Value), -1, -2, -2, -2) %></em></span></td>
<td><div align="right" class="style3"><%=
FormatCurrency((master1workOrder.Fields.Item("salePrice").Value) +
(master1workOrder.Fields.Item("manHourCost").Value) +
(master1workOrder.Fields.Item("shippingCost").Value), -1, -2, -2, -2)
%></div></td>
</tr>
</table></td>
</tr>
<%
nst_sw = false
detail2workOrderParts_cmd.Parameters("param1").Value = CInt("0" +
master1workOrder.Fields.Item("workOrderNumber").Value)
Set detail2workOrderParts = detail2workOrderParts_cmd.Execute
While (NOT detail2workOrderParts.EOF)
'Nested repeat
%>
<tr>
<td><div align="left">&nbsp;<span
class="style3">&nbsp;&nbsp;&nbsp;<%=(detail2workOrderParts.Fields.Item
("filledSKU").Value)%> ( <%=(detail2workOrderParts.Fields.Item
("partDescription").Value)%> )</span></div>
<div align="left"></div></td>
<td width="33%"><div align="right"
class="style3"><%= FormatCurrency((detail2workOrderParts.Fields.Item
("salePrice").Value), -1, -2, -2, -2) %></div></td>
</tr> <%
' Nested move next
detail2workOrderParts.MoveNext()
Wend
%>
<tr>
<td>&nbsp;</td>
<td>Total :</td>
</tr>

</table></td>
</tr>
</table>
<%
Repeat_master1workOrder__index=Repeat_master1workOrder__index+1
Repeat_master1workOrder__numRows=Repeat_master1workOrder__numRows-1
master1workOrder.MoveNext()
Wend
%>


I can post the recordsets too if needed, just left them out at first
to not take up too much space in this post.
 
A

Adrienne Boswell

Gazing into my crystal ball I observed Mangler
I will try my best to explain this....

I have 2 recordsets, one pulls the main info and the other pulls
detailed info for the specific record and it get repeated. So:

Record1 :
(Master recordset result)
Repair price : $20 Labor : $5
(Detail recordet result)
part 1 : $2
part 2 : $2

Record2 :
(Master recordset result)
Repair price : $25 Labor : $10
(Detail recordet result)
part 1 : $2
part 2 : $2
part 3 : $5


I cannot figure out how to get the sum for each individual record. I
figured out how it can be done with a single repeat region but not
with a nested one adding information with another region. The results
I am looking for are as follows :



Record1 :
(Master recordset result)
Repair price : $20 Labor : $5
(Detail recordet result)
part 1 : $2
part 2 : $2
Record1 Total :$29

Record2 :
(Master recordset result)
Repair price : $25 Labor : $10
(Detail recordet result)
part 1 : $2
part 2 : $2
part 3 : $5
Record2 Total :$44



Here is the code for the main repeat region with the nested one
inside :

I can post the recordsets too if needed, just left them out at first
to not take up too much space in this post.

'run query and open up recordset rs
rsarr = rs.getrows()
rs.close
set rs = nothing
for a = 0 to ubound(rsarr,2)
regular = rsarr(0,a) 'assuming regular is 1st field in query
labor = rsarr(1,a) 'assuming labor is 2nd field in query
'do second query for parts and open up recordset rs2
rsarr2 = rs2.getrows()
rs2.close
set rs2 = nothing
for b = 0 to ubound(rsarr2,2)
part = rsarr2(0,b) 'assuming part is 1st field in query
parttotal = parttotal + part
next
total = regular + labor + parttotal
response.write "total: " & total
next
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top