ReportTotals Function

***Re-posting this in the 8.5 forum… just upgraded the server last night. Thanks in advance team.

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