Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Multi-valued GetItemValue and VBA
Please can someone advise;
I'm using an MS Access 8 module written in VBA to transfer data directly from fields in a Notes 4.5.7 database to an Oracle db. All works fine except for one thing - extracting all values from a Notes multi-value menu item.
The code for getting a single value of an item is:
itemval = NotesDoc.GetItemValue(fieldname)(0)
the zero indicating the first and usually only value in that item.
However to obtain other values from a multi-valued item, e.g. a menu list, it is necessary to loop round the 'array' collecting all the other values. In Lotus Script this is done with:
For Each fieldval In NotesDoc.GetItemValue(fieldname)
itemval = itemval & "," & fieldval
Next
or something similar. But this doesn't work in VBA because VBA cannot directly cycle through all item values in a field.
The only solution I've found to stop the looping is to error trap a Subscript Out Of Range error, thus:
Function Get_Item_Values (notesDoc As Object, _
arraysize As Integer) As String For i = 0 To arraysize On Error GoTo EndLoop results = results & "," & _ notesDoc.GetItemValue(fieldname)(i)Next i
Get_Item_Values = Mid(results, 2, Len(results) - 1)
End Function
Does anyone know any better method please?
Many thanks - Chris B.