I want to be able to read documents from a NotesDocumentCollection and for each document pick certain filed values and then write these filed values as one row in a table. When I get to the next document in the collection I want to read the same field values and write them to the same row on the table but with a new line as separator which simulates a dynamic table. My problem is that the initial filed values are being overwritten as a result only the field values from the last document in the collection show up. How do I get around this ?
Not knowing exactly what it is you are assigning makes it impossible to give a precise answer, but remember that the FieldSetText method will only work with an honest-to-goodness string. Just how are you building the replacement text? Just by way of example, here’s how I’d go about it:
dim dc as notesdocumentcollection
dim doc as notesdocument
dim uidoc as notesuidocument
dim tmpText as String
dim rowCounter as Integer
[insert instantiations here]
tmpText=“”
rowCounter=1
Set doc=dc.getFirstDocument
Do until doc is Nothing
tmpText=tmpText+doc.itemvalue(0)
if Not rowCounter=dc.Count Then tmpText=tmpText+chr(10)
I want to generate a statement for a client. So I compose a new document with the client profile selected. This picks up the name of the client and I use this as my key to pick all docs pertaining to employees of that company. I now have a document collection. Now on the document that I have composed I have a single row table and I want to list info from values coming from docs in the collection. If my doc collection has 3 doc, then I will have a loop reading values from the 3 docs and writing to my open document.
The answer’s simple: see Chuck’s code. In your loop, you’re just over-writing anything you’ve set in the “dJ” ui doc field with the next document’s value – you need to append, not replace!
Do Until doc Is Nothing
Call uidoc.FieldSetText("dJ", Cstr(doc.regDate(0)))
Set doc = coll.GetNextDocument(doc)
OK, you probably need to play with what delimiters are used for input in the field in question, not just how those multi-values are presented. For example, if multi-values are separated on input by a semi-colon, then you need to include that char when you set the field text in your code.
…but when I include a semi-colom(which is what I have designated on “Seperate values when user enters” on Field Properties and I have set it to display multi values with a new line separator all i get is value1;value2;value3.
If I remember rightly, Notes doesn’t actually dispay the multiple values on separate lines in Edit mode, only in Read mode. Is it displaying your values all on the same line in Read mode, once you have saved and reopened the document?