I have the following code in the ONCHANGE event for the field called PrepContract. PrepContract is a COMBOBOX field where a user can choose YES or NO. If the user chooses YES, then I want to compose a new document. If the user chooses NO, then I don’t want nothing to happen.
Sub Onblur(Source As Field)
Dim ws As New notesuiworkspace
Dim uidoc As notesuidocument
Dim PrepContract As Variant
If PrepContract = Yes Then
Set uidoc = ws.composedocument("","","Supply Contract")
Else
ArkemaPrepContract="No"
End If
End Sub
Can anyone provide assistance on how to get this working correctly?
2> Select Run Exiting/OnChange events after value change
3> Put the code in the ‘Exiting’ event not the onBlur event.
Shawn
Sub Exiting(Source As Field)
Dim session As New NotesSession
Dim ws As New NotesUIWorkspace
Dim db As New NotesDatabase("", "")
Dim scDocument As New NotesDocument(db)
scDocument.form = "Supply Contract"
Call scDocument.Save(False, False)
Call ws.EditDocument(True, scDocument)
Dim ws As New notesuiworkspaceDim uidoc As notesuidocument
Dim uidocNew as NotesUIDocument
Dim doc as NotesDocument
Set uidoc = ws.CurrentDocument
Set doc = uidoc.Document
If doc.PrepContract(0) = “Yes” Then
Set uidocNew = ws.composedocument(“”,“”,“Supply Contract”)
Else
doc.ArkemaPrepContract=“No”
Call uidoc.Refresh '(optional)
Call uidoc.Save '(optional) or you could call doc.Save(False, True)
End If
This is just an example based on assumptions I’m making about what you’re trying to do. Also, I think that the OnBlur event is triggered when you actually exit the field (as opposed to just changing the Combo box selection).
Thank you very much for your help.Your code works perfectly. However, I do have one small problem. The new document being created does not create until I exit the field. I need the new document to be composed immediately when the field value is set to “Yes”.