How do I average a calculated field in a report?

G

Guest

I have a field named Date of Birth, one named Date Today, a third named Age.
The age is calculated from the first two. How do I sum this calculated age
total to average it by the number of records. Access 2003.
 
D

Douglas J. Steele

I believe Duane's assuming (as am I) that when you said that "the age is
calculated from the first two", you meant you have a formula as the control
source for the Age text box. You need to put that formula in your Sum
statement, not a reference to the text box.
 
G

Guest

When I apply the SUM to the calculation, Access informs me that I cannot use
an Aggregate with my expression:
=DateDiff("d",[BirthDate],[DateToday])/Count([PatientNumber]). What did I do
wrong?
 
G

Guest

Access informs me that I cannot use an Aggregate function such as SUM with my
expression: =DateDiff("d",[BirthDate],[DateToday])/Count([PatientNumber]).
What have I done wrong?
 
D

Duane Hookom

There is a function to calculate age at
http://www.mvps.org/access/datetime/date0001.htm. Then you can show the
average age in a group or report header or footer with:

=Avg(Age([Date of Birth],[Date Today]))

--
Duane Hookom
MS Access MVP
--

NewLifeAl said:
Access informs me that I cannot use an Aggregate function such as SUM with
my
expression:
=DateDiff("d",[BirthDate],[DateToday])/Count([PatientNumber]).
What have I done wrong?

Douglas J. Steele said:
I believe Duane's assuming (as am I) that when you said that "the age is
calculated from the first two", you meant you have a formula as the
control
source for the Age text box. You need to put that formula in your Sum
statement, not a reference to the text box.
 

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