SetWarnings

C

Charles

I am running an append query from a button. I have turned the warnings off
so that the user dosn't have to respond to the default popups. The problem
is that when the user tries to append duplicate data to the table, the
SetWarnings settings prevents me from trapping this error. Is there a way
to handle the default popups without using the SetWarnings method so that I
can trap this error.

Thank you
 
S

Steve Schapel

Charles,

Can't be specific without knowing more details of what you are doing.
But you should be able to compare the existing data in the table with
the data that the Append Query's data, and identify any duplicates. This
can be done before running the append, and only have your code proceed
to run the append query if the conditions are satisfied.
 
T

tina

instead of using DoCmd.OpenQuery to run your Append query, you can use

CurrentDb.Execute "the entire SQL string here", dbFailOnError

*without* the DoCmd.SetWarnings code. add error handling code to trap error
3022.

note that while OpenQuery, with the warnings turned off, will add all
non-duplicate records and discard the duplicates without adding, Execute
will err out when the unique key is violated and not add *any* records at
all, even the non-duplicate records. that may work fine for your process;
you just need to be aware of the difference in the two methods.

hth
 

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