Could if be that this test is failing:
If Len(Trim(cTestOcc)) = 0 Then
You try to pass the cTestOcc to Trim function but if the value of the object is null from the database (DBNull) then the Trim will fail.
Try adding a parameter validation first:
If cTestOcc = DBNull.Value Then
...