Subject: Update field on different form?
Your problem seems to be that when you create Form B the Form A is still open, so if you cancel B and at the sametime update the number in A you run the risk of getting a save conflict.
I suggest that the button to create Form B is a script action to increment the value, create B (passing it the unique doc id of A) then close A and present the user with the new B document.
If the new B document is cancelled then the cancel action closes the new Form B window and also locates form A and and reduces the number by one.
So on Form A button something like:
Dim ws As New NotesUIWorkspace
Dim doca As NotesDocument, docb As NotesDocument
Dim Session As New Notessession
Dim uidoc As NotesUIDOcument
Set db = session.currentdatabase
Set doc = ws.currentdocument.document
Set uidoc = ws.currentdocument
' Increment your number field on Form A
doc.NumberFld = doc.NumberFld(0) + 1
Call doc.save(True, True)
Call uidoc.save
’ Create B form copying across the Form A unique ID
Set docb = db.CreateDocument
docb.form = "FormB"
docb.parentref = doc.UniversalId
docref = docB.Universalid
Call docb.save(True, True)
Set reopendoc =db.GetDocumentByUNID( docref )
Call uidoc.close ' Close Form A
Call ws.EditDocument(True, reopendoc) ' open form B
and on Form B cancel action
Dim ws As New NotesUIWorkspace
Dim doca As NotesDocument, docb As NotesDocument
Dim Session As New Notessession
Dim uidoc As NotesUIDOcument
Set db = session.currentdatabase
Set docb = ws.currentdocument.document
Set uidoc = ws.currentdocument
' get Form A
Set doca =db.GetDocumentByUNID( docb.parentRef(0) )
’ take one off the number field and save it
doca.NumberFld = doca.NumberFld(0) - 1
Call doca.save(True, True)
’ open Form A
Call ws.EditDocument(True, doca)
’ make Form B non edit mode
uidoc.Editmode =False
’ call a delete on Form B
Call uidoc.DeleteDocument
(NB: NumberFld is a numeric field on the Form A, ParentRef is a text field on Form B)
(NB2: Form B will still be seen in the views until the view is refreshed by the user