Solved

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

Posted on 2011-09-15
3
329 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
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…

895 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

15 Experts available now in Live!

Get 1:1 Help Now