INSERT queries complete but some records are missed

S

spud

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.
 
D

Dirk

Could you try to run it as
DBStarget.QueryDefs(strQueryToRun).Execute(dbFailOnError) and see if that
makes a difference?
 

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

Top