Undo record changes

S

Sharon

Hi

I have a form that contains multiple tabs and subforms. Form Undo or
control old value won't work because as soon as another tab or a subform gets
the focus, the record is saved. It is necessary to allow the user to close
the form without saving changes, i.e. undo any changes. I am currently
writing out the record to a temporary table on form open and intend
reinstating the record from the temp table if the user exits without saving.
Is this the best way? Also what would be the best way to get the temporary
record back into the table? Any help would be much appreciated. Thanks.
Sharon
 
V

Van T. Dinh

You may need more than one "temporary" Table since you need to hold the
temporary data for the Subforms also if you want to do an "overall"
cancellation, i.e. cancelling all changes on the main Form and the Subform.

One of my work-arounds for data entry into the Form / Subform combination is
to hide the Subforms and provide a CommandButton for the user to explicitly
save (code asking the user to confirm before updating) the "One" record at
which type the code makes the Subform visble.
 
J

John Spencer

This is the simplest method that I know.

--Have local/shadow work tables that parallel the permanent data
--Clear the local/shadow work tables
--Load the local/shadow work tables with the relevant records
--Do all the form work with the local/shadow tables
--Update the permanent data from the local/shadow work tables
--Clear the local/shadow work tables

In simple cases you could load an unbound form and unbound controls with the
data from the record(s) and then update the relevant tables when the save
button was closed.
 
J

John Spencer

IF undo changes is selected, just reload the temp tables FROM the permanent
tables. The permanent tables should not be changed at all.

In a multi-user environment, the relevant records could have been changed by
someone else unless you have implemented some record locking routine that
keeps that from happening. That could be accomplished by have an "in use"
field that gets set when the records are loaded to the working table and
then clearing the "in use" field when the records are no longer being used
by the temporary tables. Of course, then you need to have some way to
clear the "in use" field(s) when crashes, errors, and abnormal shut downs
occur. I would probably use a datetime field and store the date and time
the record was "in use" and then have a routine that clears all the "in use"
fields that were older than some specified datetime.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top