Microsoft Access Didn't Add Records Due To Key Violations

guyuz

New member
Local time
Tomorrow, 00:38
Joined
Apr 2, 2014
Messages
9
[SOLVED] Microsoft Access Didn't Add Records Due To Key Violations

Hello,
I have a table called tblTarget, with 3 fields: Autonumber ID, Number F1, Number F2. F1 and F2 are indexed, allow duplicates, and are not required.
I'm trying create an append query. SQL code is the following:
Code:
Insert into tblTarget
SELECT *
FROM (
Select 1 as F1, 1 as F2 from onerow)
-onerow is a dummy table.

When I run the query, I receive the error in the title: Microsoft Access Didn't Add 1 Record(s) Due To Key Violations.
I've tried many syntaxes for the query, they all supposedly work, but they lead to this error.

For any questions or requests, I'm here. Thank you for your time.

EDIT: Problem solved, solution in my last comment
 
Last edited:
Open the table tblTarget in design view, look if it has more as one Index.
 
Open the table tblTarget in design view, look if it has more as one Index.

If I understand correctly what you are asking, all 3 fields (Primary Key, F1, F2) have indexes ("Yes (Duplicates OK)"). However, I've already tried tampering with the Indexed property of the fields F1 and F2, with all combinations of Yes (Duplicates OK)/No. I still receive the exact same error.
 
Does the index look like in the picture, (but why do you have a index on "F1" and "F2" if you use a autonumber for ID)?
attachment.php
 

Attachments

  • Index.jpg
    Index.jpg
    21.6 KB · Views: 3,388
Does the index look like in the picture, (but why do you have a index on "F1" and "F2" if you use a autonumber for ID)?

To be honest, I don't know how indexing works/for what it is used, and having indexing on all fields was the default (IIRC).

Anyway, I removed the indexes for F1 and F2. It doesn't seem to solve the problem, though.

EDIT: Found the solution, it was a mistake on my part: tblTarget's F1 and F2 fields were in a relationship with another table,and I accidentally tried to append values of F1 and F2 which didn't exist in that other table.
PS: I'd like to change the title tag to "Solved", how do I do that?
 
Last edited:
Good you found the problem. :)
In top of your first post, (see picture):
attachment.php
 

Attachments

  • Solved.jpg
    Solved.jpg
    22.5 KB · Views: 3,335

Users who are viewing this thread

Back
Top Bottom