filter general ledger entries

ggdmp
Member Posts: 5
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.
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
-
Are you refering to
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 usingIF GLEntry.CALCSUMS("Credit Amount","Debit Amount") then
You can also create a repeat until if the calcsums failsIF NOT GLEntry.CALCSUMS("Credit Amount","Debit Amount") then BEGIN if glentry.find('-') then repeat credit += glentry."credit amount"; etc... until glentry.next = 0;
0 -
I tried this... and it does not sum up correctly. Also, if I run the form, the Credit Amount and Debit Amount are both 0. I have to filter something for it to show something.
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;0 -
Do you reset the Debit/Credit ?
Debit := 0; Credit := 0; 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;
0 -
ok.. this works!!
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?0 -
oh, ok...
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!0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions