Check for Data

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm importing a file into a temporary table and after some updates to the
data, I append it to another table. What is the best way to check if data in
Field1 in TableTemp is already in Field1 in TableAppend.
 
Why do you care?

Are you saying that you want to know which records are already in
TableAppend, so you don't add them twice? If so, what you're really after
is a way to only add records from Temp to Append that aren't in Append
already.

A couple ways to do this: 1) put a Unique Index on the field you don't want
duplicated - Access will reject any record(s) that matches on that index;
2) create a query that finds records in one not in the other (e.g.,
"unmatched query")- use that to determine which records to add.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
Sash said:
I'm importing a file into a temporary table and after some updates to the
data, I append it to another table. What is the best way to check if data in
Field1 in TableTemp is already in Field1 in TableAppend.


Use a query that Joins the two tables ala the Find Unmatched
query wizard.

SELECT . . .
FROM table INNER JOIN temp
ON table.field1 = temp.field1

will return only records that have a field1 in common.

SELECT . . .
FROM temp LEFT JOIN table
ON table.field1 = temp.field1
WHERE table.field1 Is Null

will return records in temp that are not in table.
 
Thank you Jeff. Makes sense.

You are correct on why I care. The user is loading data from a disk into
the temporary table. The user may mistakenly load the same disk more than
once and I don't want duplicate records in my TableAppend.
 
Back
Top