AnsweredAssumed Answered

Adding sum of two fields from Find results

Question asked by JohnNiebler on Mar 26, 2017
Latest reply on Mar 26, 2017 by BruceRobertson

Hello all,

 

I think this is super easy and I'm just missing the trick.

 

I have one table with AmtPaid, DatePaid, and AmtPd2, DatePaid2 fields.

 

So this might look like this:

 

$30     1/3/17     $40     1/10/17

$30     1/5/17

$25     1/6/17     $25     1/6/17

 

What I want is a total of all money paid within a date range.

 

I have a layout with two global date fields and a button to perform a search.  The button triggers this script:

Enter Find Mode[]

Set Field[Contracts::DatePaid; Contracts::IncomeStartDate & ".." & Contracts::IncomeEndDate]

Perform Find

Set Variable[$SumOfAmtPd; Value:Sum{Contracts::AmtPaid)]

Set Field[Contracts::DatePaid2; Contracts::IncomeStartDate & ".." & Contracts::IncomeEndDate]

Perform Find

Set Variable[$SumOfAmtPd2; Value:Sum{Contracts::AmtPd2)]

Show Custom Dialog["Income For Date Range";"The total for AmtPaid is " & $SumOfAmtPd & ". And the total for AmtPd2 is " & $SumOfAmtPd2 & ". And the Total income is " & $SumOfAmtPd+$SumOfAmtPd2]

 

This isn't returning the correct amounts for the sums.  Looks like it's returning just the first returned record's amount.

 

Thanks,

-John

Outcomes