Results 1 to 3 of 3
  1. #1
    journeyman is offline Advanced Beginner
    Windows 11 Access 2016
    Join Date
    Dec 2022
    Posts
    82

    Update table 1 from TOP value in table 2 - Error

    Hi All,



    I am attempting to update a main items table with the last record results from another table.

    In the follow example, the SELECT statement provides the result - i.e. the last item in the Details table.

    Code:
    UPDATE Tbl_WorkflowItems
    SET CurrentTask = (
        SELECT TOP 1 d.TaskName
        FROM Tbl_WorkflowDetails d
        WHERE d.WorkFlowID=27 AND d.Completed=True
        ORDER BY d.ItemNumber DESC)
    WHERE ID = 27
    However, the error I'm receiving is Operation must use an updateable query.

    The query is very clearly an update query. Both tables can be updated. So what gives?

    Thanks in advance for any good help

    Cheers

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Yes, it is an UPDATE query but it is not an updateable query, according to Access.

    Saving this sort of calculated data is usually a bad idea. If it can be calculated for UPDATE, it can be calculated when needed.

    If you really must save, options are:

    1. save the TOP 1 data to a temp table and use that table as source

    2. VBA looping recordset

    3. domain aggregate functions
    Last edited by June7; 06-20-2023 at 10:50 AM.
    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
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    Both tables can be updated.
    That fact means nothing with respect to the query. What you have is a query with a sub query. Those have never been updatable as far as I can recall. Maybe this would be of interest to you
    http://allenbrowne.com/ser-61.html
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Replies: 11
    Last Post: 07-11-2019, 12:28 AM
  2. Replies: 2
    Last Post: 04-21-2019, 09:35 PM
  3. UPDATE 3073 error trying to update a table field
    By GraeagleBill in forum Programming
    Replies: 2
    Last Post: 10-11-2018, 05:11 PM
  4. Error handling of table update error?
    By panoss in forum Forms
    Replies: 5
    Last Post: 10-31-2014, 02:06 PM
  5. Replies: 0
    Last Post: 11-30-2010, 12:23 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