IsElement(myDeptList(dept1))... should this work?

I have built a list of departments(departmentList). I wish to see if the string from field ‘dept1’ is contained within this list … I have tried the following, but first condition is always False, even although I know the string is contained here, since I print it’s value out to the agent Log.

Sub Cumulative (dept1 As String)

departmentList(Cstr(deptListIndex))= deptDoc.Department(0)

If Iselement(departmentList(dept1)) = True Then

 Do While JobDoc is Nothing

    ' some code



     Do while Not doc Is Nothing

     ' some more code relevant to first loop

     Loop

 Loop

Else

Print “Should not be here, since value does exist in list!”

End If

End Sub

Any help appreciated… thanks in advance.

Subject: RE: IsElement(myDeptList(dept1))… should this work?

Iselement tells whether a given “tag” appears in the list. It’s hard to be sure from the code you showed, but it appears you’re expecting it to search the data instead. If you write:

alist(“Joe”) = “tall”

Then Iselement(alist(“Joe”)) is true, but Iselement(alist(“tall”)) is false.