Solved

I need to assign a value to a field in a document in lotusscrip dynamically

Posted on 2011-09-15
3
326 Views
Last Modified: 2013-12-18
I have 100 fields in a form ., when i create a document . i need to assign values to those fields
but i dont want to write all 100 fields manually  because their name are like

field1
field2
field3
field4
.
.
.                       that goes like that

so i put a for loop in the for loop preceding the string "field"  appended by counter value of the for loop i get the name of the field and then try to assign value to it but i get the error

use of illegal property  below is my code. how can i achieve this?

      For x=0 To datacount  
            
                  doc.KHedef&Cstr(x+1)="value1"                                                             doc.Ilgilihoshin&Cstr(x+1)="value2"
                  doc.HedefBitis&Cstr(x+1)="value3"
                  doc.BasariOlcum&Cstr(x+1)="value4"
                   doc.Agirlik&Cstr(x+1)="value5"

                  
                        

      Next      
0
Comment
Question by:fatihdi
3 Comments
 

Author Comment

by:fatihdi
ID: 36544272
error screenshot
0
 
LVL 10

Accepted Solution

by:
doninja earned 300 total points
ID: 36544336
try using doc.replaceitemvalue(itemname$,value)

you can specify the field name as a string

i.e.
in declarations
dim item as notesitem

in code
set item=doc.replaceitemvalue("KHedef"  & Cstr(x+1), "value1")

repeat for each variable you have to define.
0
 
LVL 46

Assisted Solution

by:Sjef Bosman
Sjef Bosman earned 200 total points
ID: 36546578
Or, shorter

Call doc.replaceitemvalue("KHedef" & (x+1), "value1")

If would even make sense to store the strings in an array, and loop through that one too, like this:

Dim fields As Variant
fields= Split("KHedef;HedefBitis;others", ";") ' to create an array
For x=1 To datacount  +1                             ' why fro 0 to datacount?
      Forall fld In fields
            Call doc.replaceitemvalue(fld & x, "value1")
      End Forall
Next

Of course, the values can be put in an array as well...
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now