Have created this button on a form to create new copy of this document cancelling out hours requested for vacation, etc. Does exactly what I need, BUT … the current open document won’t close … AND … new document(doc 2)save doesn’t go into the QuerySave and QueryClose events on the form which reset some fields, then go to a mail/review routine
Here is the complete code (with the offending Call doc.close remarked out). Any help would be appreciated. Just spent 5 hours here trying to find a similiar post!
Sub Click(Source As Button)
'Action to copy current document reversing the hours requested entries,
'submitting to supervisor, and effectively cancelling request
Dim session As New NotesSession
Dim db As NotesDatabase
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim doc2 As NotesDocument
Set db = session.CurrentDatabase
'Get document, copy, change fields, then leave in Edit mode so staff can review and submit or CANCEL
Set uidoc = workspace.CurrentDocument
Set doc = uidoc.Document
Set doc2 = New NotesDocument (db)
’ doc2.SaveMessageOnSend = True
Call doc.CopyAllItems (doc2, True )
'Set fields to new values
Dim sick,ppd,ipp,vac,hol,per As Variant
Dim negate As Integer
negate = (-1)
sick=negate * doc2.SickDays(0)
ppd = negate * doc2.PPDdays(0)
ipp = negate * doc2.IPPdays(0)
vac= negate * doc2.VacDays(0)
hol = negate * doc2.HolidayDays(0)
per = negate * doc2.PersonalDays(0)
oth= negate * doc2.OtherDays(0)
Set notesItem = doc2.ReplaceItemValue("SickDays", sick)
Set notesItem = doc2.ReplaceItemValue("PPDdays", ppd)
Set notesItem = doc2.ReplaceItemValue("IPPdays", ipp)
Set notesItem = doc2.ReplaceItemValue("VacDays", vac)
Set notesItem = doc2.ReplaceItemValue("HolidayDays", hol)
Set notesItem = doc2.ReplaceItemValue("PersonalDays", per)
Set notesItem = doc2.ReplaceItemValue("OtherDays", per)
Set notesItem = doc2.ReplaceItemValue("Form", "Cancel")
Set notesItem = doc2.ReplaceItemValue("Approved", "")
Set notesItem = doc2.ReplaceItemValue("submitted", 1)
Set notesItem = doc2.ReplaceItemValue("NSubmitNOW", 1)
Set notesItem = doc2.ReplaceItemValue("Status", 2)
Messagebox ("If approved by your supervisor, this request will be cancelled. It will still appear in your records, but the hours will be added back to your total.")
Call doc2.Save (False, False,True) 'Save new doc
Call doc.Save (False, False, True)
’ Call doc.Close([True])
Call workspace.ViewRefresh
End Sub