'(Globals) object, (Declarations) event
Dim allowEdit As Integer
'(Form) object, Postopen event
Sub Postopen(Source As Notesuidocument)
'Let document pass if new or not in EditMode
'Otherwise if existing document is in EditMode
' Set allowEdit so Querymodechange doesn't reprocess
' Turn EditMode off so document opens in Read mode
' Tell the user to use the action
If source.EditMode And Not source.IsNewDoc Then
allowEdit = True
source.EditMode = False
Messagebox _
"Use Edit mode action to edit document"
Else
allowEdit = False
End If
End Sub
'(Form) object, Querymodechange event
Sub Querymodechange(Source As Notesuidocument, Continue As Integer)
'Allow user to proceed, and turn off allowEdit if
' user clicked the action (allowEdit on)
' already processed by Postopen (allowEdit on)
' trying to get out of Edit mode
' (allowEdit off but EditMode on)
'Tell user to click action if changing existing document
' to Edit mode and not already processed by Postopen
' (allowEdit and EditMode off)
If allowEdit Or (source.EditMode And Not allowEdit) Then
allowEdit = False
Else
Messagebox _
"Use Edit mode action to edit document"
continue = False
End If
End Sub
'(Action) object, Click event
Sub Click(Source As Button)
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Set uidoc = workspace.CurrentDocument
'Turn on allowEdit so Querymodechange will let it pass
'Turn on EditMode
allowEdit = True
uidoc.EditMode = True
End Sub