![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have a database that has been in use for some years. Within this there are tables for Orders, OrderDetails, Deliveries and DeliveryDetails. The user now wants for archive deleted Orders and/or Deliveries. At present they are simply deleted. Once archived he wants the ability to restore selected 'archived/deleted' Orders or Deliveries. There appear to be two approaches: 1 to set up archive tables with the same structure at the originals. When deleting records, append them to the archive tables and delete them from the original tables 2 add an extra Boolean field in the tables to indicate whether the record should be regarded as 'deleted' or not. The first seems to be straightforward except for the fact that the OrderID in the Orders table is an Autonumber and this is the published, visible Order number. I know, I know I should not have used an Autonumber in this way but I have. Archiving appears to present no problem but I am concerned about restoring from the archive. Is it possible to re-insert the archived records back into the original tables whilst maintaining the original Autonumber? The second approach is simple in one respect but would require me to make sure that all appropriate queries were changed to filter out the 'deleted' records. There are many such queries and I need to be sure that I change them all. Seems a lot of work!! I would welcome any thoughts about which is the better approach. Or in fact whether there are still better approaches. Jim |
#3
| |||
| |||
|
|
I have a database that has been in use for some years. Within this there are tables for Orders, OrderDetails, Deliveries and DeliveryDetails. The user now wants for archive deleted Orders and/or Deliveries. At present they are simply deleted. Once archived he wants the ability to restore selected 'archived/deleted' Orders or Deliveries. There appear to be two approaches: 1 to set up archive tables with the same structure at the originals. When deleting records, append them to the archive tables and delete them from the original tables 2 add an extra Boolean field in the tables to indicate whether the record should be regarded as 'deleted' or not. The first seems to be straightforward except for the fact that the OrderID in the Orders table is an Autonumber and this is the published, visible Order number. I know, I know I should not have used an Autonumber in this way but I have. Archiving appears to present no problem but I am concerned about restoring from the archive. Is it possible to re-insert the archived records back into the original tables whilst maintaining the original Autonumber? The second approach is simple in one respect but would require me to make sure that all appropriate queries were changed to filter out the 'deleted' records. There are many such queries and I need to be sure that I change them all. Seems a lot of work!! I would welcome any thoughts about which is the better approach. Or in fact whether there are still better approaches. Jim |
#4
| |||
| |||
|
|
I have a database that has been in use for some years. Within this there are tables for Orders, OrderDetails, Deliveries and DeliveryDetails. The user now wants for archive deleted Orders and/or Deliveries. At present they are simply deleted. Once archived he wants the ability to restore selected 'archived/deleted' Orders or Deliveries. There appear to be two approaches: 1 to set up archive tables with the same structure at the originals. When deleting records, append them to the archive tables and delete them from the original tables 2 add an extra Boolean field in the tables to indicate whether the record should be regarded as 'deleted' or not. The first seems to be straightforward except for the fact that the OrderID in the Orders table is an Autonumber and this is the published, visible Order number. I know, I know I should not have used an Autonumber in this way but I have. Archiving appears to present no problem but I am concerned about restoring from the archive. Is it possible to re-insert the archived records back into the original tables whilst maintaining the original Autonumber? The second approach is simple in one respect but would require me to make sure that all appropriate queries were changed to filter out the 'deleted' records. There are many such queries and I need to be sure that I change them all. Seems a lot of work!! I would welcome any thoughts about which is the better approach. Or in fact whether there are still better approaches. Jim |
#5
| |||
| |||
|
#6
| |||
| |||
|
#7
| |||
| |||
|
|
Thank you all for your helpful comments. Salad and Ron question why I would wish to archive records if I subsequently wish to restore them. Think of deletion in the way that files are placed in a Trash can. Although they appear to have been deleted that are simply placed in a different place from which they can be retrieved. I have since experimented with some SQL statements to copy, delete and restore records. To place an Order into the archive: INSERT INTO OrdersArchive SELECT Orders.* FROM Orders WHERE Orders.OrderID =11800 The 11800 is merely illustrative! Then one can: Delete * From Orders Where Orders.OrderID = 11800 To restore this record: INSERT INTO Orders SELECT OrdersArchive.* FROM OrdersArchive WHERE OrdersArchive.OrderID =11800 The important aspect of this is that it re-inserts the record with the correct AutoNumber, namely 11800. My concern about this approach was ill founded. I should have done the experiment before posing the question. Sorry about that! |
#8
| |||
| |||
|
|
I have a database that has been in use for some years. *Within this there are tables for Orders, OrderDetails, Deliveries and DeliveryDetails. *The user now wants for archive deleted Orders and/or Deliveries. *At present they are simply deleted. *Once archived he wants the ability to restore selected 'archived/deleted' Orders or Deliveries. There appear to be two approaches: 1 * * * to set up archive tables with the same structure at the originals. When deleting records, append them to the archive tables and delete them from the original tables 2 * * * add an extra Boolean field in the tables to indicate whether the record should be regarded as 'deleted' or not. The first seems to be straightforward except for the fact that the OrderID in the Orders table is an Autonumber and this is the published, visible Order number. *I know, I know I should not have used an Autonumber in this way but I have. *Archiving appears to present no problem but I am concerned about restoring from the archive. *Is it possible to re-insert the archived records back into the original tables whilst maintaining the original Autonumber? The second approach is simple in one respect but would require me to make sure that all appropriate queries were changed to filter out the 'deleted' records. *There are many such queries and I need to be sure that I change them all. *Seems a lot of work!! I would welcome any thoughts about which is the better approach. *Or in fact whether there are still better approaches. Jim |
#9
| |||
| |||
|
|
On test may want to do with the delete / re-insert system 1) Delete the record with the highest autonumber 2) Compact the database, I think Access will reset the autonumber 3) Add a new record, It should get the deleted autonumber, If it does you will not be able to reinsert. |
#10
| |||
| |||
|
|
2 add an extra Boolean field in the tables to indicate whether the record should be regarded as 'deleted' or not. |
![]() |
| Thread Tools | |
| Display Modes | |
| |