INSERT queries complete but some records are missed

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

Guest

I have a VBA sub that loops through iterations that:

a) copies some tables from the current database to another target one
b) runs INSERT queries in the target database to update the main tables with
info from the copied tables

The tables are copied ok, but the INSERT queries don't always insert all the
records. The queries are written as:

INSERT INTO big_table SELECT * FROM small_table AS E WHERE NOT EXISTS
(SELECT * FROM big_table AS O WHERE O.part_ID=E.part_ID) ORDER BY date;

and the VBA to copy the table and run the query is:

DoCmd.TransferDatabase acExport, "Microsoft Access", strPathSource, acTable,
strOldName, strNewName, False

DBStarget.QueryDefs(strQueryToRun).Execute

Does anyone see something here that could be causing this problem? Thanks.
 
Could you try to run it as
DBStarget.QueryDefs(strQueryToRun).Execute(dbFailOnError) and see if that
makes a difference?
 
Back
Top