DSUM in Form

  • Thread starter Thread starter Gator
  • Start date Start date
G

Gator

I have a textbox on a form where =DSum("Amount","TreasurerDeposits") returns
the sum from a table...it works....why can't I do this for a query? What do
I do to get total from query....is there any SQL that will do it?
i have a subform showing records from a query and I want a textbox to show
the total of a field from the query. what code or SQL can do this?
 
You could just use DSum. To Access, tables and queries are pretty much
interchangeable everywhere.
 
OK for some reason my query lost it's datasource...i fixed it. But, on the
subform's datasheet, I want the textbox's sum to work in the event that I use
the Filter by Selection in the datasheet. Right now it is showing the sum of
all the records in the table despite a filter. If I Filter by Selection, I
want the textbox to sum only the filtered records, not all the records.
Regards,
Gate
 
You'd need to have a Where clause in your DSum corresponding to the Filter.

You could try

=DSum("Amount","qryTreasurerDeposits", Forms!NameOfForm.Filter)

Note that you'll need to put code in the form's Filter event to requery the
text box.
 
Back
Top