View.ColumnValues(8) Array problem, Help?

Hi,

I have a script, to access a view, and to heck the values of column 8 of the view.

Set oView = oDb.GetView(“By Student Code”)

Set oStudentViewEntry = oView.GetEntryByKey(Clng(oStudentCode))

oSTudentViewEntry.ColumnValues(8)

If (Arraygetindex(oSTudentViewEntry.ColumnValues(8),“Swimming”)>=0) Then

Messagebox "Yes, he likes Swimming!"

End If

Column 8 is taking values from a CheckBox field called “HOBBY”, allowing multiple values.

WHen I run the script, if that column has more than 1 values e.g. “Swimming”,“Reading”. Then it works fine.

But if the column 8 contain No values or just 1 Value, then it comes out with “TYPE MISMATCH” error!

I have cracked my head, trying different ways to avoid, but to no avail. Hope someone can give me some tips.

THank You.

Subject: Use the IsArray() function

…Set oView = oDb.GetView(“By Student Code”)

Set oStudentViewEntry = oView.GetEntryByKey(Clng(oStudentCode))

oSTudentViewEntry.ColumnValues(8)

if IsArray(oSTudentViewEntry.ColumnValues(8)) then

If (Arraygetindex(oSTudentViewEntry.ColumnValues(8),"Swimming")>=0) Then

    Messagebox "Yes, he likes Swimming!"

End If

Else

If oSTudentViewEntry.ColumnValues(8)="Swimming" Then

    Messagebox "Yes, he likes Swimming!"

End If

End If

Subject: View.ColumnValues(8) Array problem, Help?

You are probably trying to use ArrayGetIndex on something that isn’t an arrayYou could try setting a Variant type to be oSTudentViewEntry.ColumnValues(8), then work with that instead?

Chris Boote