HELP: coll.GetFirstDocument in Collection doesn't return a document

Hi,

i’m doing a db.search in order to get a collection of documents to generate a report.

The search works fine and returns a coll. with a count of 1891.

However, if i start walking the collection using coll.GetFirstDcoument … GetNextDocument, i never get a valid doc - it always remains “Nothing”.

I already tried coll.GetNthDocument with the same result.

The funny thing is, if i call coll.PutAllinFolder and start walking the folder, the docs are there!

Same with calling coll.StampAll (“MyField”, “Hello”) - it works…

Has anybody any idea? i paste the relevant code for reference…

many thx in advance for your help - i just don’t know what to do to fix this…

Andreas

Code ---------------------------------------

Dim se As New notessession

Dim db As notesdatabase

Dim coll As NotesDocumentCollection

Dim doc As notesdocument

Dim strSearch As String

dim CutOffDate as new notesDateTime (“01/01/2000”)

Set db = se.currentdatabase

strSearch = {(Form = “Kontaktbericht”) & (}

strSearch = strSearch & {@Contains (@Text (@Month (Start)); "} & Cstr (Month (ReportDate.DateOnly))

strSearch = strSearch & {") & @Contains (@Text (@Year (Start)); “} & ReportJahr & {”))}

Set coll = db.Search (strSearch, CutOffDate, 0)

If coll.Count = 0 Then

Error 30000, "No Documents found!"

End If

set doc = coll.GetFirstDocument ’ <— always returns NOTHING!!!

While Not doc is Nothing

... do some processing....



set = coll.GetNextdocument (doc)

Wend

Alternativ code for while-loop:

for i = 1 to coll.count

set doc = coll.GetNthDocument (i) ' <--- ALWAYS REMAINS NOTHING!!!



... do some processing....

next

ANY IDEAS?

Subject: HELP: coll.GetFirstDocument in Collection doesn’t return a document

Try empty parenthesis after GetFirstDocument, like this: set doc = coll.GetFirstDocument()

I know it seems silly, but otherwise the code looks fine to me :slight_smile:

Subject: RE: HELP: coll.GetFirstDocument in Collection doesn’t return a document

And then set = coll.GetNextdocument (doc)

needs to be

set doc = coll.GetNextDocument(doc)

(probably just a posting typo but…)

–Andy S

Subject: Ignore

Subject: RE: HELP: coll.GetFirstDocument in Collection doesn’t return a document

I don’t know for sure, but I think Your line:While Not Doc is Nothing

should be

While Not (Doc is Nothing)

Andy

Subject: HELP: coll.GetFirstDocument in Collection doesn’t return a document

I recently encountered this problem - somehow, when copying a database for testing, the type on the first tab of the properties was changed to “Multi DB Search” instead of standard. Why this prevents us from accessing the docs in a documentcollection I don’t yet know. Changing the type back to standard fixes the problem though.

Subject: RE: HELP: coll.GetFirstDocument in Collection doesn’t return a document

It is wonderful to get benefited from a post of almost 10 years back. Thanks for posting Peter!!