Sum quantity field in subform PurchaseLines

I have 3 lines in my purchase line form, each one with 2, 4 and 10 in Quantity feld.

In my 4ª Line of Subform Purchase Lines, I want to sum the other 3 quantity lines , in Quantity field of this 4ª line.


line 1 Quant = 2

line 2 Quant = 4

line 3 Quant = 10

line 4 Quant = 16 (2+4+10)

How can I do It in the Form 54 (subform purchase lines)?

You have a couple of options. You can add a flowfield to the t_39 definition that will represent this value. The calcformula would be of type Sum, operating on the Quantity field, and filtering so that document type and document no. match the current record , and the line no. value is less than the current line. This will basically create a field with a running subtotal of the quantity field.

Another option would be to create a function in the table that basically returns the same value, and add a control to the list form that displays the value of the function return. Using this option, you would not get the use of the drilldown feature that you get with a flowfield, but that’s a moot point if your primary intent is to use this value on a report.

In either case, be careful what you wish for. If you just run a straight sum process without regard to the line types and Nos., you may be adding apples and oranges.

Hope that helps.

Th first option is OK, I created a new flow field RecSum and I will filter to sum the lines type= Item.

When I insert the line Type = Charge Item, I want that new field calculated to be inserted in Quantity field.

Where can I say in form Purchase Lines, that Quantity in the line Type = Charge Item isal to RecSum?


There is a function that does most of what you are trying to do. Look at that function and work out how to customize what you are trying to do. DO NOT put code like this on a form under any circumstances.