Results 1 to 3 of 3

MSGraph object with accumulated values in Access form

  1. #1
    solversen is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2017
    Posts
    2

    MSGraph object with accumulated values in Access form

    I'm struggling to pass accumulated values to a msgraph object. The graph shows the accumulated values for profit. Look at the attachment, livetrades_form.pdf, to see what I try to achieve. This one works. But when I change to another result set, something wrong happens, attachment livetrades_form_not_correct_pdf.



    See the table which the query extracts data form in livetrades_table.pdf.

    When showing the form, the Graph's RowSource property is set:
    ProfitGraph.RowSource = "SELECT Null, (SELECT sum(Profit) from LiveTrades a2 where a1.ExitTime >= a2.ExitTime) AS RunningSumField1 FROM LiveTrades AS a1 WHERE AlgoVariantID=" & lstAlgoVariant & " GROUP BY a1.ExitTime, a1.LiveTradesID ORDER BY a1.ExitTime ;".

    When the lstAlgoVariant (Listbox) returns 1, the graph is correct. When it Returns 12, it's not. The msgraph_query.pdf shows the statement which returns the wrong values. It returns two rows of data, the first one is 367,98 and the second one 212,08. Looking at the table, it seems like the first row with another Algovariant than 12 is counted in, and what happens next, I can't understand....

    I would be happy to have some help to make the right statement to send to the graph object.
    Attached Files Attached Files

  2. #2
    solversen is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2017
    Posts
    2
    I managed to solve this myself, by adding another condition to the nested where clause:

    ProfitGraph.RowSource = "SELECT Null, (SELECT sum(Profit) from LiveTrades a2 where a1.ExitTime >= a2.ExitTime AND AlgoVariantID=" & lstAlgoVariant & ") AS RunningSumField1 FROM LiveTrades AS a1 WHERE AlgoVariantID=" & lstAlgoVariant & " GROUP BY a1.ExitTime, a1.LiveTradesID ORDER BY a1.ExitTime ;"

  3. #3
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    17,338
    Thanks for posting your solution and welcome to the site!
    Paul (wino moderator)
    MS Access MVP
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 1
    Last Post: 11-10-2014, 08:55 AM
  2. Replies: 6
    Last Post: 03-29-2014, 07:47 PM
  3. Replies: 4
    Last Post: 02-05-2014, 11:55 PM
  4. Replies: 1
    Last Post: 09-03-2011, 06:01 PM
  5. How to create accumulated expense?
    By latestgood in forum Access
    Replies: 1
    Last Post: 05-17-2011, 07:46 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
  •  
Tech Forums: Microsoft Office Forums