Expression to sum totals in textboxes

D

Dave

On a report I have an textbox called "txtAmount" with the following control
source:

=IIf([ckEligible],[Amount],0)

If the checkbox "ckEligible" is true then the value in txtAmount is
populated with [Amount]. Otherwise it is zero.

Now I want to sum up all the values for all the displayed records show them
in the footer

I create a textbox in the footer called "txtSumAmount" and set it's control
source to:

=Sum(IIf([Amount]=0,0,[Amount]))


However the sum includes values for [Amount] even when the textbox
"txtAmount" is set to zero because ckEligible is false.

How can I exclude those [Amount] values from my total when "txtAmount"
displays zero?

I tried this but it does not work:

=Sum([txtAmount])
 
J

John Vinson

How can I exclude those [Amount] values from my total when "txtAmount"
displays zero?

I'd suggest moving the IIF() statement to the Query upon which the
form is based rather than the control source of the textbox. This will
give you an (uneditable) computed field which can be summed.
 

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