Results 1 to 5 of 5
  1. #1
    CoffeeFunnel is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2017
    Posts
    12

    UPDATE Query, Created Temp Table Not working

    Hi All,



    I'm getting around to learning SQL, so I'm a bit new to advanced techniques. Can someone help me out a bit? What I'm trying to do, get the minimum value for a particular unique identifier from a transactional table, and update to another table that holds the records by unique identifier where the the minimum value is null. I have to crawl through multiple transactional records to complete the primary table. I keep getting a the message/error "Operation must use an updateable query." Below is the format of the query.

    Code:
    UPDATE PrimaryTable, (SELECT PrimaryTable.UniqueID, MIN(DataSourceTable.Value) AS MINValue FROM DataSourceTable INNER JOIN PrimaryTable ON DataSourceTable.UniqueID = PrimaryTable.UniqueID WHERE PrimaryTable.MINValue IS NULL GROUP BY PrimaryTable.UniqueID) AS TempTable SET PrimaryTable.MINValue = TempTable.MINValue WHERE (((PrimaryTable.UniqueID)=TempTable.UniqueID))
    I tried UPDATE SET WHERE, but maybe my syntax was incorrect. I'm trying to avoid creating another table. I'd prefer to keep it all in one query. Is this possible?

    Tanks!
    CoffeeFunnel

  2. #2
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936

  3. #3
    CoffeeFunnel is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2017
    Posts
    12
    I read the article, made a few changes and I'm still getting the same message. I separated the sub query into it's own query, included a DISTINCT statement, and changed MIN to DMIN. But, I'm still getting the same error. The queries are below.

    PrimaryTable
    Code:
    UPDATE PrimaryTable, TempQuery
    SET PrimaryTable.MINValue = TempQuery.MINValue
    WHERE (((PrimaryTable.UniqueID=TempQuery.UniqueID))
    TempQuery
    Code:
    SELECT DISTINCT PrimaryTable.UniqueID, DMIN(SourceData.Value, "SourceData") AS MINValue
    FROM SourceData INNER JOIN PrimaryTable ON SourceData.UniqueID=PrimaryData.UniqueID
    WHERE PrimaryData.UniqueID IS NULL
    I thought creating this temp table/query would resolve the issue, since it's seperating the actions and the DISTINCT/DMIN is not allowing repeats of UNIQUE IDs

  4. #4
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Table and query are two different things. Temp table/temp query are not the same. It has to be a table.

  5. #5
    CoffeeFunnel is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2017
    Posts
    12
    Okay, PrimaryTable Query works, because I made an actual table. I thought making a temp table was like making a subquery within the query. There has to be a way to combine all of this into one query.

    Can someone point me in the right direction?

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

Similar Threads

  1. Cant update the Query I have created
    By andy49 in forum Programming
    Replies: 4
    Last Post: 11-14-2016, 01:47 PM
  2. Replies: 3
    Last Post: 02-22-2016, 03:38 PM
  3. Replies: 1
    Last Post: 09-03-2014, 10:48 AM
  4. Query for temp linked table
    By compooper in forum Programming
    Replies: 8
    Last Post: 06-30-2011, 06:53 AM
  5. make a temp table from crosstab query
    By stigmatized in forum Programming
    Replies: 0
    Last Post: 07-26-2010, 03:01 PM

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