INSERT INTO qry - duplication

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Sorry if this is answered elsewhere - looked but couldn't find

I have inherited a db, one part of the vba code of which updates a table using an INSERT INTO query, gathering info from a second table. The SELECT part of the query definitely produces records which duplicates entries in the primary key fields already in the first table

My question is, what SHOULD happen when this code is run? It seems to be cheerfully dropping all duplicates and only inserting new records, with not a flicker of an error, but I thought it should try to insert the duplicates and then cause an error because of the primary key. Have I misunderstood

Thx in advance for all assistance

Eri
P.S. I know that this has no mention of forms - sorry! If there's a more appropriate forum for this question, can somebody point me in the right direction?
 
If you wish to be notified of errors and interrupt the process, try:
Dim strSQL As String
strSQL = "INSERT INTO ..."
dbEngine(0)(0).Execute strSQL, dbFailOnError

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Eric said:
Sorry if this is answered elsewhere - looked but couldn't find.

I have inherited a db, one part of the vba code of which updates a table
using an INSERT INTO query, gathering info from a second table. The SELECT
part of the query definitely produces records which duplicates entries in
the primary key fields already in the first table.
My question is, what SHOULD happen when this code is run? It seems to be
cheerfully dropping all duplicates and only inserting new records, with not
a flicker of an error, but I thought it should try to insert the duplicates
and then cause an error because of the primary key. Have I misunderstood?
Thx in advance for all assistance,

Eric
P.S. I know that this has no mention of forms - sorry! If there's a more
appropriate forum for this question, can somebody point me in the right
direction?
 
Back
Top