Yes, all this is in detail. Detail of each purchase needs to stop after my ending inventory quantity is met.
This formula brings the results I want but then keeps listing detail with the maximum @MainFormula (ending inv quantity) thru out the detail. I don't want to show details after my ending inv quantity is met:
IF {#Qty Purchased} <{@MainFormula} THEN {#Qty Purchased} ELSE {@MainFormula}
This is the second formula and it gives me results up to the last record where it should show my ending inventory quantity, instead it shows 0.
whileprintingrecords;
numbervar cnt;
numbervar result;
if {@Qty on Hand} < {@MainFormula} then result := {@Qty on Hand}
else if {@Qty on Hand} >= {@MainFormula} then (cnt := cnt + 1;
if cnt = 1 then result := {@MainFormula} else result := 0)
;result
Once again, thank you for your help!