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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Average in Report

Status
Not open for further replies.

RRose

Technical User
Oct 20, 2000
1
US
I was wondering if there is a way to average information once it is in a report.

I have 5 columns info and I am wanting to average them together. How or can I do this.

Any help is welcome

Thanks

Richard
 
If you are refering to averaging the total of 5 fields, the Avg function built in to Access will not help you. You can Sum each field the use the following function to average across the 5 fields:

Public Function AverageOf5(n1 As Double, n2 As Double, _
n3 As Double, n4 As Double, n5 As Double)

Dim x As Integer
Dim z As Double

x = 0
z = n1 + n2 + n3 + n4 + n5

If z = 0 Then
AverageOf5 = 0
Exit Function
End If
If n1 <> 0 Then
x = x + 1
End If
If n2 <> 0 Then
x = x + 1
End If
If n3 <> 0 Then
x = x + 1
End If
If n4 <> 0 Then
x = x + 1
End If
If n5 <> 0 Then
x = x + 1
End If

AverageOf5 = z / x

End Function

HTH
RDH

Ricky Hicks
rdhicks@mindspring.com

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top