Array help

I’ve never worked with arrays before and I think they are the way to go for this problem. I have a 15Rx4C table on a PartList form. The 1st column contains checkbox fields, (“C_1”, “C_2”, etc.) and the next 3 columns are PartName_1, PartNum_1 and PartCost_1 then PartName_2, PartNum_2 and PartCost_2, etc. I would like for the user to select whichever parts they serviced and then click a button to compose a response doc that includes the name, number and cost of each part selected IN order. Meaning, I’ve gotten it to work (sort of) using script that queries every field individually. However, the code is 2 pages long. Furthermore, the selected parts are copied to the response doc in the same order as the PartList doc. In other words, if they select parts 1, 5 and 10, then on the response doc, Row 1 has part 1, then 3 blank rows then part 5 is in the 5th row, etc. I’m pretty sure I could eliminate 90% of the code by using arrays. I’ve been over and over the arrays’ section in the Help and I know I need to use a dynamic array. So far, I have:

Dim CurrDoc as NotesUIDocument

dim MachDoc as NotesDocument

Dim PartNames () As String

Dim ci As String

Set CurrDoc…

Set MachDoc = CurrDoc.document

For counter% = 1 To ??

ci = Cstr(counter%)

If CurrDoc.FieldGetText(“C_” + ci) <> “” Then

PartNames(counter%-1) = CurrDoc.Part_ + ci

End If

Next

Please don’t laugh; I’m sure this is not even close! But I’ve been reading about arrays for a couple of hours and I don’t feel I’m making any progress. I can’t even figure out how to get the upper bound of the array! ANY help is much appreciated!

BTW…Does anyone know of any good tutorials or a good book on the subject?

Subject: RE: Array help

It really sounds like, besides array help, you need programming help.

Am I correct in supposing that you have a similar table of fields on the response document? In your message you mention the user “selecting” rows from the original table, but the little code snippet you posted doesn’t reflect such a selection.

It sounds like what you want is to copy certain of the rows to a similar table, but the destination rows aren’t going to have necessarily the same numbers as the source rows. Therefore, your current code, that keeps track of the current row, is failing to track a basic piece of information – you need a source row counter and a destination row counter, but you have only one counter.

The function to find the upper bound of an array is ubound, but there’s no need here for you to find an array upper bound. You know how many times you need to iterate to read each row of data from the table – you have 10 rows. That never changes. There also seems to need to copy the data to an array – you want to copy data from one document to another document. Just copy over the field values from source field to destination field.

Incidentally, I think it’s better to use the back end (NotesDocument) to access field values, since this gives you the actual field value rather than the text that’s in the field, which might not be a valid value for the datatype of the field.