Subtotals in Form

G

Guest

I have a form that lists the donations history for a donor. I would like to
have 2 subtotals - one to subtotal the donations for the current year and one
to subtotal the donations for the prior year. Do I use Sum Iff? If so, what
is the syntax?

I tried this for the current year subtotal, but it doesn't work:

=Sum(Iif Format([Trans-Check Date], "yyyy")=Format(Now(),"yyyy"), [Amount])

Thanks.
Meryl
 
A

Allen Browne

Try:
=Sum(IIf(Year([Trans-Check Date]) = Year(Date()), [Amount], 0)

Or you could sum the amount directly from the table:
=DSum("Amount", "Donation", "([DonorID] = " & Nz([DonorID], 0) &
") AND ([Trans-Check Date] Between #1/1/" &
Year(Date()) & "# And #12/31/" & Year(Date()) & "#)")
 
G

Guest

Thank you!

Allen Browne said:
Try:
=Sum(IIf(Year([Trans-Check Date]) = Year(Date()), [Amount], 0)

Or you could sum the amount directly from the table:
=DSum("Amount", "Donation", "([DonorID] = " & Nz([DonorID], 0) &
") AND ([Trans-Check Date] Between #1/1/" &
Year(Date()) & "# And #12/31/" & Year(Date()) & "#)")

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Meryl said:
I have a form that lists the donations history for a donor. I would like
to
have 2 subtotals - one to subtotal the donations for the current year and
one
to subtotal the donations for the prior year. Do I use Sum Iff? If so,
what
is the syntax?

I tried this for the current year subtotal, but it doesn't work:

=Sum(Iif Format([Trans-Check Date], "yyyy")=Format(Now(),"yyyy"),
[Amount])

Thanks.
Meryl
 

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

Top