Dsum bigger or smaller than 0 (1 Viewer)

DaRTHY

Registered User.
Local time
Today, 13:42
Joined
Mar 6, 2015
Messages
90
Hello friends

i have a simple question i could not find any solution:(

this is my code : (im using 2007-2010 and its working like that)

Code:
=Dsum("*";"Table Name";"[Field Name] < 0")

i need to calculate only bigger than 0 or smaller than 0 doesnt matter..

i checked from Forum etc. there is only between 2 dates options.

Ty for your helps.
 

plog

Banishment Pending
Local time
Today, 15:42
Joined
May 11, 2011
Messages
11,653
Huh?

1. You need to supply a field to sum, you can't sum on *.

2. Bigger than or smaller than 0, means you want to exclude 0, so you use this in your criteria argument:

[Field Name]<>0
 

spikepl

Eledittingent Beliped
Local time
Today, 22:42
Joined
Nov 3, 2010
Messages
6,142
It is not clear from your description what you want. Show an example consisting of some records and then the desired result.
 

DaRTHY

Registered User.
Local time
Today, 13:42
Joined
Mar 6, 2015
Messages
90
okey. im sending a picture now. in my field - and + values. I need to calculate them. For example :

-152400 + (-70)= -152470 these values smaller than 0
and same thing for + values too.
 

Attachments

  • 2.JPG
    2.JPG
    18.2 KB · Views: 75

namliam

The Mailman - AWF VIP
Local time
Today, 22:42
Joined
Aug 11, 2003
Messages
11,695
How about doing 2 dsums?

=Dsum("*";"Table Name";"[Field Name] < 0")
=Dsum("*";"Table Name";"[Field Name] > 0")

Or more efficent it would be to do a single query
Code:
Select 
sum(iif(yourfield>0,yourfield,0)),
sum(iif(yourfield<0,yourfield,0))
from YourTable
 

DaRTHY

Registered User.
Local time
Today, 13:42
Joined
Mar 6, 2015
Messages
90
i have already written this
=Dsum("*";"Table Name";"[Field Name] < 0")
to my text box but not working. And i really dont know how shall i write to text box sql. Is that again in Control source ?
 

DaRTHY

Registered User.
Local time
Today, 13:42
Joined
Mar 6, 2015
Messages
90
okey i guess i found how can i do that.
i created 1 more field for - values and + values too (i was thinking i can do them in same field but this is more fast and easy)
now i can sum them ;)
Ty Namlian :)
 

namliam

The Mailman - AWF VIP
Local time
Today, 22:42
Joined
Aug 11, 2003
Messages
11,695
If you want to sum them all I dont see the point

-10+5-9+4-8 = -27 + 9 = -18

-10+0+5-9+0+4-8+0 will still = -18??
 

DaRTHY

Registered User.
Local time
Today, 13:42
Joined
Mar 6, 2015
Messages
90
for my report i need to sum them as 3 different parts. firstly - then + and total. they want to see all values.
 

plog

Banishment Pending
Local time
Today, 15:42
Joined
May 11, 2011
Messages
11,653
Code:
=Dsum("*";"Table Name";"[Field Name] < 0")

Again, you need to tell DSum what field to sum. You can't use * in DSum.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 21:42
Joined
Sep 12, 2006
Messages
15,662
I don't know if you can do this directly: you need something like

dsum("fieldname","select * from tablename where fieldname < 0")

not sure offhand if you can use a sql string directly in this expression.

---
you could easily just save the sql string as a query though, and then
dsum("fieldname","queryname")
 

Users who are viewing this thread

Top Bottom