Append table without duplicate value

Posted on 2009-12-17
Last Modified: 2013-11-29
I am using the following codes to append table 1 to table 2.

CurrentDB.Execute "INSERT INTO tbl_Data2 (field1, field 2, field 3) SELECT [Valume1], [Valume 2], [Valume 3] FROM tbl_Data1", dbFailOnError

But it creates duplicate data in table 2. How can I set filter to append only record that have field 1 and filed 2 are not into table 2?

Question by:rowfei
    LVL 119

    Accepted Solution


    test this

    INSERT INTO tbl_Data2 ( Field1, field2, field3 )
    SELECT tbl_Data1.[valume 1], tbl_Data1.[valume 2], tbl_Data1.[valume 3]
    FROM tbl_Data1 LEFT JOIN tbl_Data2 ON (tbl_Data1.[valume 1] = tbl_Data2.field1) AND (tbl_Data1.[valume 2] = tbl_Data2.field2)
    WHERE (tbl_Data2.field1) Is Null AND (tbl_Data2.field2) Is Null
    LVL 30

    Expert Comment

    What are you waiting for, didn't capricorn1's comment solve your problem!

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
    A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
    In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now