Trap erros with Docmd.RunSQL

rockies1

King Cobra
Local time
Today, 03:35
Joined
May 21, 2001
Messages
38
I am tryng to take the records from one table and insert them into another using a recordset and Docmd.RunSQL "INSERT..."

I don't want the "You are about to insert 1 row..." so I can use Docmd.SetWarnings False but I DO need to know if the record won't insert due to violating the unique key on the table.

Any suggestions?

Morgan
 
Code:
docmd.SetWarnings False
docmd.RunSQL
docmd.SetWarnings True
 
When I do that, I get no notification of the inability to insert the record.
 
I don't think it can be done. As far as I'm aware, they're both warning messages, and as such you can only turn them all on or off.

Not selective messages.

I would be happy to be proved wrong though!:D
 
Surely you'd still get a PasteErrors style table. I don't know for sure, though. You may, if this does happen, be able to check for the existence of the table, display a message highlighting the fat that there were errors, and then delete the table.
 
DAO
There is the CurrentDb.Execute function.

ADO
You could use a ADODB.Command Object to execute the Insert Query
 

Users who are viewing this thread

Back
Top Bottom