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

Adding repeating regions

Status
Not open for further replies.

sinistapenguin

Technical User
Jan 21, 2004
31
GB
Hi

Does anyone know how to add together fields in repeating regions.

I have a number of repeating regions on a page and I want to display a total at the end.

Any tips gratefully received

Cheers

Sinista
 
just add this before the repeat region in code view

Code:
<%
myTotal = 0
%>

And after the start of the region, which is something like:-

    <% 
While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF)) 
%>

add

<%
myTotal = myTotal + Recordset1.Fields.Item(&quot;theFieldYouWishtoADD&quot;).Value
%>

Now when you want to display the total just put

<%=myTotal%>

Or you can do this with your select statement using &quot;Sum&quot; as in

SELECT SUM (salary) as &quot;Total Salary&quot;
FROM employees
WHERE fldName = 'A%'

Cheech

[Peace][Pipe]
 
have your DB do the SUM vs. ASP.
WHY?
- IMHO ones SQL is executed (summed up) all u will be doing is navigating those records vs. &quot;summing up&quot; records (per page set) as u navigate.
Anyhow....nice & quick Cheeh!


> need more info?
:: don't click HERE ::
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top