Sub Queryopen(Source As Notesuidocument, Mode As Integer, Isnewdoc As Variant, Continue As Variant)
Dim FoundRole As Variant
Dim session As New NotesSession
Dim doc As NotesDocument
Set doc = Source.Document
Dim user As String
Dim docauthor As String
user = session.CommonUserName
If Source.IsNewDoc = False Then
docauthor = doc.created_by(0) ' Field to check
If user = docauthor Then
continue = True
Else
userRoles = Evaluate("@UserRoles")
If Source.IsNewDoc = False Then
If Source.EditMode = True Then
FoundRole = False
For i = 0 To Ubound(userRoles)
If userRoles(i) = "[Admin]" Then ' Role to check
FoundRole = True
End If
Next
If FoundRole = False Then
Messagebox "You do not have the authority to edit this document, please contact " & docauthor & " or the database administrator.", 16, "Access Control Error"
Continue = False
Else
Continue = True
End If
End If
End If
End If
End If
End Sub