TypesFromArray Method

The TypesFromArray method is a private function in the Search component that is called from the AdvancedSearch method. It accepts one parameter, an array of the media type selection (one, more than one, or all the media types selected by the reviewer in the Choose Title dialog box), and loops through the array of elements and assembles the media types into a string with the correct syntax for a WHERE clause. The string is returned to the AdvancedSearch method.

MAX_COLL is a private constant that contains the value 5 (the maximum number of media types in the CML/LitCrit application). The reason the code specifies MAX_COLL – 1, is that the array is zero-based and the upper bound of an array with 5 elements is 4. If the reviewer has chosen all media types (UBound(WhereClause) is not less than MAX_COLL – 1) the TypesFromArray method returns an empty string.

If VarType(WhereClause) = vbArray + vbString Then
   If UBound(WhereClause) > 0 And UBound(WhereClause) < MAX_COLL - 1 Then
    strOR = "("
      For Each item In WhereClause
         If item <> "" Then
            TypesFromArray = TypesFromArray & strOR & "t.coll='" & CStr(item) & "'"
            count = count + 1
            strOR = " OR "
         End If
      Next
      If count > 0 Then TypesFromArray = TypesFromArray & ")"
      End If
   End If
End If

The complete code for the TypesFromArray method is available in Search.cls in the code section.