Search code examples
vbams-accesssql-delete

MS Access: move deleted records automatically to "recycle bin" table


I need to implement a copy of records right after they are deleted from the table, so they can be recovered in case of accidental deletion.

I am using MS Access. Is there any built in way to do it or will I have to INSERT INTO SELECT before every DELETE?

Doing it for just one table is not a concern. I want to use something ready for any table regardless of its structure, so I don't need to create and configure another recycle-bin-table for every table I have in the database, which would be necessary if I want successful move operations.

Besides SQL, I can run VBA to accomplish this task.

EDIT

There are recommendations of adding a boolean column that indicates if the record is to be displayed or is archived (has the meaning of "deleted" for my purposes), but this involves changing every table and every query I have done, so it won't fit for me, only as a last resort.


Solution

  • What happens when you have cascading deletions, as in all good designed databases? Also your INSERT in a backup table before DELETE will not solve all the issues you will face. Also copying table can result in a lot of copies that will increase your database size and you will have soon or later to clean your data.

    Journaling can be better solutions?