Solved

MS access

Posted on 2013-01-21
10
225 Views
Last Modified: 2013-02-06
I want to do Running Sum in Query2 but it is not working please if someone can look at it and fix it. Attach is the database.
Thanks
test.mdb
0
Comment
Question by:snhandle
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 26

Expert Comment

by:jerryb30
Comment Utility
Can you give example of what you want to see, based on posted data?
0
 

Author Comment

by:snhandle
Comment Utility
EmpAlias      SumOfSumOfTotal      RunTot
01-Jul-12      6,000.00                      6000
02-Jul-12      500.00                      6500
03-Jul-12      (1,200.00)                      5,300.00
09-Jul-12      (10,927.40)             -5627.4

I want to see the query2 result like the above result if I select the date range from July 1 through July 9th.
Thanks
0
 
LVL 26

Expert Comment

by:jerryb30
Comment Utility
Try this, one query:
SELECT a.Date AS EmAlias, Sum(nz([dr],0))-Sum(nz([cr],0)) AS SumTotal, DSum("nz([dr],0)","[base Table]","[date] <= #" & [a.date] & "#")-DSum("nz([cr],0)","[base Table]","[date] <= #" & [a.date] & "#") AS unTot
FROM [Base Table] AS a
GROUP BY a.Date;
0
 
LVL 26

Expert Comment

by:jerryb30
Comment Utility
For the parens:
SELECT a.Date AS EmpAlias, Format(Sum(nz([dr],0))-Sum(nz([cr],0)),"0;(0)") AS SumTotal, DSum("nz([dr],0)","[base Table]","[date] <= #" & [a.date] & "#")-DSum("nz([cr],0)","[base Table]","[date] <= #" & [a.date] & "#") AS RunTot
FROM [Base Table] AS a
GROUP BY a.Date
HAVING (((a.Date) Between [start date] And [end date]));
0
 
LVL 26

Expert Comment

by:jerryb30
Comment Utility
See NewQuery in attached.
I removed PasteErrors table to save size.
testc.mdb
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
Comment Utility
Can I ask why you want to do this in a query?

If you are going to use this in a report, then create an extra textbox in the report, set it's Control Source to the appropriate field, then set the Running Sum property (Data tab) to "Over all" or "Over group".
0
 

Author Comment

by:snhandle
Comment Utility
I want to do this in query because I want to get only negative lines  in the query, and in reports if I do runningsum then if I want to show only negative lines on the report I can not do that, because then it leave blank spaces.
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
Comment Utility
Did you try the solution I gave you to that problem.  I posted a sample database for you to look at.
0
 
LVL 30

Accepted Solution

by:
hnasr earned 500 total points
Comment Utility
Try this through report.
'set value to 0 if positive
add txtSumOfTotal = IIf([SumOfTotal]>0,0,[SumOfTotal])

In detail format event:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
   
    If SumOfTotal >= 0 Then
        Cancel = True
    End If
End Sub
test-Q-28003512.mdb
0
 

Author Comment

by:snhandle
Comment Utility
good
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

The System Center Operations Manager 2012, known as SCOM, is a part of the Microsoft system center product that provides the user with infrastructure monitoring and application performance monitoring. SCOM monitors:   Windows or UNIX/LinuxNetwo…
This collection of functions covers all the normal rounding methods of just about any numeric value.
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now