Solved

MS access

Posted on 2013-01-21
10
236 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
ID: 38803543
Can you give example of what you want to see, based on posted data?
0
 

Author Comment

by:snhandle
ID: 38803574
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
ID: 38803722
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
ID: 38803747
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
ID: 38803776
See NewQuery in attached.
I removed PasteErrors table to save size.
testc.mdb
0
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 38803785
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
ID: 38804161
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)
ID: 38805212
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
ID: 38806496
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
ID: 38862367
good
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
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…

932 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

17 Experts available now in Live!

Get 1:1 Help Now