Ignore keyviolation in appendquery

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
 
J

John W. Vinson

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!
 
K

Ken Sheridan

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
 
J

John J.

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
 
J

John J.

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!
 
P

Paul Shapiro

You could modify the source query to eliminate the invalid data. Then the
insert should work as expected.
 
Top