Connecting Tech Pros Worldwide Help | Site Map

append query - nonduplicate records

Member
 
Join Date: Mar 2008
Posts: 79
#1: Nov 26 '08
OK, I am pulling my hair out on this one. It seems like it should be so simple and I cannot seem to find the answer.

I am using Access 2000 on Windows 2000.

I have two tables set up. Table One is updated Daily, Table Two is going to keep a running tally of Data.

What I need to do is add records form Table One into Table Two. However, I only want to add records that do not exist.

Here is the tricky part. The data in Table One is not identical to Table Two. I need to have it look at 6 columns in Table One and the same in Table Two. If they are Different (all six fields) then Add the record to Table Two.

I cannot find the correct sequence to write to make this happen.

I have tried playing with a regular query to show me the records that do not match(non-duplicate). I can have it show me all files that do, but cannot figure out how to show records that do not match.

The Matching fields are all text fields. Some have numbers, but because of the information they need to saved as text.

Any help is greatly appreciated. Any questions about the information please do not hesitate to ask. Thank you in advance for your help.

Nick
Expert
 
Join Date: Jul 2008
Location: Maryland
Posts: 1,158
#2: Nov 26 '08

re: append query - nonduplicate records


You need to use the EXISTS SQL condition, or the NOT EXISTS actually. There are some examples here:
SQL: EXISTS Condition

So something like

SELECT * FROM Table1 WHERE NOT EXISTS _
(SELECT Column1, Column2, Column3, Column4, Column5, Column6 _
FROM Table2 Where _
Table2.column1 = Table1.column1 AND Table2.column2 = Table1.column2 AND Table2.column3 = Table1.column3 AND Table2.column4 = Table1.column AND Table2.column5 = Table1.column5 AND Table2.column6 = Table1.column6)
Member
 
Join Date: Mar 2008
Posts: 79
#3: Dec 1 '08

re: append query - nonduplicate records


Thank you for that. That was exactly what I needed. I never new about "Exists" statement. I still have lots to learn!! Thank you for your help. Sorry for the delayed response. Off work for the weekend.
Reply

Tags
append, duplicate, query


Similar Microsoft Access / VBA bytes