Using DAvg

grahamw

Registered User.
Local time
Today, 09:27
Joined
Aug 19, 2005
Messages
23
Hi All,
I want to average an array cur_races(1 to 10)
DAvg(expr, domain, [criteria]) seems like a good choice but it
seems to imply that I have to identify a field, table or query etc.
How can I just get the average of an array? (without setting up loop).
This would be easy in excel but Im having difficulties here with access.
Can anyone help please.
Thanks
Graham
 
Why avoid a loop? Loops are beautiful!

Code:
Public Function GetAvg (SomeArrayOfNumbers as Variant) as Single
  Dim i As Integer, j As Integer  [COLOR=Green]'indices[/COLOR]
  Dim sSum as Single

[COLOR=Green]  'traverse array elements - loop[/COLOR]
  For i = Lbound(SomeArrayOfNumbers) to Ubound(SomeArrayOfNumbers)
    [COLOR=Green]'count elements[/COLOR]
    j = j + 1
[COLOR=Green]    'sum elements[/COLOR]
    sSum = sSum + SomeArrayOfNumbers(i)
  Next i

[COLOR=Green]  'divide sum by count of elements, and assign to function[/COLOR]
  GetAvg = sum / j

End Function
 
I appreciate your advice Pat.
Ive just read a bit on normalization.
The database (of horse form I use) is produced by a company in the UK. The database is large and consists of 4 linked tables.
Attempts to use excel were thwarted due to the complexity of the tasks I need to perform.
However, maybe using excel on a subset of results from access will allow me to carry out the statistical tests.
Regards
Graham
 

Users who are viewing this thread

Back
Top Bottom