Results 1 to 4 of 4
  1. #1
    sh5mg is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2020
    Posts
    4

    Update a table using a calculated field in a query

    I have 2 tables:




    T1 - overall info regarding some transaction


    T2 - breakdown of the transaction by item and the status of where it is (currently "open" vs "closed")


    I have run a query that determines based on the status in T2, what the overall status of the transaction is in T1 (ie if there are 2 line items, and 1 is "open" and the other is "closed" the over all status is "open") -(i do this via iif- open-1 closed-0, sum them by ID, and then if >0, "open", otherwise "closed")


    I want to run an update query that updates the status column (linked by the ID),


    so far I have tried:


    UPDATE [T1] INNER JOIN [Query1] ON [Query1].[ID] = [T1].[ID] SET [Query1].[Overall Status] = [T1].[Overall Status];


    I always get the error "Operation must use an updateable query"


    Unfortunately, this is being done in ms Access, but any suggestions would be great!

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,898
    Saving calculated data, especially aggregate data, is usually unnecessary and bad design. If you can calculate it for UPDATE effort then can calculate when needed.

    Might be able to get the calculated result with DLookup() or DCount() expression in UPDATE query.

    Otherwise, will likely involve VBA code.
    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.

  4. #4
    Gicu's Avatar
    Gicu is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,114
    If you must update the field in the table you can do it using a temporary local table. Convert the Update query into a Make Table containing the ID and [Overall Status] or even better create the temp local table and use a Delete/ Append (with the Append having the calculation from the current Update one) sequence as Make Tables will bloat your db. Now create a new Update query using the temporary table and T1 that should be updateable. So you'll end up with a sequence of three queries (delete/append/update) instead of one update.

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

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

Similar Threads

  1. Replies: 7
    Last Post: 03-14-2018, 04:14 PM
  2. Calculated Field In Table-Query-MakeTable Issue
    By Lisa Perry in forum Access
    Replies: 2
    Last Post: 02-13-2013, 02:00 PM
  3. Replies: 3
    Last Post: 02-13-2013, 10:15 AM
  4. Update Query with a Calculated field
    By Lorlai in forum Queries
    Replies: 3
    Last Post: 09-21-2011, 10:57 AM
  5. Update table from calculated field in a form
    By BernardKane in forum Forms
    Replies: 3
    Last Post: 11-28-2006, 09:48 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