Solved

MS access

Posted on 2013-01-21
10
270 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
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
 
LVL 48

Expert Comment

by:Dale Fye
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 48

Expert Comment

by:Dale Fye
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

630 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