Results 1 to 8 of 8
  1. #1
    breezett93 is offline Advanced Beginner
    Windows 7 64bit Access 2013 64bit
    Join Date
    Feb 2017
    Posts
    56

    Query that only adds new data

    I'm working on a query that will copy one column from table A to table B when a button is clicked. For efficiency, I'd like only new data added instead of copying every single value every time.

    This is what I've started with.

    UPDATE tableB


    INNER
    JOIN tableA
    ON tableA.columnName = table2.columnName
    SET tableB.columnName = table1.columnName
    WHERE tableB.columnName = 'columnName'

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    you have an update query.
    queries that Add data are called append queries....
    INSERT INTO TABLE ...

  3. #3
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    In your query SQL, if "columnName" is what it looks like, i.e. the same everywhere, that query won't work. You are using the same field you want to update as you are using to define the join, which makes no sense; the join won't select the records you need because the data isn't there yet.

    It would be more helpful if you posted the SQL with the actual field names.

  4. #4
    breezett93 is offline Advanced Beginner
    Windows 7 64bit Access 2013 64bit
    Join Date
    Feb 2017
    Posts
    56
    you have an update query.
    queries that Add data are called append queries....
    INSERT INTO TABLE ...
    So I am looking for something like:

    INSERT INTO tableB (columnName)
    Select columnName
    From tableA
    //Where only data that hasn't already been inserted is inserted

  5. #5
    breezett93 is offline Advanced Beginner
    Windows 7 64bit Access 2013 64bit
    Join Date
    Feb 2017
    Posts
    56
    Quote Originally Posted by John_G View Post

    It would be more helpful if you posted the SQL with the actual field names.
    Certainly. ranman mentioned I should use an append query. So now I'm looking at:

    Insert into IvcTbl (Promise Date)
    Select Promise Date
    From OrdTbl
    //Where only data that hasn't been inserted yet is appended

  6. #6
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Use the Query Wizard to create an Unmatched query - this will find records on one table/query which do not exist on a second table/query. Then in design view change it to an Append query.

  7. #7
    breezett93 is offline Advanced Beginner
    Windows 7 64bit Access 2013 64bit
    Join Date
    Feb 2017
    Posts
    56
    Quote Originally Posted by aytee111 View Post
    Use the Query Wizard to create an Unmatched query - this will find records on one table/query which do not exist on a second table/query. Then in design view change it to an Append query.
    Here is what Access gave me after doing what you suggested:

    SELECT OrdTbl.ShpDt
    FROM OrdTbl LEFT JOIN IvcTbl ON OrdTbl.[OrdId] = IvcTbl.[OrdId]
    WHERE (((IvcTbl.OrdId) Is Null));

    You're saying I need to just swap out SELECT for INSERT INTO? Why is the Where clause like that? I don't want blank orders.

  8. #8
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Change the query type to Append, either under Design at the top or right-click in the empty gray space - don't try and do it manually.

    Access created the query for you, why don't you believe it?

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

Similar Threads

  1. Replies: 4
    Last Post: 05-09-2013, 05:56 AM
  2. update query that adds 8.25% taxes
    By alinapotter in forum Queries
    Replies: 2
    Last Post: 04-09-2013, 07:59 AM
  3. Query adds record to table?!?
    By dantejazz in forum Queries
    Replies: 9
    Last Post: 03-11-2012, 08:58 PM
  4. Replies: 2
    Last Post: 12-20-2011, 10:09 AM
  5. Tab adds new record
    By xionhack in forum Forms
    Replies: 2
    Last Post: 06-14-2011, 01:17 AM

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