APPEND Data without duplicated data

S

Santiago

Hey guys, maybe it is a silly question, but I don't know that much of ACCESS...

How can I append data to a Table checking if the new data is already in the
table?
I mean, I want to avoid duplicated data based on only some fields, not all
of them.

Is this possible?

Thanks. Bregards

Santiago
 
J

Jerry Whittle

Make the combination of the fields that make the record unique either the
primary key or a unique index. Access will not let you append any duplicate
records that way.

Or you could write a fancy query with a subquery that first checks if the
data is not already in the table. This could be very slow depending on the
number of records in the table.
 
S

Santiago

Thanks Jerry. Seems it would work.

But will it display an error message or it will not add the repeted records
to the database?

I guess I can just try ...
 
J

Jerry Whittle

Good question! The default behavior of Access it to throw up an error message
and if you say OK Access allows in the records that do not violate the
constraint. You can stop the irritating error message by setting warnings
off, doing the append, and setting warnings back on. Don't forget to set
warnings back on! You can do this in code or even a macro.
 
Top