I have a form in MS access which shows displays all records with the same Primary key. The form is based on a query which asks for the user to input the primary key.
It allows the user to make changes to the records.
I would like the user to be able to exit the form without saving any changes.
Unfortunately me.undo does not work as it only clears the last changes and if a user has moved between records, more than one change may have been made.
Ideally on opening the form I would like to copy all the original records in a text box somewhere for future use.
The issue I have is there will be a different amount of records displayed depending on the primary key entered.
I assume I would need to use a loop but am fairly new to coding and don't really know where to start with this.
If this is possible when a user save the changes I will also use the data in this field to identify and inform an admin of the changes that have been made. So if this can be done it will be doubly useful for me.
Use a temporary table. When the process begin (i.e. when the user enters the primary key), the related records are copied into the temp. table (on which the form is based), using an INSERT query. Before closing the form, the user is asked is he wants to save the changed data (if any) and, when the answer is yes, an UPDATE query is called to transfer the data from the temp. table back to the original table.
Another solution, probable more efficient, would consists in using transactions, but this would not be easy if you're not familiar with the concept and with the DAO object model in general.