Append Query duplicate primary key

Mase5701

New Member
Joined
Dec 19, 2018
Messages
6
If I run an append query will it give me an error message if duplicates primary key field?

I have an append query in my database and when I run nothing happens and it doesn't append but it doesn't give me a warning. I gotta figure this out before I start embedding it into macros because if it fails without warning how am I supposed to know?
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
If I run an append query will it give me an error message if duplicates primary key field?
If you want to see exactly what happens, the best thing to do is create a test situation like that, and see what happens.

Another thing you can do is to create an exact replica of your Append Query, but then change it to a Select query.
Get the count of your final destination table (can use an Aggregate Query or the DCOUNT function in VBA).
Then, get the count of your Select query.
Then, run your Append query.
And get another count of your final destination table.
Compare your counts. If the final number of records minus the count from your Select query does not equal your original count, then some Append records failed.

Of course, you could also do a Select query on your same logic as your Append query, and see if any of those records have the same ID as the records in your destination table.
Get the count of that. And then you could add that check to VBA and return a message, so you can alert the user before running the Append query.

So, there are multiple ways of approaching this (I am sure that there are probably other approaches too).
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,823
Members
449,049
Latest member
cybersurfer5000

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top