Expression to sum totals in textboxes

  • Thread starter Thread starter Dave
  • Start date Start date
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])
 
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.
 
Back
Top