I need to perform a transaction involving two operations (depending on which parameters the user selects at the point of save in the form “frmEditReport”).
If the User selects a certain parameter then I need to perform these 2 operations at the point of save:
1. Save the current form Edit operation in “frmEditReport”.
2. Insert a new record in another table handled by another form, “frmSelectWorkspaceToAdd” in the database, which opens automatically when a certain parameter is selected in the Edit Report form.
Therefore, the entire transaction will need to be wrapped across two different forms in the database.
Also, please note that the form handing the new record insertion also contains its own transaction processing because in addition to inserting a new record, the form also updates another field in the newly inserted record.
More Detailed Outline of the Problem
The user will double click a form record in a listbox to edit a record in this form. This causes the “Edit Report” form to be displayed as shown below in which the user will make changes to the record and then click Save Record to save the record.
The problem to be solved is when the form opens with a Report Status different from “Live” and the User changes the Report Status selection to “Live“.
When this happens then an additional operation needs to be performed in addition to saving the current “Edited” record. This additional operation involves the user choosing a “Workspace” value and inserting this value in an entirely different table. Also these 2 operations need to be wrapped in a transaction such that they either both succeed or are rollbacked accordingly.
The form “frmEditReport” is an unbound form and the additional operation to be performed when report status is changed to “Live” in the form is to add a Workspace to another table in the database. In my database adding a workspace is handled by another unbound form called “frmSelectWorkspaceToAdd”.
Some code outlining the problem is shown in the attached PDF document below. Please note that it is partly pseudo code and demonstrates what needs to be done. I could bypass the problem entirely to insert a new workspace record in “frmSelectWorkspaceToAdd” by duplicating that code in the form “frmEditReport” but of course I understand that this wouldn’t be good programming practice at all.
I am sorry if this is unclear but I am not looking for a fully coded solution to this problem but only some guidance on how to wrap transactions in 2 different forms if this is possible (in particular utilizing an already created 2nd form in the database and where this 2nd form already has its own transactions nested in the save procedure). Also I can provide more details about the 2nd form and the data to be inserted there but I don't want to make this post excessively long and complicated.
Many thanks for all your help and assistance.