Hi.
I have added two text fields at the bottom of the form General Ledger Entries that display the Debit Amount and the Credit Amount.
I made a function and added the following code that is called from OnAfterGetCurrRecord:
GLEntry.COPY(Rec);
GLEntry.CALCSUMS("Credit Amount","Debit Amount");
Credit := GLEntry."Credit Amount";
Debit := GLEntry."Debit Amount";
It works well when I simply run the form .. however when I try to do a field filter (for example if I try with Posting Date) I get the following message:
The sum of the values in the Credit Amount Field cannot be calculated because the current key does not contain all the fields being filtered.
you must select a field that contains all the fields in the filter. The order of the fields is unimportant.
Filters: Posting Date: 04/08/05
Table: G/L Entry
key Fields: Entry No.
Is there something I'm missing? I do have a secondary key in the G/L Entry table... Posting Date with SumIndexFields Credit Amount and Debit Amount.
0
Comments
http://www.mibuso.com/dl.asp?FileID=508&Type=file
???
If you do a calcsums, all the current filters should be in the current key.
You can avoid a runtime error by using
You can also create a repeat until if the calcsums fails
And what it adds up is wrong.
My code now is
GLEntry.COPY(Rec);
IF NOT GLEntry.CALCSUMS("Credit Amount","Debit Amount") THEN BEGIN
IF GLEntry.FIND('-') THEN
REPEAT
Credit += GLEntry."Credit Amount";
Debit += GLEntry."Debit Amount";
UNTIL GLEntry.NEXT = 0;
END;
However... if there is no filter (when I first open up the form)... the values of Credit Amount and Debit Amount are 0.
How do I make it show the value?
I simply added...
END ELSE
IF GLEntry.CALCSUMS("Credit Amount","Debit Amount") THEN BEGIN
Credit := GLEntry."Credit Amount";
Debit := GLEntry."Debit Amount";
END;
works great!
Thanks!