conditional if when a negative value

L

lake2212

I am new to the group, so please bear with me.

I have a report that runs a total on a column called 'number of shares'.
Sometimes the number of shares is a negative number. I would like to not
include the negative number in the total computation. How would that be done?
 
A

Al Campagna

lake2212,
In your query behind the report, using the Design Grid, add a calculated
field colum...

NoShares : NZ(IIF([Number Of Shares]) > 0, [Number Of Shares], 0 )

Place this bound calculated field NoShares on the report, and Sum in
whatever Group footer or Report footer you want.
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 
F

fredg

I am new to the group, so please bear with me.

I have a report that runs a total on a column called 'number of shares'.
Sometimes the number of shares is a negative number. I would like to not
include the negative number in the total computation. How would that be done?

Where are you summing the shares? In the Report?
Add an unbound control to the report.
=Sum(IIf(Nz(NumberOfShares],0)>0,[NumberOfShares],0))
 
L

lake2212

I am summing the shares in the report - but do want the negative number to
show in the report.

I tried your suggestion, but am getting an error that says 'The expression
you entered has invalid syntax. I have checked it over and over for errrors.
Any ideas? Thanks.

fredg said:
I am new to the group, so please bear with me.

I have a report that runs a total on a column called 'number of shares'.
Sometimes the number of shares is a negative number. I would like to not
include the negative number in the total computation. How would that be done?

Where are you summing the shares? In the Report?
Add an unbound control to the report.
=Sum(IIf(Nz(NumberOfShares],0)>0,[NumberOfShares],0))
 
L

lake2212

Thanks! This is what I needed.

fredg said:
I am new to the group, so please bear with me.

I have a report that runs a total on a column called 'number of shares'.
Sometimes the number of shares is a negative number. I would like to not
include the negative number in the total computation. How would that be done?

Where are you summing the shares? In the Report?
Add an unbound control to the report.
=Sum(IIf(Nz(NumberOfShares],0)>0,[NumberOfShares],0))
 
K

Klatuu

The easier way is to use the Format property of the control where the number
is. this will display positive numbers with one deciaml place and negative
numbers will be hidden.
#.0;""

It is always better to do this sort of thing at the report level rather than
in the query. It is faster.
--
Dave Hargis, Microsoft Access MVP


lake2212 said:
Thanks! This is what I needed.

fredg said:
I am new to the group, so please bear with me.

I have a report that runs a total on a column called 'number of shares'.
Sometimes the number of shares is a negative number. I would like to not
include the negative number in the total computation. How would that be done?

Where are you summing the shares? In the Report?
Add an unbound control to the report.
=Sum(IIf(Nz(NumberOfShares],0)>0,[NumberOfShares],0))
 
A

Al Campagna

Lake,
Sorry about my typo...
Should be...
IIF(NZ([Number of Shares],0) > 0, [Number of Shgares], 0)
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."

Al Campagna said:
lake2212,
In your query behind the report, using the Design Grid, add a
calculated field colum...

NoShares : NZ(IIF([Number Of Shares]) > 0, [Number Of Shares], 0 )

Place this bound calculated field NoShares on the report, and Sum in
whatever Group footer or Report footer you want.
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."

lake2212 said:
I am new to the group, so please bear with me.

I have a report that runs a total on a column called 'number of shares'.
Sometimes the number of shares is a negative number. I would like to not
include the negative number in the total computation. How would that be
done?
 
F

fredg

I am summing the shares in the report - but do want the negative number to
show in the report.

I tried your suggestion, but am getting an error that says 'The expression
you entered has invalid syntax. I have checked it over and over for errrors.
Any ideas? Thanks.

fredg said:
I am new to the group, so please bear with me.

I have a report that runs a total on a column called 'number of shares'.
Sometimes the number of shares is a negative number. I would like to not
include the negative number in the total computation. How would that be done?

Where are you summing the shares? In the Report?
Add an unbound control to the report.
=Sum(IIf(Nz(NumberOfShares],0)>0,[NumberOfShares],0))

I left off a [
V
=Sum(IIf(Nz(NumberOfShares],....etc..))
Should have been:
=Sum(IIf(Nz([NumberOfShares],.....rtc..))

Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top