GetNextDocument error - how to prevent it

Hi, I have problem with following LS. I used method getnextdocument. From time to time an error occures and all LS is interrupted (I marked row with ***). (I guess that it is when there is no other entry in navigator which is document) Is there any easy way how in case of error LS can run further just entry is nothing and loop will be normally finished?)thank you, jakub

While Not entry Is Nothing

	Set doc = entry.Document

	Set prevodpol  = New NotesDateTime(doc.VDatum(0))

	Call prevodpol.SetAnyTime 'dodatek

	

	If (prevodpol.TimeDifference(prevodod) => 0) And (prevodpol.TimeDifference(prevoddo) <= 0)  And (doc.VNazevZak(0) = zakjmeno) Then				

		

		doc.VDavka = cislodavky

		Call doc.Save(True,False)

		ulozdavku = True

	End If	

*** Set entry = nav2.GetNextDocument(entry)

Wend

Subject: GetNextDocument error - how to prevent it

there have been hundreds of posting in this forum about problems when working with collections. Basically, if you are updating a document inside the collection, then you need to keep a placeholder BEFORE you make the change, something like this …Dim placeholder as NotesViewEntry

While Not entry Is Nothing

.Set doc = entry.Document

.Set placeholder = nav2.GetNextDocument(entry)

.If …do what ever you wanted

…Call doc.Save(True,False)

.End If

.Set entry = placeholder

Wend

Subject: RE: GetNextDocument error - how to prevent it

thank you, this works

Subject: RE: GetNextDocument error - how to prevent it

When you post about an error you’re having, it really helps to post the actual error message you’re getting. See link below for more hints about how to get good answers.

In your case, it seems you probably need to set the NotesView.AutoUpdate property False.

Subject: GetNextDocument error - how to prevent it

Jakub, perhaps it would solve the problem if you checked that you had a handle to the doc before you tried to work with it, as below. Give it a try.

While Not entry Is Nothing

Set doc = entry.Document

If not (doc is Nothing) then

Set prevodpol = New NotesDateTime(doc.VDatum(0))

Call prevodpol.SetAnyTime 'dodatek

If (prevodpol.TimeDifference(prevodod) => 0) And (prevodpol.TimeDifference(prevoddo) <= 0) And (doc.VNazevZak(0) = zakjmeno) Then

doc.VDavka = cislodavky

Call doc.Save(True,False)

ulozdavku = True

End If

End If

*** Set entry = nav2.GetNextDocument(entry)

Wend