Quote:
Originally Posted by bkberg05
Hi - I have a continuous form that displays many records. One of the fields is an amount field. In the footer, I want to sum the amount field. That seemed easy enough using an =sum([field_name]). But then I wanted only sum some of the fields where another field (a Y/N field) was set to Y.
I'm sure it's easy, but I can't seem to figure it out. I've tried =sum([field_name]) where ynfield = "Y", but that doesn't work.
Thanks in advance for your help.
Bill Berg
Hi
Ther are a couple of ways of doing this.
1) If the record source is based on a stored query, then you could use the DSum() domain function something lke
- =DSum("Field_Name","StoredQueryName","ynField = yes")
assuming ynField is a yes/no datatype (ie. boolean - in which case you only need
- DSum("Field_Name","StoredQueryName","ynField")
??
2) In the form Record Source query, in query designer, add a field
- Yes_Value: IIF([ynField],[Field_Name],0)
again assuming ynFiled is Yes/No
then in the footer texbox enter
There is another way (which I've just used to calculate 39 sub total because 39 DSum()s are too slow) but that involves cycling through the records with VBA, which has virtually no time penalty.
Method 2 would be my prefered option.
HTH
MTB