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 sum from different fields in a form

Status
Not open for further replies.

bfamo

Technical User
Feb 16, 2006
132
NO
Hi guys,
First off I would like to thank you all for lots of good answers to my questions!


Now, my question this time is how I get [FieldAverage] to calculate the average sum of fields that contains numbers higher than 0 in a form. I have 5 fields that contain numbers from 0 to 10 ([field1], [field2], [field3], [field4], [field5]).

Thanks ;)
 
You may use this function:
Code:
'A generic function to get the average value of an arbirtrary numbers of numeric values:
Public Function myAvg(ParamArray Args())
Dim i As Long, N As Long, rv
For i = 0 To UBound(Args)
  If IsNumeric(Args(i)) Then rv = rv + Args(i): N = N + 1
Next
If N > 0 Then myAvg = rv / N
End Function

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Yes, this looks like what I'm after. I've been trying it out, and I have to admit that I'm kind of a newbie.

Could you perhaps show me the code with my fields inserted into it?

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top