Update Response documents

I thought that by checking the Formulas inherit values in a response form's properties, the fields will be updated when I make a change in the main document.
But they don't!
How can I force a field in a response doc to copy the value from the field in the main doc every time?

Thanks for your help

Who is Participating?
PaebdbConnect With a Mentor Commented:
The "Inherit values" option is executed OnCreate, which means that those values are inherited to a field when the document is composed.
If you change something, the changes are not inherited to the child documents.
What you can do is open the child documents, edit and save them, but probably thats not what you want.

The other way to do this is putting some script in the Queryclose event of the parent document.
Sub Queryclose(Source As Notesuidocument, Continue As Variant)
     Dim session As New NotesSession    
     Dim db As NotesDatabase    
     Dim collection As NotesDocumentCollection    
     Dim doc As NotesDocument
     Dim runDoc As NotesDocument    
     Dim tempName As NotesItem
     Dim newName As String
     Set db = session.CurrentDatabase
     Set doc = Source.Document
     Set collection = doc.Responses
     Set runDoc = collection.GetFirstDocument
     Set tempName = doc.GetFirstItem("Name")
     newName = tempName.Values(0)
     ' change name in direct childs
     While Not (runDoc Is Nothing)
          Call runDoc.ReplaceItemValue("Parent",newname)          
          Call runDoc.ReplaceItemValue("TempParent",newname)                    
          Call runDoc.Save(True,False)
          Set runDoc = collection.GetNextDocument(runDoc)
End Sub
iamariAuthor Commented:
Thanks, Paebdb

I've tried it after replacing
Set tempName = doc.GetFirstItem("Name")
with my field name, like
Set tempName = doc.GetFirstItem("Subject")

But it's not working and it doesn't give any error message either.

Anything else I should do?

iamariAuthor Commented:
I've got it. It worked after I've changed to
    While Not (runDoc Is Nothing)
          Call runDoc.ReplaceItemValue("Subject",newname)          
          Call runDoc.ReplaceItemValue("TempSubject",newname)      

Thanks a lot!

Did you also substitude the field names "Parent" and "TempParent" with the field names from your child document ?

Call runDoc.ReplaceItemValue("xxxxx",newname)          

Originally my code was not intended to be pasted and run, just to give the idea how it would be done.
Do you have a field "TempSubject" in your child document ? Otherwise you don't need this line.
And you also don't need

 Dim session As New NotesSession    
 Dim db As NotesDatabase      


 Set db = session.CurrentDatabase

I just forgot to delete it, sorry.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.