Compare and append

J

Johny

Hi there!

I'm new to access vba development and perhaps you could help me in here:

I am comparing to tables (table1, table2). If it happens that there are
records which are in table1 that are *not* in table2 then I want to append
that record in table2.

Could someone explain me the code to achieve this?

Thank you ever so much!

Johnny
 
M

Marshall Barton

Johny said:
I'm new to access vba development and perhaps you could help me in here:

I am comparing to tables (table1, table2). If it happens that there are
records which are in table1 that are *not* in table2 then I want to append
that record in table2.

Could someone explain me the code to achieve this?


Assuming the primary key field in table1 is retained in
table2, just insert the new records using an unmatched type
query:

INSERT INTO table2
SELECT *
FROM table1 INNER JOIN table2
ON table1.pkfield = table2.pkfield
WHERE table2.pkfield Is Null
 

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