Lotusscript loop very erratic but no error caught

I have a LotusScript problem that I haven’t seen in the 10 odd years of use before.

I am running a simple loop through a view, which is coded as below.

The view has 264 documents in it. Sometimes the code shows only documents 1 to 18, and loops round a few times, other times it counts sequentially to 159, the ends - in both cases the error handler isn’t invoked, and the script completes “normally”.

The script is in an agent which is called as a “Run on Server” from a WebQuerySave agent.

Set stageDoc = stageView.GetFirstDocument

While Not (stageDoc Is Nothing)

viewTally = viewTally + 1

Messagebox Cstr(viewTally)

Set stageDoc = stageView.GetNextDocument(stageDoc) Wend

As you can see, hardly rocket science.

I’ve also removed all sorting apart from an Ascending Sort on the 1st column of the view.

Any ideas?

Subject: loop

try setting view.autoupdate = false before starting the loop, then set it back to true at the end