Bill Benson
vbacreations at gmail.com
Fri Mar 7 16:07:35 CST 2014
Try this instead and I believe if your system is like mine, you will see the default behavior IS AN ERROR. Sub Test() Dim MyDB As DAO.Database Set MyDB = CurrentDb With MyDB On Error Resume Next .Execute "DROP TABLE [A];" .Execute "DROP TABLE [B];" .Execute "CREATE TABLE [A] (ID AUTOINCREMENT NOT NULL PRIMARY KEY, Field2 TEXT);" On Error GoTo Get_Out .Execute "CREATE TABLE [B] (ID LONG, Field2 TEXT);" .Execute "INSERT INTO B (ID, FIELD2) VALUES (-2147483648,'DELETEME');" .Execute "INSERT INTO B (ID, FIELD2) VALUES (2147483647,'DELETEME');" .Execute "INSERT INTO A SELECT * FROM B;" .Execute "DELETE FROM [A] WHERE ID =2147483647;" On Error Resume Next .Execute "INSERT INTO A (FIELD2) VALUES ('NewVal');", dbFailOnError If Err.Number <> 0 Then MsgBox "Error occurred:" & Chr(13) & _ Err.Number & " " & Err.Description .Execute "DROP TABLE [B];" End With Get_Out: Set MyDB = Nothing End Sub