Building multiple item moves within a doc

I have 2 sets of fields in a document. ponum1 thru 10 and polink1 thru 10. It is my understanding when you want to move the values in 1 item to another , it goes like this doc.polink1 = doc.ponum1(0).

I am trying to build this into a …

For x 1 to 10

doc.polink & Trim(Str$(x)) = doc.ponum & Trim(Str$(x)) & “(0)”

Next

It seems it is the (0) it is balking at. It will not save the script.

I tried string and variants for the tempxxx items in the following attemps…

tempponum = prdoc.ponum & Trim$(Str$(index)) & (0)

temppo_link = “prdoc.po_link” &Trim$(Str$(index))

Set Item = prdoc.ReplaceItemValue(temppo_link, tempponum)

This seems simple enough but it also seems not. Help please…

Subject: building multiple item moves within a doc

The problem is that if you’re using the document.fieldname(index) shorthand syntax, you can’t dynamically build the fieldname as if it were a string. You’re almost there with your use of ReplaceItemValue, but for that you can’t use the (index) notation. You might try something like this:

For x = 1 to 10

’ first, just generate some field names

ponum = “ponum” + cstr(x)

polink = “polink” + cstr(x)

’ get the value(s) of the ponum field

num_vals = doc.GetItemValue(ponum)

’ and slap those into the link field

set itm = doc.replaceitemvalue(polink, num_vals)

’ save it; otherwise, we’ll reset what itm is on the next loop through and lose the previous item value changes

call doc.save(false, false)

Next

Subject: RE: building multiple item moves within a doc

worked well, thank you very much

Subject: building multiple item moves within a doc

What you need to do is the following:

for x = 1 to 10

call doc.replaceItemValue(“polink” & str(x), doc.getItemValue(“ponum” & str(x)))

next

Morten Steinhauer

Promasoft AS

Subject: RE: building multiple item moves within a doc

I added these 2 display lines and they show “” empty.For x = 1 To 10

tempponum = prdoc.GetItemValue(“ponum” & Str(x))

temppo_link = prdoc.GetItemValue(“po_link” & Str(x))

Call prdoc.ReplaceItemValue(“po_link” & Str(x), prdoc.GetItemValue(“ponum” & Str(x)))

Next

Subject: RE: building multiple item moves within a doc

Yes, I see. Was too quick with use of the str() function. Always safer to use cStr().

So:

For x = 1 To 10

Call doc.replaceItemValue(“polink” & Cstr(x), doc.getItemValue(“ponum” & Cstr(x)))

Next

…will work…

Kind regards

Morten Steinhauer

Promasoft AS