Hello All,
I have an action in a form, but we wnat to run it in several docs. I figure that I’ll move the action to a view, but I’m getting an error about a variable not set. Can this be done?
Sub Click(Source As Button)
Dim ws As New notesuiworkspace
Dim session As New notessession
Dim db As notesdatabase
Dim uidoc As notesuidocument
Dim doc As notesdocument
Dim cd As String
Set uidoc = ws.currentdocument
Set doc = uidoc.document
Set maildoc = session.CurrentDatabase.CreateDocument
With maildoc
.Form = "Form name"
.SendTo = "Send to"
.CopyTo = "copy to"
.Subject = "Subject"
.ComputeWithForm False, False
.Send True
End With
Call uidoc.save
Call uidoc.close
End Sub
Subject: Can an action be move from a form to a view? Error Variable not set
Yes, you should be able to do this. You can enable the LotusScript debugger to see where a runtime error occurs - it is with the “Set doc = uidoc.document” statement as you now have a different context from the view. Since you have the line “Set maildoc = session.CurrentDatabase.CreateDocument”, you do not need the two prior set statements that are causing the runtime error. An alternative is to have the action be a shared action and submit it into several forms in the NSF.
Subject: Can an action be move from a form to a view? Error Variable not set
You don’t have the NotesUIDocument object in a view. You’ll have to use notesUIView.Documents to get your NotesDocumentCollection, then cycle through it to get your NotesDocument objects.