I’ve posted this in in v8 forum, but haven’t yet gotten an answer. I created this to give the user an option of also deleting all documents related to the document they are deleting (via a UID field with a common value).- My form name is “Main”.
- “UID” is a field I created which assigns all the common requests with the same unique ID to make finding all the related documents later much easier.
The code below almost works perfect. Related documents are found, they are deleted, view is refreshed and related documents are gone. But when closing the database I get the default prompt you get in all Notes databases when you try to exit a database and you have a document marked for deletion: “Do you want to delete the 1 document from the database?” FYI: It doesn’t matter whether I choose “Yes” or “No” to that default prompt since the documents are already gone. <— I just want to get rid of that message and all will be well, can anyone help? Here is my code I am using in the Querydocumentdelete of the Database Script:
Sub Querydocumentdelete(Source As NotesUIDatabase, Continue As Variant)
On Error GoTo errhand
Dim session As New NotesSession
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Dim resp As Integer
Dim prompt As String
Dim AssocDocs As NotesDocumentCollection
Dim db As NotesDatabase
Dim v As NotesView
Dim workspace As New NotesUIWorkspace
Dim tmpUID As Variant
Dim nextDoc As NotesDocument
Set db = session.CurrentDatabase
Set v = db.getview(“(AllRequestsByUID)”)
Set dc = Source.documents
Set doc = dc.getfirstdocument
’ Do following if trying to delete a “Main” request &
’ there are reoccurring documents associated with the selected
’ request. Otherwise, it’s an individual doc and they are free
’ to delete it without prompt.
If doc.form(0) <> “Main” Then Exit Sub
If doc.Reoccuring(0) <> “Yes” Then Exit Sub
tmpUID = doc.UID(0)
Set AssocDocs = v.getalldocumentsbykey(tmpUID)
prompt = “Do you want to also select all " & AssocDocs.count & " associated reoccurring dates for deletion?”
resp = MsgBox(prompt, 35, “Verify”)
If CStr(resp) = “2” Then 'If Cancel, dont do anything
continue = False
Exit Sub
ElseIf CStr(resp) = “6” Then 'If Yes, select all reoccurances and delete them
Call AssocDocs.RemoveAll(True) ’ remove the docs on the backend
Call workspace.ViewRefresh ’ show removed docs on frontend
Else
’ If No, only mark the selected document for deletion
End If
Exit Sub
errhand:
MsgBox "QueryDocumentDelete error at line " & Erl & Error
Exit Sub
End Sub