Results 1 to 4 of 4
  1. #1
    cazziewhelan is offline Novice
    Windows XP Access 2003
    Join Date
    Feb 2014
    Posts
    3

    Sum Update Query

    Hi All,

    I am trying to write a SQL statement query, that will calculate the SUM value in one table for a March period, and update that value to another table, here is what I have so far, but the compile error says Operation must use an updatable query.


    UPDATE League_Totals SET League_Totals.March_Total = (SELECT SUM(Result_Value)
    FROM Result_Details


    WHERE LEAP_Date = "March_2014");


    Any ideas what I am doing wrong?

  2. #2
    lfpm062010 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Location
    US
    Posts
    415
    Try to use a DSUM function instead of sub-query.

  3. #3
    cazziewhelan is offline Novice
    Windows XP Access 2003
    Join Date
    Feb 2014
    Posts
    3
    Hi, thanks for your reply, I have managed to solove another issue with e DSUM function, however canot get it to work in the update query?

    UPDATE League_Totals
    SET League_Totals.March_Total = DSUM(Result_Details.Result_Value)
    WHERE LEAP_Date = "March_2014";

    Can you shed any light on how to structure an update query to include a DSUM function?
    The DSUM is to calculate all Result_Value where LEAP_Date is March and Store_Number is 137 in Result_Details table and update this DSUM todal to March_Total in League_Results table.

    It would be great if you could help me out on this one!

  4. #4
    lfpm062010 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Location
    US
    Posts
    415
    DSum Syntax:

    DSum("FIELDNAME", "TABLENAME", "CRITERIA")

    Try this, I am not sure the "LEAP_Date" should go in the DSum "CRITERIA" area or in the UPDATE "WHERE" area.

    UPDATE League_Totals
    SET League_Totals.March_Total = DSUM("Result_Details.Result_Value", "Result_Details", "LEAP_Date = 'March_2014' ")
    ;

    OR

    UPDATE League_Totals
    SET League_Totals.March_Total = DSUM("Result_Details.Result_Value", "Result_Details")
    WHERE LEAP_Date = "March_2014";

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

Similar Threads

  1. Replies: 7
    Last Post: 08-26-2013, 06:05 AM
  2. Replies: 1
    Last Post: 05-17-2013, 12:53 PM
  3. Replies: 2
    Last Post: 08-30-2012, 07:59 AM
  4. Replies: 4
    Last Post: 11-10-2011, 03:41 PM
  5. Replies: 1
    Last Post: 08-19-2011, 12:16 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