Sure.
However i thought of maybe an even simpler solution…
Maybe you can change MonOwed to be an integer… (I would assume that all payments at either done or not, so that it is not possible to have 1.5 payments)
In that case you could maybe assign the filter from the user, to a global record-variable of type Integer, and by playing with the FIND’s you could determine if the MonOwed you have just calculated falls inside or outside the filter given by the user (Do this test in the OnPreSection-trigger of the section you want to print MonOwed, and supress printing the section if needed by use of CurrReport.SHOWOUTPUT).
But back to my original suggestion…
You already have a report, in wich you at some point calculates the MonOwed-variable.
(I assume it has a simple structure with just one dataitem, and in my example it is Customer)
In this report (or a copy of it [;)]) you need to add the following…
A new dataitem of type integer at the end of the report. (This is the one i mentioned where the actual printing will be done.)
A new global variable: TempRec - Record - Customer (REMEMBER TO MAKE IT TEMPORARY!! Properties → Temporary = yes)
(I choose the customer-table because then you will have all fields available if you need more info about the customer printed, besides the customer no. You need to choose a field that you don’t need, to store the MonOwed-value, I choose “Credit Limit”… Maybe you could get better performance of the report by choosing another table as TempRec)
A new global variable: MonOwedFilter - Text30 (This is the one you set as SorurceExpr on the control in the request form)
A new global variable: TempRecCount - Integer (This one is used for storing the number of records that fall within the filter)
In the OnAfterGetRecord-trigger of Customer-dataitem put some code like this at the end…
TempRec.INIT();
TempRec := Customer;
TempRec.“Credit Limit” := MonOwed;
TempRec.INSERT();
In OnPreDataItem-trigger of Inter-dataitem put some code like this…
TempRec.SETFILTER(“Credit Limit”,MonOwedFilter);
TempRecCount := TempRec.COUNT;
SETRANGE("Number,1,TempRecCount);
In OnAfterGetRecord-trigger of Integer-dataitem put some code like this…
IF Number = 1 THEN
TempRec.FINDSET(FALSE,FALSE)
ELSE
TempRec.NEXT;
Now all you need to do is to make the layout of the report in the sections of the Integer-dataitem, instead of in the sections of the Customer-dataitem.
(Remember to use TempRec as SourceExpr in all controls, not Customer)