Calculating Totals From Response Docs And Populate Field

THE PURPOSE OF THIS SCRIPT IS TO CALCULATE THE TOTAL OF THE A NUM BER/CURRENCY
FIELD FROM ALL THE RESPONSE DOCUMENTS AND POPULATE A FIELD IN THE PARENT
DOCUMENT WITH THAT TOTAL
Sub Queryclose(Source As Notesuidocument, Continue As Variant)

%REM
THE PURPOSE OF THIS SCRIPT IS TO CALCULATE THE TOTAL OF THE ACTUAL SAVINGS FROM
THE RES-
PONSE DOCUMENTS AND POPULATE THE ACTUAL SAVINGS FIELD IN THE PARENT DOCUMENT
%END REM

'DECLARING ALL THE VARABLES
Dim count As Integer
Dim workspace As New NotesUIWorkspace
Dim newamount As Variant
Dim currentdoc As NotesDocument
Dim dbase As NotesDatabase
Dim Session As New NotesSession
Dim responsedoc As NotesDocument
Dim parentdoc As notesDocument
Dim collection As NotesDocumentCollection
Dim parentdocitem As NotesItem

Dim item As NotesItem
Dim temp As Double
Dim ret As Variant
Dim view As NotesView

Dim ta As Double
Dim ts As Double
Dim trf As Double
Dim inst As Double
Dim mi As Double
Dim parentID As Variant

'SETTING THE VARIABLES
Set currentdoc = source.Document
Source.AutoReload = False
Set dbase = session.CurrentDatabase
Set responsedoc = source.Document

%REM
GETTING THE PARENT DOCUMENT'S UNIQUE ID FROM THE RESPONSE DOCUMENT AND THEN
OPENS
DOCUMENT. THE COLLECTION IS SET TO BE ALL THE RESPONSES OF THE PARENT DOCUMENT.
%END REM

parentID = responsedoc.ParentDocumentUNID
Set parentdoc = dbase.GetDocumentByUNID(ParentID)
Set collection = parentdoc.Responses

'LOOPING THROUGH ALL THE RESPONSE DOCUMENTS TO ADD THE ACTUAL SAVINGS.
WHEN DOING THIS
'IT CHECKS FOR WHETHER THE RESPONSE DOCUMENT IS A TAX ABATEMENT, TAX
SAVINGS,
'INFRASTRUCTURE, TRAINING FUNDS OR MISCELLANEOUS TYPES, SO THAT THE
CORRECT ACTUAL
'SAVINGS IN THAT PARTICULAR SECTION OF THE PARENT DOCUMENT IS POPULATED.

For count = 1 To collection.count
Set responsedoc = collection.GetNthDocument(count)
If responsedoc.TaType(0) = "Ta" Then
ta = ta + responsedoc.TaAmount(0)
End If

If responsedoc.TsType(0) = "Ts" Then
ts = ts + responsedoc.TsAmount(0)
End If

If responsedoc.TrfType(0) = "Trf" Then
trf = trf + responsedoc.TrfAmount(0)
End If

If responsedoc.InstrType(0) = "Instr" Then
inst = inst +responsedoc.InstrAmount(0)
End If

If responsedoc.MiType(0) = "Misc" Then
mi = mi + responsedoc.MiAmount(0)
End If
Next count

parentdoc.TotalAmount = ta + ts + trf + inst + mi
parentdoc.TaActAccSavings = ta
parentdoc.TsActAccSavings = ts
parentdoc.TrfActAccSavings = trf
parentdoc.InstrActAccSavings = inst
parentdoc.MiActAccSavings = mi

'SAVING THE PARENT DOCUMENT AFTER MAKING THE CHANGES.
ret = parentdoc.Save (True, False)

'REFRESHING THE VIEW TO SEE THE CHANGES MADE.
Set View = dbase.GetView("Status")
Call view.Refresh
Call workspace.viewRefresh

End Sub
This was first published in November 2000

Dig deeper on Lotus Notes Domino Administration Tools

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchWinIT

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchEnterpriseLinux

SearchVirtualDataCentre.co.UK

Close