Hi all,
i have a problem when i create a new doc. In a form, i have a action hotspot with this code.
If the user save the form before click into action hotspot, the code runs ok but if not, the error “Object variable not set” occurr in line:
Set rtf1 = currdoc.GetFirstItem(“DVPLoc”)
This is the code.
Sub Click(Source As Button)
Dim session As New NotesSession
Dim workspace As New NotesUIWorkspace
Dim uidoc As notesuidocument
Dim currdoc As notesdocument
Dim db As NotesDatabase
Dim collection As NotesDocumentCollection
Dim doc As NotesDocument
Dim rtf1 As notesrichtextitem
Set db = session.CurrentDatabase
Set uidoc = workspace.CurrentDocument
Set currdoc = uidoc.Document
Set collection = workspace.PickListCollection(1, False, "Server", "Database.nsf", "View","DVP & R List", "Please select a DVP & R")
If collection.Count = 0 Then
Messagebox "User canceled" ,, "No Documents selected to be linked."
Else
Set doc = collection.GetNthDocument(1)
Set rtf1 = currdoc.GetFirstItem("DVPLoc")
If rtf1.type = RICHTEXT Then
If ( rtf1 Is Nothing ) Then
Exit Sub
Else
If doc.Codigo(0) <> "" Then
Call rtf1.AppendText("DVP&R: ")
Call rtf1.AppendDocLink(doc,"DVP&R")
Else
Call rtf1.AppendText("DVP&R: " & doc.FicoRef(0) &" is linked . Please click on the doclink to open the document")
Call rtf1.AppendDocLink(doc,"DVP&R")
End If
End If
End If
End If
Call currdoc.save(True,False)
currdoc.saveoptions = "0"
Call uidoc.Refresh
Msgbox "DVP&R: " & doc.FicoRef(0) &" is linked ."&Chr$(10)&"The DVP&R link only appear after you save and close this document.",0,"DVP & R Link"
End Sub
Tanks