views:

43

answers:

1

Is it possible to use a subform's 'current' record set as the domain argument to DAvg() (etc.)?

Basically, I have a subform that displays a subset of records from a query. I would like to run DAvg() over this subset. This is how I've gotten around it:

=DAvg([FieldToAvg], [SubformQuery], "ChildField=Forms.MasterForm.MasterField And FieldToAvg > 0")

but what I actually want is something like:

=DAvg([FieldToAvg], [SubformCurrentlyDisplayedData], "FieldToAvg > 0")

Is this possible in Access 2007?

+1  A: 

Is there any reason why you do not want to use a subform footer, hidden or otherwise, to do this? It is the simplest way.

In a textbox:

=Avg([SomeField])
Remou
Yes, I need to exclude some of the displayed records from the average. That's why I'm using `DAvg()`.
harto
You can use IIf() to create a column in your subform's Recordsource that includes only the values you want to average and then use that with @Remou's suggestion.
David-W-Fenton
OK. Thanks David.
harto