By submitting your email address, you agree to receive emails regarding relevant topic offers from TechTarget and its partners. You can withdraw your consent at any time. Contact TechTarget at 275 Grove Street, Newton, MA.
First, create as much fields in your principal form as you got different
children's form. In my example, I've got one principal form named "Principal"
and two children's form named "Child1" and "Child2". So, I've create two
calculated fields name "NumOfChild1" and "NumOfChild2".
Next step. In your principal form you will have to copy the code in the
"Postmodechange" event. With this event you will be sure that unauthorised
peoples won't upgrade your principal documents. Each time a user will modify
his principal document, the code will verify, compare and upgrade the number of
childrens in the document.
Sub Postmodechange(Source As Notesuidocument)
Dim Session As New NotesSession
Dim Doc As NotesDocument
Dim Coll As NotesDocumentCollection
Set Coll = .Responses
'verify if the fields are empty
If .NumOfChild1 (0) <> "" Then Tot# = .NumOfChild1 (0)
If .NumOfChild2 (0) <> "" Then Tot# = Tot# + .NumOfChild2 (0)
'if the count is the same, it's not necessary to upgrade it
If Tot# = Coll.Count Then Exit Sub
Set Doc = Coll.GetFirstDocument
Do While Not (Doc Is Nothing)
If Doc.Form (0) = "Child1" Then
Child1% = Child1% + 1
Child2% = Child2% + 1
Set Doc = Coll.GetNextDocument (Doc)
.NumOfChild1 = Child1%
.NumOfChild2 = Child2%