Options

get the current record of a report

MorganMorgan Member Posts: 12
Hi everybody,

I run a report from a FORM (based on table A) like that : REPORT.RUN(report_ID,TRUE,FALSE,my_Record_from_table_A);

On the report (also based on table A), i need to get the current record in order to filter a second record based on table B. (1 record form table A is linked to several records from table B... but here isn't the problem)

The report print only 1 page related to my_record_from_table_A
In the present time , it works fine (it print 1 page for record of table A with one field of one record from table B).

But what I want is to let the user choose which record of table B will be use to print.

So i need the current record of table A to filter records from table B with a specific field of the record A, but there is no way to get this record (on the OnPreReport Trigger or another)

I search all the afternoon on the different topics but definitively no appropriated answer. I guest it is not possible but.....

Maybe one of you of a solution

Comments

  • Options
    ArhontisArhontis Member Posts: 667
    Hi,

    I could give you some directions...

    Make a function it the report with a parameter of type text.
    Make a global var like MYFILTER of type text.
    In the function give the parameter's value to that global parameter. i.e.
    SetAFilter(SomeFilter:Text20). 
    BEGIN
      MYFILTER := SomeFilter;
    END;
    
    In the OnPreDataItem of table B, place some code like:
    IF MYFILTER<>'' THEN
       "table B".SETFILTER("Field A", MYFILTER);
    

    Declare a report variable to your FORM and prior the RUNMODAL call the SetAFilter with the desired value and then call the RUNMODAL.

    That way, by declaring functions and calling them, you can pass anything and do alot of tricky stuff.

    I hope that helps... :D
  • Options
    ArhontisArhontis Member Posts: 667
    You could also look at the GETFILTER(field), GETFILTERS and GETVIEW to get the filter of the desired field or the entire record.

    Use that value somewhere in the OnPreDataItem of "table B".

    You could also use the OnPreDataItem of "table B" trigger to filter the B record with a value of a field fro dataitem A, by using
    "table B".SETFILTER("bField","table A"."aField");
    

    Do I get closer to your target that way? 8-[
  • Options
    MorganMorgan Member Posts: 12
    Your first solution seems to be OK. nice done

    In my case, the report isn't directly called by the form. In fact, the form call codeunit 229 (ducument-print) in which is called the report (but in the codeunit there is no var corresponding to the report, report is called through is ID)

    But, of course i also could modify this codeunit to apply your solution...
Sign In or Register to comment.