Report Average or Sum

A

AlCamp

On a Totals query for a report, I want the user to be able to check an
option box on a Dialog form and have an Average, or Sum returned by the
query.

The form is frmDialog, and the Option Frame on that form is [AverageOrSum]
and it has 2 checkbox elements...
[Average]=1 and [Sum]=2

At present, I have the Sum portion of this problem working with this as a
calculated column...
SumOf1s : Sum(IIf([DefectID]=1,[DefectCount],0)))

Then I tried adding the Average portion... (all on one line)
SumOrAvg1s : Sum(IIf([DefectID]=1
AND Forms!frmDialog!AverageOrSum = 1,[DefectCount],Avg([DefectCount])))
I get a "Can't use aggregate function" (the AVG in this calculation) error.

Any help will be appreciated.

As always... Thanks,
Al Camp
 
A

AlCamp

Typo... this portion of the post should read...
Then I tried adding the Average portion... (all on one line)
SumOrAvg1s : Sum(IIf([DefectID]=1
AND Forms!frmDialog!AverageOrSum = 2,[DefectCount],Avg([DefectCount])))
I get a "Can't use aggregate function" (the AVG in this calculation)
error.

(AND Forms!frmDialog!AverageOrSum = 2 --- instead of 1)

Al Camp


AlCamp said:
On a Totals query for a report, I want the user to be able to check an
option box on a Dialog form and have an Average, or Sum returned by the
query.

The form is frmDialog, and the Option Frame on that form is [AverageOrSum]
and it has 2 checkbox elements...
[Average]=1 and [Sum]=2

At present, I have the Sum portion of this problem working with this as a
calculated column...
SumOf1s : Sum(IIf([DefectID]=1,[DefectCount],0)))

Then I tried adding the Average portion... (all on one line)
SumOrAvg1s : Sum(IIf([DefectID]=1
AND Forms!frmDialog!AverageOrSum = 1,[DefectCount],Avg([DefectCount])))
I get a "Can't use aggregate function" (the AVG in this calculation)
error.

Any help will be appreciated.

As always... Thanks,
Al Camp
 

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