Do Loop and doc.remove

I have a Do Loop:

While Not doc Is Nothing

DocsRead = DocsRead + 1

	

Doc.DateLastArchived = Now()

Doc.ArchiveAgent=1 ' Field to differentiate the source

If Not doc.HasItem ("DateOriginallyCreated") Then

Doc.DateOriginallyCreated = doc.Created

End If

Call doc.Save(True,False)

Call doc.CopyToDatabase( ArchiveDB )

DocsWritten = DocsWritten + 1



Call doc.Remove(True)

    Set doc = ArchiveView.GetLastDocument	

Wend

The second time through the loop it hits the doc.DateLastArchived line and throws the error: “The document has been deleted”

Shouldn’t I be getting the last document?

(I think if I get previous document there is no object there)

Is there a way to update the collection?

TIA

Subject: Do Loop and doc.remove

Jon,

try replacing your loop with a Do Until

Also, you will probably need to do archiveview.Refresh to update it (might have some performance issues). Probably better to build a NotesDocumentCollection from the view and then at the end use the RemoveAll method of the collection.

HTH

Mike

Subject: RE: Do Loop and doc.remove

I wanted to build a collection, but the db is at 35 Gig and the collection will be enormous.

The archiveview.refresh is excellent idea. also what do you think about placing:

archiveview.autoupdate = True

anyway - Thanks Muchly Mike

Subject: RE: Do Loop and doc.remove

How many documents will be in the collection?? (ie: how many docs currently in the archiveview?)

This would still be quicker than updating the view EACH time you delete a document. At least a collection is static so it is easier to navigate through and then remove them all at the end.

Mike

Subject: RE: Do Loop and doc.remove

there is also a for all with 6 views dimmed …

Dim ViewList(1 To 6) As String

Forall view In ViewList

Set ArchiveView = db.GetView(view)

my estimate for each view is somewhere between 5000 and 8000 docs for each one but there could be more

also, some of the docs are in excess of 100 MB each!

I will try the collection because considering the volume it should be a lot faster (but my deadline to run is monday so I may be stuck)

Subject: RE: Do Loop and doc.remove

Personally, I would build one view that encompasses all 6 of the views you are dimming, then look at getting the best performance from them by messing about with the indexes/refresh when settings. Then run my script on those.

Good luck Jon.

Please let us know how you get on/how it goes. Monday is days and days away!!!

Mike

Subject: RE: Do Loop and doc.remove

days and days - unless you will be lynched in 48 hours

LOL

Many Thanks Mike - I will post a follow-up