ACC2000: Append Query Results in Duplicate AutoNumbersID: Q209710
|
Moderate: Requires basic macro, coding, and interoperability skills.
A table to which you append data by using an append query now has duplicated numbers in a field defined as an AutoNumber data type in
Microsoft Access. The expected result is appended data with incremented numbers in the AutoNumber field.
Your append query is explicitly referencing the field with the AutoNumber data type. You are, in essence, overriding the automatic AutoNumber that you specified in your table design. This may result in duplicate numbers.
When creating the append query, do not include a field with an AutoNumber data type in the Append To row of the QBE grid. By omitting this field in your append query, Access will automatically generate incremental numbers in the table's AutoNumber field.
CAUTION: Following the steps in this example will modify the sample
database Northwind.mdb. You may want to back up the Northwind.mdb file
and perform these steps on a copy of the database.
You will receive duplicates only if there is no Primary Key or Index (No Duplicates) defined in the AutoNumber field in the table to which you are
appending. By definition, primary keys are unique.
Including fields with AutoNumber data types in your append query may also result in noncontiguous numbers in the table to which you are appending. For example, if the table to which you are appending has values of 1 to 20 in the AutoNumber field, and the table from which you are appending has values of 20, 34, and 55, you will end up with one duplicate value. The next time you add a new row to the table to which you are appending, the AutoNumber field will be assigned a value of 56.
Additional query words: prb
Keywords : kbusage kbdta QryMktbl
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbprb
Last Reviewed: May 13, 1999