Calculation on a form

  • Thread starter Thread starter Dave
  • Start date Start date
D

Dave

I have a form "Decs" with a subform "Runners Ratings"
with a Field "Own". What I am trying to do is
calculate the the average of the "Own" field in
the "Runners Ratings subform" and display the result in
the Field "Arate" in the "Decs" Form.
I have tried variations of the following in the Record
source of "Arate" but get an error.
=Avg expr [RunnersRatingssubform],Form![Own]
Can anybody help please, as you can see i'm a novice at
this.
Thanks
 
Try the DAvg() function. You will need to supply it with the field name to
be averaged, the table or query from which that field comes, and any
criteria needed to limit the average to the correct records. In this case,
the criteria would probably be the value of the child link field of the
subform.

=DAvg("Own", "[Runners Ratings Record Source Name]", "[NameOfLinkingField]="
& NameOfSubformControl.Form.txtTextboxForLinkingField)

The above will work if the linking field is numeric. If it is text, modify
as follows:

=DAvg("Own", "[Runners Ratings Record Source Name]",
"[NameOfLinkingField]=""" &
NameOfSubformControl.Form.txtTextboxForLinkingField & """")
 
Back
Top