Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how can I use the Sum function with an IIF?

Status
Not open for further replies.

HockeyFan

MIS
Jun 21, 2005
138
US
Is it possible to do a sum of field B, only when field A has the value of 1?
Example:
=IIf([A]="1",Sum(),"")

The problem with my statement above, is that it is doing a sum of all of the records of field B, whereas I only want it to sum the records that have a value of 1, in field A.

I want to use this statement as a control source for my form.
 


How about this...
[tt]
=SUM(IIf([A]="1",,0))
[/tt]


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
This definately sounds like the right solution, but for some reason it's not working. could there be a syntax error?
 


What are the symptoms of "not working?"

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 



What is the data type for [A]?

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 


Then why are you testing for a STRING???
Code:
=SUM(IIf([A]=1,[B],0))

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Skip, you da bomb!

Thanks. stupid mistake by me. I appreciate your help!
 


Francois: Do you know what kind of a bomb it was?
Clouseau: The exploding kind.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top