Results 1 to 3 of 3
  1. #1
    lass9509 is offline Novice
    Windows 10 Office 365
    Join Date
    Jun 2020
    Posts
    1

    Avoiding duplicates when importing values

    Hello,



    I have this problem that when i import a list of values from excel into a data table, and when I at a later point want to update some values (another import, but with updates values), i get duplicates. I have tried to set a field as primary key, but that does not allow me to import values where the primary key appears.

    Can someone help me find a solution to my problem.

  2. #2
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    One way to do this is to first import the data into an empty "temp" table, whose structure is exactly the same as your data table.
    Then, create tqo action queries that do the following:
    1. Perform and unmatched query between the temp table and data table, and make that an Append Query to add the new records to the data table.
    2. Create a matched query between the temp table and data table, and make this an Update Query, updating the fields on the existing records that you need to do.

    You will also want a Delete Query to delete out the temp table either at the very beginning or the very end, so that it is empty before the next import.
    Once you set up the temp data and these 3 action queries, you may be able to create a Macro to do all the necessary steps with just one click.

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Can you set a link to the Excel?

    Review Gustav answer in https://stackoverflow.com/questions/...g-in-ms-access
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Normalization - Avoiding Null Values
    By toddaxsom in forum Access
    Replies: 4
    Last Post: 03-20-2016, 02:03 PM
  2. Replies: 2
    Last Post: 11-11-2013, 10:09 AM
  3. Avoiding entering duplicate values
    By djclntn in forum Forms
    Replies: 1
    Last Post: 01-25-2013, 11:51 AM
  4. Avoiding Duplicates - Concatenate Related?
    By WBosman in forum Access
    Replies: 10
    Last Post: 05-18-2011, 09:05 AM
  5. Avoiding duplicates in query
    By theracer06 in forum Queries
    Replies: 1
    Last Post: 08-24-2010, 12:49 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums