Copy data from one subform to another - MS Access
Posted on 2016-10-27
I have an Access database that has a form with 2 subforms on it. Subform1's record source is MyTable. Subform2's record source is MyTemporaryTable. In the detail section of Subform1 (displayed as continuous forms), in addition to the table's fields displayed in textboxes, I have a command button that I intend to use as a "select" button. the "select" button appears next to every record displayed in Subform1.
I want to be able to 'select' a record from Subform1 and have it copied into Subform2 (i.e. populate the temporary table with that record).
So, my question is related to the action of the 'select' button in Subform1. How do I get it to copy the selected record from Subform1 and populate Subform2 (and thereby save it to the temporary table)?
If it isn't that complex of a solution, then it would also be great if someone could show me how to also 'deselect' a record from Subform2 (i.e. I would also put a command button in Subform2 like I have in Subform1 except its purpose would be to delete the record from the temporary table in the event the user made a mistake and selected the wrong record from Subform1).
The data needs to be saved to the temporary table as I will be doing something additional with the data in the near future, so I don't want to just populate subform2. I need the selected data to actually be saved to the temporary table.