I have been asked to a create a report.
I am suppose to look at all the records where the program type is Passport Services. I got that working.
Each passport Service has a Transaction type which could either be 'cheque' or 'receipt'. Each record can have multiple Transacation types. For each record I have been asked to keep track of the total amount if the transaction type is cheque and if the transaction type if receipt.
I have been able to get receipt working and it gives me the correct total amount. But when I try to apply the same code and get the total amount for cheque. It doesnt work. It gives me the same answer. I even know why its giving me the same answer. I just dont know how to fix it.
(OnAfterGetRecord)
IF "Consumer Disbursement"."Transaction Type" = "Consumer Disbursement"."Transaction Type"::Receipt THEN
BEGIN
"Consumer Disbursement".CALCSUMS(Amount);
END;
IF "Consumer Disbursement"."Transaction Type" = "Consumer Disbursement"."Transaction Type"::ChequeTHEN
BEGIN
"Consumer Disbursement".CALCSUMS(Amount);
//TotalAmountCheque := "Consumer Disbursement".Amount;
END;
(OnPostDateItem)
TotalAmountReceipt := "Consumer Disbursement".Amount + TotalAmountReceipt;
TotalAmountCheque := "Consumer Disbursement".Amount + TotalAmountCheque;
I see the problem with this code, but I am just not sure how to fix it.
Any Suggestions???
This is just to provide you with an idea of what I mean. This is just one record (REC00031) with multiple Transaction Type.
http://www.zshare.net/image/992983510e280437/
Answers
some quick thoughts...haven't tested
I would split up the amount with different variables.
CREATETOTALS(checkamt, receiptamt);
OnAfterGetRecord()
CALCFIELDS(Amount);
if check type then
checkamt := checkamt + amount else
checkamt := 0;
if receipt type then
receiptamt := receiptamt + amount else
receiptamt := 0;
then keep Createtotals of receiptamt & checkamt.
you can also look at the customer statement report.
depending on the type it splits it into Debit or Credit and total's it.
Sounds just like what you're doing.
CREATETOTALS
Use this function to maintain totals for a variable in the same way as totals are maintained for fields by using the TotalFields property.
http://www.BiloBeauty.com
http://www.autismspeaks.org
It still doesnt work. For some weird reason its only detects the negative values. It never seem to find any of the transaction type 'cheque'.
I dont think i will need calfields(amount) because amount is not a flowfield.
It still doesnt work any suggestions.
Thanks anways.
And you can add messages to see if everything is working as you expect.
Once it does work the messages can be removed.
IF "Consumer Disbursement"."Transaction Type" = "Consumer Disbursement"."Transaction Type"::Cheque THEN BEGIN
MESSAGE('Check Type Found! TOTAL AMOUNT %1 - Amount %2',totalamountcheque,amount);
TotalAmountCheque := TotalAmountCheque + Amount;
message('%1', totalamountcheque); //to see if it changed
END;
http://www.BiloBeauty.com
http://www.autismspeaks.org
http://www.BiloBeauty.com
http://www.autismspeaks.org