Lotus Notes FAQ


How do you open a document in edit mode if it exists?

The following code will open in edit mode the first doc in the "UPref" view if it exists or create a new document if it doesn't exist. Use GetDocumentByKey on the view if you need to select a specific document first.

Dim session As New Notessession
Dim ws As New NotesUIWorkspace
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument

Set db = session.CurrentDatabase
Set view = db.GetView("UPref")

On Error Resume Next
Set doc = view.GetFirstDocument
If doc Is Nothing Then
 Set uidoc = ws.ComposeDocument("","","UPref")
Else
 ws.OpenDatabase "","","UPref"
 ws.EditDocument
End If


Home *Notes V3 *Notes V4 *Notes/Domino 4.5

Last Modified: May 24, 1996