Ignore keyviolation in appendquery

  • Thread starter Thread starter John J.
  • Start date Start date
J

John J.

In code I run several appendqueries starting with docmd.setwarnings = false.
Due to keyviolation Access does give me a warning/error. But I do want the
non key-violating values to be added, without the error message.

Is this possible?
Thank you.
John
 
In code I run several appendqueries starting with docmd.setwarnings = false.
Due to keyviolation Access does give me a warning/error. But I do want the
non key-violating values to be added, without the error message.

Is this possible?

Only by removing the constraint in the table.

Why would you want to have a rule prohibiting invalid data, and then turn
around and add invalid data? Either remove the rule, or fix the data; you
can't have it both ways!
 
John:

Are you calling the Execute method with the dbFailOnError option? If you
instead call the OpenQuery method then rows which don't violate the key
should be inserted into the table.

Ken Sheridan
Stafford, England
 
Thanks Ken. That dit it!

Ken Sheridan said:
John:

Are you calling the Execute method with the dbFailOnError option? If you
instead call the OpenQuery method then rows which don't violate the key
should be inserted into the table.

Ken Sheridan
Stafford, England
 
The *non* key-violating data is not invalid.

John W. Vinson said:
Only by removing the constraint in the table.

Why would you want to have a rule prohibiting invalid data, and then turn
around and add invalid data? Either remove the rule, or fix the data; you
can't have it both ways!
 
You could modify the source query to eliminate the invalid data. Then the
insert should work as expected.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top