0
votes

I want to put a form ( document ) to EditMode = false; So, when the form is opened, I want to cannot modify any fields etc until I press a button that puts the doc. in EditMode = true.

My code is smth like this:

Sub Initialize Dim ws As New NotesUIWorkspace Dim uidoc As NotesUIDocument Dim doc As NotesDocument Set uidoc = ws.CurrentDocument 'Set doc = uidoc.Document

uidoc.EditMode = False

End Sub

I choose to code in the Initialize method of the Form...

But it doesn't work and it gives me a message like: " Document comand is unavailable" . Please help, I will appreciate, thank you.

1
Try searching Google for "lotus notes prevent edit mode" and you will find lots of examples. Here's one: www-10.lotus.com/ldd/nd6forum.nsf/0/… - Per Henrik Lausten

1 Answers

3
votes

As a general rule of thumb, the Initialize event should not be used in forms. One reason for this is that the form has not necessarily finished loading everything by the time that Initialize runs.

This code should be placed in the QueryOpen event.

Another best practice is to NOT use NotesWorkspace.CurrentDocument to get a handle to the current form and instead use the Source parameter passed into the QueryOpen event. NotesWorkspace.CurrentDocument should only be used in agents and other places where the form is not already in context. Calling NotesWorkspace.CurrentDocument while the current document is already in context can cause strange behavior in Notes.

Here's some code that should work:

Sub Queryopen(Source As Notesuidocument, Mode As Integer, Isnewdoc As Variant, Continue As Variant)
    If (Not Source Is Nothing) Then Source.EditMode = False
End Sub