Deleting response documents

I need to delete response documents from disk as well as the collection. Can it be done in this loop.Sub Click(Source As Button)

Dim session As New NotesSession

Dim ws As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Dim user As NotesName

Dim doc As NotesDocument

Dim db As NotesDatabase

Dim view As NotesView

Set uidoc = ws.CurrentDocument

Set db = session.CurrentDatabase

Set doc = uidoc.Document

'Loop on Contacts

Dim cont_coll As NotesDocumentCollection

Dim cont_resp As NotesDocument

Set cont_coll = doc.Responses

Set cont_resp = cont_coll.GetFirstDocument

While Not ( cont_resp Is Nothing )

'Loop on Activities

Dim act_coll  As NotesDocumentCollection

Dim act_resp  As NotesDocument

Set act_coll  = cont_resp.Responses

Set act_resp  = act_coll.GetFirstDocument

While Not ( act_resp Is Nothing )

  ***Delete act_resp

  Set act_resp = act_coll.GetFirstDocument

Wend

***Delete cont_resp

Set cont_resp = cont_coll.GetFirstDocument

Wend

Call uidoc.DeleteDocument

End Sub

Subject: Try this sub…

Sub DeleteDocAndResponses(doc As NotesDocument) Dim kids As NotesDocumentCollection

Dim kid As NotesDocument

Dim i As Long

Set kids = doc.Responses

For i = 1 To kids.Count

	Set kid = kids.GetNthDocument(i)

	Call DeleteDocAndResponses(kid)

Next

Call doc.Remove(True)

End Sub

Subject: Try this sub…which may go faster if the collections are big

Get nth is usually slower than get next but i’t harder to use getnext when past documents are deleted

this is an alternative

Sub DeleteDocAndResponses(doc As NotesDocument)

Dim kids As NotesDocumentCollection

Dim kid As NotesDocument

Set kids = doc.Responses

Dim sib as NotesDocument

set sib = kids.GetFirstDocument

do until sib is nothing

Set kid = sib

set sib = kids.GetNextDocument( kid )

Call DeleteDocAndResponses(kid)

loop

Call doc.Remove(True)

End Sub