Variable Passing to the report from current form

I am going thru the codeunits but not able to get the required stuff. Can anybody explain me how we can pass current record which is on the form to the report where i can filter the required record report only ? Example: If i am generating a Purchase Order, how this PO no. can be captured and passed at the report level where i can filter required PO only ?

You can use the following instruction: REPORT.RUNMODAL(Number [, ReqWindow] [, SystemPrinter] [, Record]) See for the help of it. You can transfer the record from a code to a report in it. Ciao!!

Hi, When you call the report, you have to use a record variable that is filtered by the PO no. There is something like this: SalesHdr.GET(“No.”); SalesHdr.SETRECFILTER; REPORT.RUNMODAL(REPORT::“X”,TRUE,TRUE,SalesHdr); SalesHdr is a record variable in the same table as rec variable. I hope that this helps you

If you omit the setrecfilter-line, the code works well too. Thats better, because afterwards you will have a nasty filter on this form. Michael

HI IF you want to pass records then the replies above is the sloution for the problem, and if you want to pass a variable other the records like integer etc then u can write a function on the report, call the function function before running the report, it will server your purpose. hari

quote:


Originally posted by Quasimodo
If you omit the setrecfilter-line, the code works well too. Thats better, because afterwards you will have a nasty filter on this form.


Really? This is supposed to work? [:0] Just a few days ago I was doing this same thing and omitted the SETRECFILTER. The report ran over the entire data set, not just the current record. I then inserted the SETRECFILTER and used a local record variable to save and restore filters before and after the report [xx(] Maybe it didn’t work for me because I passed the form’s Rec - variable???

Okay, just tried it again. If I use Miguel’s code, it works just fine. If I omit the SETRECFILTER, it doesn’t. Instead, the report runs over the entire table, even though one would assume that the GET had narrowed the record’s view to the one single record retrieved by GET. It seems that only the attached filters are passed to the report, not the contents of the record variable. SETRECFILTER creates a filter on the record variable, which is then correctly passed to the report. If you use a local variable instead of Rec, the SETRECFILTER doesn’t destroy the form’s view, so it’s safe to use [8D]

When I generate an HTML- or PDF-File directly from the invoice-form e.g. I use salesheader.setrange(“No.”,“No.”)without setrecfilter and it works fine. Ever tried SETSELECTIONFILTER? Michael

Speaking of SETSELECTIONFILTER, I have always found it a bit confusing (and not quite consistent) that some functions work on the current selection, while others require you to mark the desired records with Ctrl+F1. If all you want to achieve is passing a selection from a form to a report or codeunit, a simple selection (without Ctrl+F1) should always be sufficient, right? Michael, using SETRANGE seems like a good idea to reduce the program by one more instruction, as it sets the filter immediately [:D]