
Signature
Duane Hookom
MS Access MVP
--
Actually, it is a little more complicated than below. I have to "count" the
"F" and "P" and at the same time get 2 averages of another (currency) field,
based on the "F" and "P". The sum of the other values are divided by the
count to get that average.
I have tried using one and two other queries, but there were just too many
variables (such as the record had to be between a set of dates).
What I need to figure out is WHY when I print what is showing on the screen
(which is correct), the count in the two (four) fields are added to the
previous amount in that field.
Hope this helps.
John H W
> There is probably an easier method if we knew where you are and what your
> requirements are. It is very rare that you need to write code in a report to
[quoted text clipped - 23 lines]
> >
> > John H W
Duane Hookom - 31 Mar 2005 06:39 GMT
The format event of a section of a report may fire twice for each printing
of the section.
I still think there might be an easier method that doesn't involve any other
queries or code.
To count the number of "F" values in FieldA, use:
=Sum(Abs([FieldA]="F"))
to average all the FieldCurrency values where FieldA = "F"
=Sum(Abs([FieldA]="F") * FieldCurrency)/Sum(Abs([FieldA]="F"))
You may need to catch for a divide by zero if there are no "F" values in
FieldA.

Signature
Duane Hookom
MS Access MVP
> Actually, it is a little more complicated than below. I have to "count"
> the
[quoted text clipped - 48 lines]
>> >
>> > John H W
John H W - 31 Mar 2005 22:29 GMT
The below worked. I had forgotten that ABS would return a 1 when true.
Thanks,
John H W
> The format event of a section of a report may fire twice for each printing
> of the section.
[quoted text clipped - 59 lines]
> >> >
> >> > John H W