Results 1 to 5 of 5
  1. #1
    alfranco17 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Oct 2012
    Posts
    5

    Problem with keys in update query.

    Hi.

    I have two tables, t_transactions and temp_t_transactions. I created temp_t_transactions by copying the structure of t_transactions. Primary key is field "id_trans" and is an autonumber. Both are permanent tables.

    I want the user to work on the temp_t_transactions table, and when ready, copy that info to t_transactions, which is the permanent database. When I try to run the following query, I keep getting an error message that says there it "didn't append 1 record to the table due to key violations". I am not including the key field for either table in the SQL code. This is the code. It works fine the first time I run it, when t_transactions is empty, but fails when it has even a single record.

    INSERT INTO t_transactions ( id_trans_type, id_product, f_quantity, id_locación, effdate, actdate, id_user, id_po, id_so, id_inv, f_comments )
    SELECT 'TRANSFER' AS f_trans_type, temp_t_transactions.id_product, temp_t_transactions.f_quantity, temp_t_transactions.id_locación, temp_t_transactions.effdate, Now() AS actdate, 'AFRANCO' AS id_user, temp_t_transactions.id_po, temp_t_transactions.id_so, temp_t_transactions.id_inv, temp_t_transactions.f_comments


    FROM temp_t_transactions;

    Any help will be greatly appreciated.

    Thanks.
    Armando.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    I tested your query on tables I built following your structure. Can't replicate issue. Want to provide db for analysis? Follow instructions at bottom of my post.

    Why this 'temp' table setup?
    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
    alfranco17 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Oct 2012
    Posts
    5

    Red face It worked!

    Thanks a lot, June. When following your instructions to share the database, I ran "Compact and repair", and now it works! I guess that's what was missing.

    I am using the temp table because I want the user to add records in one place, and then, when they are correct, transfer them to the good table.

    How often should I run "compact and repair"?

    Thanks again! I had spent three hours trying to figure it out.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Run C&R definitely after design modifications as they cause increased file size or whenever you encounter odd behavior like you experienced. You can set the db to run C&R everytime it closes.
    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.

  5. #5
    alfranco17 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Oct 2012
    Posts
    5

    Thumbs up Great.

    Quote Originally Posted by June7 View Post
    Run C&R definitely after design modifications as they cause increased file size or whenever you encounter odd behavior like you experienced. You can set the db to run C&R everytime it closes.
    Thanks! I will set it up like that.

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

Similar Threads

  1. Update Query problem
    By Reaper in forum Queries
    Replies: 7
    Last Post: 11-17-2011, 07:10 AM
  2. double update query problem
    By tss in forum Queries
    Replies: 9
    Last Post: 11-04-2011, 08:50 AM
  3. Update query problem
    By pratim09 in forum Queries
    Replies: 5
    Last Post: 05-05-2011, 06:05 AM
  4. Problem with Update Query?
    By emarchant in forum Access
    Replies: 7
    Last Post: 10-08-2010, 12:51 PM
  5. Update Query problem
    By sollem1 in forum Queries
    Replies: 0
    Last Post: 11-08-2007, 10:16 AM

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