Results 1 to 4 of 4
  1. #1
    ChrisNWV is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2012
    Posts
    7

    Query to update a table

    I am comparing two tables (ComparisonTable2 & NewChanges). The primary


    key is AppReg. I am able to compare them and make changes by the
    comparison, however, I want to update ComparisonTable2 with the new
    information from the NewChanges table. A change will only occur if during
    the comparison an AppReg is in the Newchanges table but not in the
    ComparisonTable2. I know I am close to the answer. Everytime I run
    the below code it is asking me for a parameter. When I remove the
    last line of code it simply copies all of the data from NewChanges
    into ComparisonTable2. Any assistance would be greatly appreciated.

    INSERT INTO ComparisonTable2 ( AppReg, Manufacturer )
    SELECT NewChanges.[AppReg], NewChanges.[Manufacturer]
    FROM NewChanges
    WHERE NewChanges.AppReg <> ComparisonTable2.AppReg;

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Try:

    WHERE NewChanges.AppReg Not In (SELECT AppReg FROM ComparisonTable2);
    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.

  3. #3
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    Code:
    INSERT INTO ComparisonTable2 ( AppReg, Manufacturer )
    SELECT NewChanges.AppReg, NewChanges.Manufacturer
    FROM NewChanges 
    WHERE NewChanges.AppReg NOT IN 
    (SELECT ComparisonTable2.AppReg FROM ComparisonTable2);
    Hah! June beat me!

  4. #4
    ChrisNWV is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2012
    Posts
    7
    THANK YOU!!!
    It worked fine!!!

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

Similar Threads

  1. Replies: 1
    Last Post: 05-17-2013, 12:53 PM
  2. Update query won't update table
    By bonesie in forum Access
    Replies: 6
    Last Post: 01-15-2013, 05:22 PM
  3. Replies: 6
    Last Post: 05-10-2012, 08:20 PM
  4. Replies: 1
    Last Post: 02-08-2012, 04:50 PM
  5. Replies: 2
    Last Post: 12-20-2011, 07:33 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