ReportTotals Function

I need some advice re: creating a BuildReportTotalsRow function to complement an existing agent. The agent accesses about 20 databases and fetches totals then builds a report document & displays to requesting user. The function below is the 2nd function… the 1st creates the 1st row of header labels. It accesses a profile document with an empty table (e.g. 5 columns + 1 row) to build the table. In the end, there is the 1st row with labels and the next 20 rows contain the #s. I just want to create a final row that totals each # column. Any ideas? It seems like the following function could be used as a base (just replace the inserts with total?). Thanks in advance.

Function BuildReportOutputRow(sdb As NotesDatabase, orderTotal As String, seenTotal As String, nocallsTotal As String, uname As String, rptDoc As NotesDocument, r As NotesRichTextItem, redbook As String) As Boolean

'Display the search criteria at the top of the report



'Get a handle to the table and populate the row columns.  Add a new row at the end

Dim rtnav As NotesRichTextNavigator

Dim rtt As NotesRichTextTable

Dim icol As Integer

Dim numrows As Integer

Dim rtrange As NotesRichTextRange

Dim elemtype As Integer



Set rtnav = r.CreateNavigator

If Not rtnav.FindFirstElement(RTELEM_TYPE_TABLE) Then

	Messagebox "Could not find table",, "Fatal error"

	Exit Function

End If



Set rtt = rtnav.GetElement



numrows = rtt.RowCount

elemtype = RTELEM_TYPE_TABLECELL



Set rtrange = r.CreateRange



rtnav.FindLastElement(elemtype)

Call rtt.AddRow

'This should put the insertion point in the first cell of the new row	

Call rtnav.FindNextElement(elemtype)



r.BeginInsert rtnav

Call r.AppendDocLink( sdb, sdb.Title, sdb.Title )

r.EndInsert

rtnav.FindNextElement(elemtype)

r.BeginInsert rtnav

Call r.AppendText(uname)

r.EndInsert

rtnav.FindNextElement(elemtype)

r.BeginInsert rtnav

Call r.AppendText(Format$(orderTotal, "Currency"))

r.EndInsert

rtnav.FindNextElement(elemtype)

r.BeginInsert rtnav

Call r.AppendText(seenTotal)

r.EndInsert

rtnav.FindNextElement(elemtype)

r.BeginInsert rtnav

Call r.AppendText(nocallsTotal)

r.EndInsert

End Function

Subject: ReportTotals Function

Somewhere, you must be grabbing the raw data you use in each cell in each row. For those data that you wish to total up at the bottom, you’ll need to create some kind of temp var that holds the sum. Add the latest value to the current sum, repeat. When done, you have your total, stuff it into the bottom row.

Subject: RE: ReportTotals Function

Thanks Doug… figured I needed to add value 1 to a temp variable then value 2, etc. I guess this could be done just before building the row. After the row is built, it starts on the next database. Do you have any snippets? Something like this?

dim tmpordertotal as variable

…continue dims for remaining total fields

set tmpordertotal= would assume tmpordertotal+current value so it builds the value, correct.

…then I would use tmpordertotal (+ others) to build each cell in the report totals row.

Am I remotely close in my thinking? Thanks Doug…