Sub Querydocumentdelete(Source As Notesuidatabase, Continue As Variant)
Dim DocCol As NotesDocumentCollection ' To hold all selected documents
Dim CurDoc As NotesDocument ' For cycling through documents in DocCol
Dim vEvalResp As Variant ' Used for determining if user is part of correct role
' Find out if the user is not a member of either Admin, or Server roles.
vEvalResp = Evaluate( |!@IsNotMember(@UserRoles; "[ADMIN]":"[SERVER]")| )
If vEvalResp( 0 ) Then Exit Sub ' If they are a member, then leave module
Set DocCol = Source.Documents ' This are documents selected in the view.
Set CurDoc = DocCol.GetFirstDocument
Do Until CurDoc Is Nothing ' Cycle through all documents in DocCol
If CurDoc.Form( 0 ) = "MyForm" Then ' If the selected form is of type "MyForm" then fail
Continue = False ' Tell Notes that we are not going to delete the doc.
Exit Do
End If
Set CurDoc = DocCol.GetNextDocument( CurDoc )
Loop
If Continue = True Then
Msgbox "You do not have access to delete one or more of the selected documents!", 48, "Error deleting documents"
End If
CleanUp:
Set DB = Nothing
Set DocCol = Nothing
Set CurDoc = Nothing
End Sub