If a user selects several lines on a form and uses control f1 to mark the records is it possible to display the sum of a particular field? Ex. user selects and marks several sales lines. User wants to know the sum of the quantity field for sleected (marked) lines. Thanks
All you have got to do is to COUNT your MARKED Records : Put a button on your form and add this two lines of code on the OnPush() trigger : YourRecord.Marked(TRUE); MESSAGE('There is %1 records which are MARKED, YourRecord.COUNT); YourRecord.Marked(FALSE); You may need to adapt this considering the requirement of your customer. ###### email@example.com
I think you mis-understood. I want to get the sum of the quantity field of just the marked records as selected by the user. Thanks
Hi, depending on how the info should be displayed you need to run this code and show the variable “Total” in a field or message.
Total := 0; YourRecord.Marked(TRUE); IF YourRecord.FIND('-') then REPEAT Total := Total + YourRecord.Quantity; UNTIL YourRecord.NEXT = 0; YourRecord.Marked(FALSE);
Saludos Nils Edited by - nilsm on 2002 Jun 07 21:10:07
That is similar to the code I tried. Here is the code the “marked1” shows “0” on the message. (Note the user is selecting and marking the lines to be totaled manually.) CLEAR(mark1); MARKEDONLY(TRUE); IF FIND(’-’) THEN BEGIN REPEAT mark1:=“Remaining Qty.”+mark1; UNTIL NEXT=0; MESSAGE(‘The Sum for Marked Records = %1’,mark1); END; MARKEDONLY(FALSE);
I figured it out. Here is the correct code. CLEAR(mark1); MARKEDONLY(TRUE); IF FIND(’-’) THEN BEGIN REPEAT CALCFIELDS(“Remaining Qty.”); mark1:=“Remaining Qty.”+mark1; MARK(FALSE) UNTIL NEXT=0; MESSAGE(‘The Marked Records Remaining Qty. = %1’,mark1); END; MARKEDONLY(FALSE);