keeping duplicate records from being appended

G

Guest

How can I prevent duplicates from being appended (on the fly via an append
query)

to a table when the type of duplicates I want to prevent are entire record

duplicates not just one-field-duplicates. (IOW: it's ok for all field 1
values to

include duplicates and it's ok for all field 2 values to include duplicates
but I

don't want the append query to be able to append records where field 1 and
field 2

are the same as field 1 and field 2 of another record.)....and

....when there is this type of duplicate I want the append action to fail

silently...so the user doesn't get an error. It just doesn't happen.


BACKGROUND INFO
I have an append query,activated by a button on a form (button runs macro
that

opens the append query) which appends records to a table. (There are three
fields:

name number, and color. Ultimately I need a list of numers and colors for
each

name..without duplicates. So I append all these fields for each record from
the

original table that underlies the form to a table (table B)with the append
query

...then a query whose properties are set to Unique Values = yes finds all the

numbers and colors for each name. This is the list without duplicates that I
need.)

If the user hits the button more than once (without changing data) there
will be

duplicate records appended to table B. It could get pretty long if people
get very

happy with that button. I want to avoid having a very big table B in my
database.

Thanks much
 
J

Jeff Boyce

Paul

One approach might be to create an index spanning the multiple fields you
don't want duplicated (Unique, no duplicates). When you run your append
query, you'll be informed that "n" records could not be added, blah, blah,
blah...

One way to prevent the warning is to turn the warnings off (either in a
macro or in code, SetWarnings = False).

WARNING! If you fail to turn the warnings back on after your append query,
Access will not tell you if something goes wrong. ALWAYS turn the warnings
back on!
 
G

Guest

I am trying to follow the help file. SetWarnings vba code works but, since I
want to have the warnings turned back on after code runs I am interested in
another part of that help file:

quote: To temporarily stop the display of warning messages, set the
warningson argument to False. To resume displaying them, set the warningson
argument to True. endQuote

Can someone give me an example of how that would be written? (I'm getting
errors when trying to use:warningsON
Thanks
 
G

Guest

my newbieness was showing:
now I understand the WarningsOn argument is part of the setWarnings method.
 

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

Similar Threads


Top