This defines a global variable on the form (since it has to be available to the QueryModeChange and the action button) and includes code for the form's QueryOpen and QueryModeChange events, plus code for the action button itself. I haven't tested this in any other kind of button/hotspot within a form, but I suspect it would work.
We use it in an application where we want users to make changes only through a dialog box so we can restrict the fields they can change. Sure, we could have run the code from the QueryModeChange, but that's the beauty of Notes/Domino: lots of different ways to accomplish the same thing!
'(Globals):
Option Public
Dim EditAction As Integer
'Form_name:
Sub Querymodechange(Source As Notesuidocument, Continue As Variant)
If Not Source.EditMode and Not EditAction Then
Messagebox "You must use the Edit action button to edit the document",64,"Edit " &_
"Document"
Continue = False
End If
End Sub
Sub Queryopen(Source As Notesuidocument, Mode As Integer,_
Isnewdoc As Variant, Continue As Variant)
If Not Isnewdoc Then
If Source.EditMode Then
Messagebox "This document cannot be opened in Edit mode",16,"Edit Document"
Continue = False
End If
End If
End Sub
'Edit: (action button)
Sub Click(Source As Button)
Dim ws As New NotesUIWorkspace
EditAction = True
' Do your checks to make sure they can edit the document, then put it into Edit mode
ws.CurrentDocument.EditMode = True
EditAction = False
End Sub
provided by Julian Robichaux at nsftools.com.
Technorati: Show-N-Tell Thursday
Categories: Show-n-Tell Thursday_
2 comments:
Shouldn't EditAction be Boolean and not a Integer?
It could be, but that data type isn't available prior to ND6 (as I recall). Using an Integer will allow the code to work in any prior version.
Thanks for the comment!
Post a Comment