Results 1 to 3 of 3
  1. #1
    krausr79 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    16

    Update existing and append new

    I feel like this must be at least somewhat common, but I can't get the wording right to google it. I have two tables with 2 key fields and one data field. From one table to the other, I'd like to update the data field if the keys exist and append the record if it doesn't. I could use query(s) builder or SQL. Example:

    Temp table:
    Key1 Key2 Data
    1 2 Hi


    4 3 Hello

    Main table:
    Key1 Key2 Data
    1 2 Hola
    4 5 Tag

    After update:
    Main table:
    Key1 Key2 Data
    1 2 Hi
    4 3 Hello
    4 5 Tag

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    You will need to use two queries in order to do this (Access doesn't have an "Upsert" function).

    First do an UPDATE Query to update any existing records.
    Then do an APPEND Query to insert any new records.

  3. #3
    krausr79 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    16
    Ok. I created two queries joined at the key values and did updates where not null and appends where null.

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

Similar Threads

  1. Replies: 3
    Last Post: 10-04-2015, 10:17 AM
  2. Replies: 7
    Last Post: 06-05-2015, 11:13 AM
  3. Append to existing records only
    By barkly in forum Queries
    Replies: 1
    Last Post: 08-29-2013, 11:25 AM
  4. Replies: 3
    Last Post: 08-28-2012, 02:27 PM
  5. Replies: 2
    Last Post: 05-21-2012, 08:46 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