LotusScript: Test if object property exists - how?

Hello everyone!

I couldn’t find a LotusScript forum, so I’m posting here. I have code like this:

Dim objCol As NotesDocumentCollection

Set objCol = doc.Responses

If objCol.Count>0 Then

  Print "Count is > 0"

End If

…which give me a “Object variable not set” when it hit the “If objCol.Count…” statement. Is there a way to check if “Count” is set? I have checked and objCol is not null and is an object. In javascript you could say something like “if(objCol.Count) {”.

Any help would be very appreciated! If there is a better forum, please let me know.

Thanks,

Alex

Subject: Nothing

You can test for Nothing with this property, I think:

If not doc.Responses is nothing then

Set objCol = doc.Responses

If objCol.Count > 0 then

    Print "Count is > 0"

End if

End if

Subject: Not Nothing

Thanks, but I actually tried this and gave the same error. What I found I had to do was check the object with the “IsA” to ensure that it was the object I want it to be before presuming to call properties or methods on it.

Cheers,

Alex

Subject: create a notesdocumentcollection

Dim ndc as NotesDocumentCollectionSet ndc = doc.Responses

If Not ndc Is Nothing Then

blah

blah

blah

End If

This works for me, so it ‘should’ work for you :slight_smile:

Phil