I've read other threads in this forum to do with key violations, but none of them help me with my particular problem.
I import data from a text file into a temporary table in my Access database. I use a temporary table because the number of columns and titles in my text file do not match the Access target table. So, I thought I'd use an append query to transfer some of the columns and all of the rows from my source table (the temporary imported data table) to the target table.
My target table has a primary key that is autonumber, but the append query does not try to add anything into this field - meaning I let Access fill in this field by itself. The temporary source table does not have a primary key. Still, when I run the query, I get the key violation message and no records are appended. I narrowed the problem down to one field in my target table, called MsdnID. This is not an autonumber field or a primary key - it's a regular text field with indexing set to "Yes (duplicates ok)". The append query tries to append data from one of the source fields (a text field). When I remove the column in the query that tries to append to the target MsdnID field, the append query works, appending data for all fields except MsdnID, which is left blank. MsdnID is a field that I use to set relationships between several tables. As mentioned, in the target table, MsdnID is not a primary key and allows duplicate values. However, in another table (not directly referenced by the append query), MsdnID is a primary key.
When the append query didn't work, I thought I needed to specify a join between my source and target tables. So, I added the target table to append query and added a join between the source field and MsdnID. I tried both the one-to-one join and the many-to-one join. Netiher worked. I still get the key violation message. I'm out of ideas.
How do I fix this? I don't understand why I get a key violation message when the target field isn't a primary key in the target table.
Thanks
I import data from a text file into a temporary table in my Access database. I use a temporary table because the number of columns and titles in my text file do not match the Access target table. So, I thought I'd use an append query to transfer some of the columns and all of the rows from my source table (the temporary imported data table) to the target table.
My target table has a primary key that is autonumber, but the append query does not try to add anything into this field - meaning I let Access fill in this field by itself. The temporary source table does not have a primary key. Still, when I run the query, I get the key violation message and no records are appended. I narrowed the problem down to one field in my target table, called MsdnID. This is not an autonumber field or a primary key - it's a regular text field with indexing set to "Yes (duplicates ok)". The append query tries to append data from one of the source fields (a text field). When I remove the column in the query that tries to append to the target MsdnID field, the append query works, appending data for all fields except MsdnID, which is left blank. MsdnID is a field that I use to set relationships between several tables. As mentioned, in the target table, MsdnID is not a primary key and allows duplicate values. However, in another table (not directly referenced by the append query), MsdnID is a primary key.
When the append query didn't work, I thought I needed to specify a join between my source and target tables. So, I added the target table to append query and added a join between the source field and MsdnID. I tried both the one-to-one join and the many-to-one join. Netiher worked. I still get the key violation message. I'm out of ideas.
How do I fix this? I don't understand why I get a key violation message when the target field isn't a primary key in the target table.
Thanks