Array problem?: "Could not create field: ProductPrice"

A user chooses some products from a catalog, then clicks a “Create order” button, and the ordered products are written to a new order document. All orders are required to have standard delivery costs as a product, so this is added to the user’s selection. Users get the “Could not create field: ProductPrice” error when the ProductPrice field is created with the code:

Set itOrderProductPrice = New NotesItem(docOrder,“ProductPrice”,Prices)

Prices is an array that contains prices of selected products. There were no problems with the code until I added the standard delivery costs as a product. I do that by defining the first member of the array as standard delivery costs:

Prices(0) = 1500

'Then I start a counter at 1:

iCount = 1

'Then I loop through all the selected products:

Redim Preserve Prices(iCount)

Prices(iCount) = docProduct.CTPrice(0)

iCount = iCount + 1

Why can’t I define the first member of the array directly, and then define the rest in a loop later?

Subject: Actually the problem lies in the fact that all numbers are stored in Notes as Doubles…

And the first item of your array is an integer. Try:Prices(0) = Ddbl(1500)

Subject: Array problem?: “Could not create field: ProductPrice”

Try this:

Dim Prices as variant

Redim Prices(0 to 100) as Integer

Prices(0) = 1500

Redim Preserve Prices(0 to iCount) 'iCount-1 ?

Prices(iCount) = …

Set itOrderProductPrice = New NotesItem(docOrder,“ProductPrice”,Prices)

Try also using:

Call docorder.replaceitemvalue(ProductPrice",Prices)