Run-time error '3022' - Suppress it? (1 Viewer)

Moxioron

Registered User.
Local time
Today, 01:20
Joined
Jul 11, 2012
Messages
68
Hello.

I am using the following code to run an append query on another table

Dim db As DAO.Database
Set db = DBEngine.Workspaces(0).OpenDatabase("R:\DEPT-BR\CONSUMER LENDING\Marketing Campaigns\2015\2015 Auto Prequal Campaigns\August 31 Mailing\Auto Loan Prequalification - August 31 2015.accdb")
db.Execute "qry_08312015 Auto Loan Prequal Results - Append", dbFailOnError
Set db = Nothing


It works great .... except when it finds dupes. I have two fields in the table the data is appending to as the primary keys to obviously prevent dupes, but some of the records in the append are not duplicates.

So my ?s

1.) Does this Run-time error prevent all records from being appended or just the dupes?
2.) How can I suppress the error? I tried DoCmd.SetWarnings False to no avail.

Thanks.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 01:20
Joined
Aug 30, 2003
Messages
36,118
Try leaving off

, dbFailOnError

It should append everything but the dupes. I use this method in a situation where there may or may not be dupes and I don't care (it's on purpose).
 

Moxioron

Registered User.
Local time
Today, 01:20
Joined
Jul 11, 2012
Messages
68
You are a genius my friend.

So will the append query still bring in any records that are not duplicates? I ran it this morning and I did not receive the error message, but I had no new records so I can't tell if it will bring in new records.

Thank you.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 01:20
Joined
Aug 30, 2003
Messages
36,118
It does for me. Make a copy of the db and delete some records that should get appended and see if they do. I just checked the old db that uses this method all day long, and it uses OpenQuery rather than Execute, but I wouldn't expect that to matter. If it still doesn't work for you, switch and see if OpenQuery does (or is that a different db?). Mine looks like:

DoCmd.SetWarnings False
DoCmd.OpenQuery "qapp_Daily_charter_de"
DoCmd.SetWarnings True

The original designer loved his underscores; they drive me batty.
 

Users who are viewing this thread

Top Bottom