Results 1 to 9 of 9
  1. #1
    kroenc17 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Sep 2010
    Location
    Albany, NY
    Posts
    49

    append query

    Hello all,



    I'm trying to make a query that will append data from one table into another table. I've done this successfully, however I only want to append entries that have a new update. If a row is the same as it was before, I don't want it to be appended to the new table.

    For example: My first table is a list of ongoing projects. One project may have an update added to a field, but another project may not. Right now my query is appending every row to the new table whether or not it is the exact same as it was previously (aka no updates, nothing new).

    How do I ONLY APPEND NEW INFORMATION?

  2. #2
    Rixxe is offline Blessed Bear
    Windows 7 Access 2007
    Join Date
    Sep 2010
    Location
    London (Essex ... yep!)
    Posts
    184
    If you have a primary key, Say an ID like '0001'

    And you append a table with another entry like '0001' and '0002' it won't append '0001' but will add '0002'.

    So basically select a field to be a primary key, like an ID.

    Good luck

  3. #3
    kroenc17 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Sep 2010
    Location
    Albany, NY
    Posts
    49
    I added the Primary Key ID field from the table that is being appended to to my query and when I tried running it I got an error saying that all rows could not be updated because of primary key violations. I also tried it the other way around ... appending the Primary Key ID field from the original table to the new table, and got the same error.

    Can you walk me through your suggestion with a bit more detail? Thanks for the help

  4. #4
    Rixxe is offline Blessed Bear
    Windows 7 Access 2007
    Join Date
    Sep 2010
    Location
    London (Essex ... yep!)
    Posts
    184
    Well as far as i remember:

    If you have a table with results from QueryA, You then change the ID to be a primary Key.
    When you append the results of QueryB to the table with QueryA results, you should only be able to append the rows which have different ID's.

    Please note, the fields will have to be exact. (Same type, same size, etc)

    There may be other requirements, but i can't remember them at the moment.

    Hope this is helpful. However in the case that it isnt, you might want to discover other way's (Or wait for other peoples replys.)

    Good luck

  5. #5
    Rixxe is offline Blessed Bear
    Windows 7 Access 2007
    Join Date
    Sep 2010
    Location
    London (Essex ... yep!)
    Posts
    184
    I forgot to mention, that if the ID is duplicated (In some databases it happens) Then this will fail horribly, as the ID/Primary key has to be unique.

  6. #6
    kroenc17 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Sep 2010
    Location
    Albany, NY
    Posts
    49
    Both tables primary key is already an AutoNumber ID field ... I've tried appending that field into the second table but whether I append it from itself or from the previous table I get the above error message.

    Thanks for the help, I'll continue hacking away ... any other suggestions? Is this possible to do?

  7. #7
    Rixxe is offline Blessed Bear
    Windows 7 Access 2007
    Join Date
    Sep 2010
    Location
    London (Essex ... yep!)
    Posts
    184

  8. #8
    kroenc17 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Sep 2010
    Location
    Albany, NY
    Posts
    49
    Access kills me. I'm working off of that link trying to use the Query Wizard to create an Unmatched Query ...

    it asks "Select the matching field from each table."

    it does not list all of the fields in either table.

    the fields it does not list are the matching fields.

  9. #9
    Rixxe is offline Blessed Bear
    Windows 7 Access 2007
    Join Date
    Sep 2010
    Location
    London (Essex ... yep!)
    Posts
    184
    Did the append query work then?

    Unmatched queries can be done better with SQL code:

    Code:
    Select a.*
    From TableA as a
    Left outer Join TableB as b
    on a.ID=b.ID
    where b.ID is null
    
    If i made a mistake with the syntax don't hate me, just wrote it in 2 seconds.

    Regards

    Rixxe

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

Similar Threads

  1. append query help
    By SlowPoke in forum Access
    Replies: 2
    Last Post: 09-25-2010, 10:47 AM
  2. append query
    By w_kenny in forum Access
    Replies: 2
    Last Post: 08-24-2010, 05:48 AM
  3. Append Query (Maybe VBA?)
    By justinwright in forum Queries
    Replies: 14
    Last Post: 07-21-2010, 10:31 AM
  4. Append query won't append
    By yelkenli in forum Queries
    Replies: 5
    Last Post: 02-12-2010, 11:19 AM
  5. Append Query
    By aabh in forum Queries
    Replies: 6
    Last Post: 02-02-2010, 04:26 PM

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