Whenever a record is deleted or updated on a form, I want to save its old values in a history table (let's call it Revised). I guess I have to do the following:
For record changes:
- use the BeforeUpdate event to save the data somewhere (collection ? array ? or to a recordset -the Revised table- without saving-yet ?)
- use the AfterUpdate event to add/save that data to the Revised table
For Deletions:
- use the OnDelete event to save the data - but again how ? several records could be deleted at once since the form (a subform in fact) is in datasheet view
- use the AfterDelConfirm to add that data to the Revised table.
Do you have any clues, comments or links for this ?
This is all in a "pure Access" (no SQL Server) at the moment.
Many thanks !
Edit: as usual, properly asking the question gaves me ideas:
option 1
use the BeforeUpdate or the OnDelete to build the SQL statement, and use the AfterUpdate or the AfterDelConfirm to Execute the SQL statement. But that won't work for multiple deletions ?
option 2
have the Revised recordset defined ta form level, insert the record "Before" but only Update "After". Again, problem with multiple deletes.
WHERE active = True
And deletions actually becomeactive = False
Seems like this could be an inexpensive way to maintain a history of deleted records --- they're still present, but just not visible in the form. - HansUpIsActive
field, you could have aDateDeleted
field. It eats up a bit more storage space, but it could be indexed and would also provide additional information (which might be helpful someday when trying to figure out exactly what a user was doing). Every query would then have aDateDeleted Is Null
condition, instead ofActive = True
. - mwolfe02