In my Access 97 database I have several tables such as customer/products all linked to a current orders table. When a new order is placed a new record is created in the current record table, this is unique by using a AutoNumber field.
Current Orders table
OrderID CustomerID OrderDate etc.
--------------------------------------------
When an order is complete I move the record to a completed orders table which is identical in structure to the current orders table, except that the OrderId field is no longer an Autonumber, as the existing order number is used. The reason for moving the record is so that the current order table is limited in size to the only the current orders making access speed reasonable.
My problem occurs when the database is compacted as the Autonumber field is reset to the next number after the last Order in the current orders table. If the last completed order had the highest order number then after the compaction this order number will be reused for the next new Order.
When this new Order is completed it will fail to move the record to the completed table as the Order Id already exists in the completed orders table.
I can not use a different Order no in the completed orders, as the user may want to search for a particular order no, in which case I do a union query between the current orders and the completed orders table, so they must be unique between the 2 tables.
Can anyone help with a simple solution as I have only realised this at a late stage!