Tip

Want To Know How Much Childrens Your Document Have?

This code is pretty helpfull to know how much childrens does your principal
document have.

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

With Source.Document
Set Coll = .Responses
'verify if the fields are empty
If .NumOfChild1 (0) <> "" Then Tot# = .NumOfChild1 (0)
If .NumOfChild2 (0) <> "" Then Tot# = Tot# + .NumOfChild2 (0)
End With

'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
Else
Child2% = Child2% + 1
End If
Set Doc = Coll.GetNextDocument (Doc)
Loop

With Source.Document
.NumOfChild1 = Child1%
.NumOfChild2 = Child2%
End With

Call Source.Refresh
End Sub

This was first published in November 2000

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

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:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.