Deano wrote:
Alot of my forms are bound.
I would like to offer a Cancel option so that they can make as many changes
as they like and still Cancel out without making any changes.
I have one idea of how to do this for new records; tag each record with a
boolean value. On clicking OK, these are all set to True and the form
closes.
If they Cancel the False records are deleted and the form closes.
Not too sure what to do if they change an existing record and then exit.
OK, so to summarize they can both add and edit records in your bound
form, and hitting 'Cancel' should cancel ALL the edits and updates to
all records that were made that session.
If your application is single user, no problem. Copy the recordsource
to a temporary table, add a "Dirty" flag to each new and edited record.
Upon OK'ing the session, copy/update all records with the dirty flag
set to the original table.
If your application is multi-user, you're going to have to add a
'LastEdited' timestamp to all the records in the source table. In the
temporary table include this timestamp field, do not update it if you
edit a record, but do update the dirty flag. Note that you may have to
be tricky about key generation if you can have multiple users doing this
at once. When the session is OK'ed, copy all NEW records to the source
table, and update only existing edited records if the timestamp fields
are equal. Update the timestamp fields for those records.
For records where they are not equal, some other user has already edited
them and saved their changes. Present these records to the user and
allow them 2 choices: (1) discard your changes (2) get a fresh copy of
these records so you can make the changes over again.