Summing fields in subform

C

CRBI

I have a members database with a table for member info and a table for their
contribution amounts. I have created a form based on the member table with a
subform from the contributions table. Since a single member can make several
contributions within one year, I want a field next to the subform to sum the
total contributions that particular member has made to date. I can't seem to
get the syntax right to make that work. I created an unbound text box and
used the following syntax:

=sum(Forms![Contributions Subform]Amt!)

I built this using expressions.
 
C

Cheese_whiz

Hi CRBI,

You could use DSum:

=DSum("Amt", "Contributions", "MemberID = " & Me.txtMemberID)

Assuming:
"Amt" is the field in your subform's recordsource (table or query) where
donation amounts are stored.

"Contributions" is the name of your table or query that holds contribution
records

"MemberID" is the primary key from your main form's recordset (table or
query), and it's a number type field (could/most likely is an autonumber)

"txtMemberID" is the main form control that is bound to the memberId field
in your main form's recordsource

HTH,
CW
 
D

Dale Fye

Another way to address this would be to put the Total control in the footer
of the subform. Then all you would need to do is in the ControlSource of
that textbox enter: =Sum([Amt])

--
HTH
Dale

email address is invalid
Please reply to newsgroup only.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top