I have build a Tabular-Type Form binded to a temporary table.
User can insert in form some record. In the header form I have a textbox in which I want to show total amount (sum of amount field of all row).
How can I do it?
You can write code to consider all the records in the temporary table while INSERT, MODIFY and DELETE and try to find out the sum value and update the form.
In the Header I show several textbox (binded with some variable).
One of this textbox must to show Total Amount (sum all rows).
In this textbox I insert function called CalcTotalAmount.
This is the code:
IF Rec.FIND('-') THEN
REPEAT
TotalAmount := TotalAmount + Amount;
UNTIL NEXT=0;
EXIT(TotalAmount);
When I run the form and try to insert more than first record:
1) The problem is that you are looping through REC thus changing the position "in background"...
2) Try to restore the original Rec after the loop (backup it at beginning and restore it after that just by :=)
RecBackup := Rec;
IF Rec.FIND('-') THEN
REPEAT
TotalAmount := TotalAmount + Amount;
UNTIL NEXT=0;
Rec := RecBackup;
EXIT(TotalAmount);
Comments
here is many help search forum.
http://midynav.blogspot.com/ (Microsoft Dynamics Navision)
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
my table is:
10 "Line No." Integer (Primary Key)
20 "Description" Text
30 "Amount" Decimal
In my form property Autosplitkey=Yes
No subform!
In the Header I show several textbox (binded with some variable).
One of this textbox must to show Total Amount (sum all rows).
In this textbox I insert function called CalcTotalAmount.
This is the code:
IF Rec.FIND('-') THEN
REPEAT
TotalAmount := TotalAmount + Amount;
UNTIL NEXT=0;
EXIT(TotalAmount);
When I run the form and try to insert more than first record:
Error: Tablexxx (my table) "Line no." '10000' already exists.
How I solve it? ](*,)
2) Try to restore the original Rec after the loop (backup it at beginning and restore it after that just by :=)
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.