I have a form with two subforms, one of which is inserted based on a formula (based on the value of the Categories field). The LotusScript I use for the Click event of the button in the first subform works fine, but virtually the same thing does not work when used in the subform. This exact subprocedure below works just fine on another form, but not in the computed subform. I keep getting “Variant does not contain an object” when I click the button.
Sub Click(Source As Button)
Dim CourseNum As String
Dim uidoc As NotesUIDocument
Set uidoc = workspace.CurrentDocument
CourseNum=doc.Taken(0) & ":" & doc.TakenDate(0) & ","
doc.Taken=Null
Call uidoc.FieldAppendText ( "History", CourseNum)
If CourseNum ="" Then
Exit Sub
End If
Call uidoc.refresh
End Sub
The reason I am doing it this way is because contacts may belong to more than one category, and each category has a subform that goes with it that needs to be inserted if the contact belongs to it.
Subject: LotusScript works, but not in Subform
Where is workspace defined?
Subject: LotusScript works, but not in Subform
YOu do need to define workspace, but after that you will need to define ‘doc’ You need to have dim workspace as new notesuiworkspacedim doc as notesdocument
set uidoc = workspace.currentdocument
set doc = uidoc.document
If you do not want to define doc then use uidoc.FIeldGetText(“Taken”)
If you put ‘Option Declare’ in the Options event it will help you identify any variables that are not declared.
Subject: LotusScript works, but not in Subform
Thanks for your help. My subform works now. I am still having a problem with a replication/save conflict. I have the following code in the Exiting event the Categories field on the main form.
Dim session As New NotesSession
Dim workspace As New NotesUIWorkspace
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim doc2 As NotesDocument
Dim docUID As String
Set db = session.CurrentDatabase
Dim uidoc As NotesUIDocument
Dim uidoc2 As NotesUIDocument
Dim view As NotesView
Set uidoc = workspace.CurrentDocument
Set doc = uidoc.Document
docUID=doc.UniversalID
Call uidoc.Save
Set doc2 = db.GetDocumentByUNID (docUID)
Set uidoc2= workspace.editdocument(False, doc2, False)
Call uidoc2.RefreshHideFormulas
Call uidoc2.Refresh
Call uidoc.Close
I need this because the computed subforms are based on this field. The problem is, when the user saves and closes the document when they are done editing, it tells them “Another copy of the document has been saved. Would you like to save your changes as a replication/save conflict?” Any ideas on how I can prevent this would be very much appreciated.