I am using getentrybykey to get a view entry. Then I use entry.columnvalues(2) to get the value of the third column. My Problem is that the column contains multiple values.
This column will always contain the same number of values (16) and I will always just need to get one of the values (but the value I need will change depending on the date).
What is the best way to get the value I need?
I’ve tried several things, but none seem to work (my problem is that I’m a little confused with arrays).
(x would be the item in the list I want to access)
myvalue = entry.columnvalues(2,x)
or
dim myHours(1 to 16) as variant
myHours = entry.columnvalues(2)
myValue = myHours(x)
or what I thought I might have to resort to is something like this (but this doesn’t seem like the most efficient or logical way of doing it):
c = 1
forall v in entry.columnvalues(2)
myHours(c) = v
c = c+1
end forall
Subject: help: ColumnValues(x) returns an array
Hello Chris,
When you need only one value you could use:
myvalue = entry.columnvalues(2)(x)
Where x is the position of the value you need-1, since arrays starts counting with 0.
This is a quick way of writing the code. This line says could also be written as follows:
Dim myValues as variant
myValues = entry.columnvalues(2) 'This will return the value of 3th column. Since this column contains multiple values, it will return an array.
myValue = myValues(x) 'Get the xth element of the array myValues
Good luck,
Rene
Subject: RE: help: ColumnValues(x) returns an array
Also…if the array is “empty”, there’s nothing in that column, your code will error.
I would add…Not Typename( myArray ) = “EMPTY”:
dim myArray as variant
private const INT_POSITION = 5 '// element in column array to return
.
.
.
myArray = doc.columnValues( 2 )
Msgbox arr(INT_POSITION)'// this line will error if there is nothing in the column
If Not Typename( myArray ) = “EMPTY” Then
Msgbox arr(INT_POSITION)
End If
Regards,
Nick
Subject: RE: help: ColumnValues(x) returns an array
It wouldn’t hurt to test with Isarray() either – since Notes doesn’t use table definitions, you have no way of knowing for sure what the column return will be.