Suming data within a nested repeat region

Discussion in 'ASP General' started by Mangler, Feb 4, 2009.

  1. Mangler

    Mangler Guest

    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.
     
    Mangler, Feb 4, 2009
    #1
    1. Advertising

  2. Gazing into my crystal ball I observed Mangler
    <> writing in news:ea812e19-a86f-4229-abfe-
    :

    > 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 :


    <snip bloated markup>
    >
    > 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

    --
    Adrienne Boswell at Home
    Arbpen Web Site Design Services
    http://www.cavalcade-of-coding.info
    Please respond to the group so others can share
     
    Adrienne Boswell, Feb 5, 2009
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. SAL

    #Region #End Region issue

    SAL, Aug 29, 2008, in forum: ASP .Net
    Replies:
    1
    Views:
    364
    Alexey Smirnov
    Aug 29, 2008
  2. shank

    nested repeat region

    shank, Dec 10, 2005, in forum: ASP General
    Replies:
    1
    Views:
    121
    shank
    Dec 10, 2005
  3. Simon Gare

    Force new page in printed repeat region

    Simon Gare, Jun 15, 2006, in forum: ASP General
    Replies:
    0
    Views:
    110
    Simon Gare
    Jun 15, 2006
  4. Simon Gare

    Calculate total in repeat region

    Simon Gare, Jun 17, 2006, in forum: ASP General
    Replies:
    0
    Views:
    146
    Simon Gare
    Jun 17, 2006
  5. gp
    Replies:
    0
    Views:
    114
Loading...

Share This Page