Passing filter to a report

Hi, maybe this has been discussed before, but I can’t find it. How do I pass a record filter to a report called by r.RUNMODAL? I want the report run only on the records selected on the calling form. Thanks Anna

  1. If you need to set filters on DataItem: You can set all your filters on a variable of record type before calling report and then use parameters of RUNMODAL: REPORT.RUNMODAL(Number [, ReqWindow] [, SystemPrinter] [, Record]) For example: Employee.SETFILTER(“Country Code”,‘IT’); REPORT.RUNMODAL(5201, TRUE, FALSE, Employee); You can use it only if your report contains only one DataItem of this record. 2) If you need to pass data to RequestForm: You can create function in report with parameters you need to pass and call it before report run (this function will save parameters you passed to variables you need): EmployeeReport.InitParameters // This is function you created EmployeeReport.RUNMODAL(5201);

quote:


Originally posted by Arthur

  1. If you need to set filters on DataItem: You can set all your filters on a variable of record type before calling report and then use parameters of RUNMODAL: /snip/ 2) If you need to pass data to RequestForm: You can create function in report with parameters you need to pass and call it before report run (this function will save parameters you passed to variables you need):

Hi, Arthur. Thank you for your reply. Actually, my problem is that I’d need both to set filters on the (THE) DataItem and to pass data that would normally entered in a RequestForm. After fooling around for a while, I resorted to copy the code in the OnAfterGetRecord trigger of the report unique DataItem into a function in the calling form and have the form do all the work, without using the report anymore. It works, but I still wonder if it wouldn’t be possible to pass filters and variables values from form to report. Anna

quote:


Originally posted by Anna Perotti
It works, but I still wonder if it wouldn’t be possible to pass filters and variables values from form to report.


Hi Anna, This can be accomplished using SETTABLEVIEW, e.g.:CLEAR(EmployeeReport); EmployeeRec.SETFILTER(EmployeeRecField, MyFilter); // DataItem Record EmployeeReport.SETTABLEVIEW(EmployeeRec); EmployeeReport.InitParameters // This is function you created EmployeeReport.RUNMODAL(~~5201~~);

quote:


Originally posted by Steffen Voel This can be accomplished using SETTABLEVIEW,


Thank you! [:D] Anna