Here's the code:
Sub Postopen(Source As Notesuidocument)
Dim doc As notesdocument
Dim item As notesitem
Set doc = source.document
Set item=doc.getfirstitem("RoleX")
If item.contains("[
CSSUnderwriters]") Then
continue=True
Elseif item.contains("[
Admin]; [
CSSUnderwriters]") Then
continue=True
Else
Messagebox "You are not
authorized to open this form.",,"No Access"
continue=False
Exit Sub
End If
End Sub
Continue is not available in the PostOpenEvent. You have two options. First, you can use your code in the PostOpen Event as modified below.
Sub Postopen(Source As Notesuidocument)
Dim doc As notesdocument
Dim item As notesitem
Set doc = source.document
Set item=doc.getfirstitem("RoleX")
If item.contains("[
CSSUnderwriters]") Then
Goto SingleExit
Elseif item.contains("[Admin];
[CSSUnderwriters]") Then
Goto SingleExit
Else
Call source.Close
Messagebox "You are not authorized to
open this form.",,"No Access"
End If
:SingleExit
End Sub
However, you shouldn't even show the document if you don't want the user to open it. You could use your original code in the QueryOpen event so the document is not opened. Continue is available and will function in QueryOpen.
Although both of these methods will keep the document from being opened, it is not a security function and will not prevent people from accessing information in the document.
Do you have comments on this Ask the Expert question and response? Let us know.
This was first published in October 2004