I use a form to build a list of records into a temporary table, and when the user has completed the form I run an append query to add the temporary records into the main table. The idea is to be be able to delete all records from the temporary table if a user 'abandons' without affecting the main data. The structure of the temporary table is identical to the main table. The only indexed field is the Autonumber ID field in the main table. I do not specify the Autonumber field in the append query. The syntax I use is:
DoCmd.RunSQL "INSERT INTO [Main Booking Subdata] ( BookingID, MenuID, Product, Price, Qty, Total ) SELECT TempBooking.[BookingID], TempBooking.[MenuID], TempBooking.[Product],TempBooking.[Price], TempBooking.[Qty], TempBooking.[Total] FROM TempBooking;"
When the query runs it seems to try to add records from the temporary table into gaps in the Autonumber field in the main table and not onto the end of the table. The gaps are where records in the main table have been deleted. Say there is a gap of three numbers in the Autonumber ID field. The query will add three records into the gap and then throw up a key violation error when it then tries to add a duplicate ID number.
How do I ensure that the append query adds records to the END of the table?? Please help!
(afterthought - I suppose I could open the main table as a recordset and cycle through the temporary table adding records but that isn't very neat.)
DoCmd.RunSQL "INSERT INTO [Main Booking Subdata] ( BookingID, MenuID, Product, Price, Qty, Total ) SELECT TempBooking.[BookingID], TempBooking.[MenuID], TempBooking.[Product],TempBooking.[Price], TempBooking.[Qty], TempBooking.[Total] FROM TempBooking;"
When the query runs it seems to try to add records from the temporary table into gaps in the Autonumber field in the main table and not onto the end of the table. The gaps are where records in the main table have been deleted. Say there is a gap of three numbers in the Autonumber ID field. The query will add three records into the gap and then throw up a key violation error when it then tries to add a duplicate ID number.
How do I ensure that the append query adds records to the END of the table?? Please help!
(afterthought - I suppose I could open the main table as a recordset and cycle through the temporary table adding records but that isn't very neat.)