RecRef in Report

Hi,
I use RecRef type to show date on report (Navision 2016). The code is:

OnPreReport()
RecRefe.OPEN(50000);
FieldRef:=RecRefe.FIELD(4);
IF RecRefe.FINDFIRST THEN
REPEAT
EmployeeNo:=FieldRef.VALUE;
UNTIL RecRefeR.NEXT=0;

When I show EmployeeNo on report I only get the last value, but I need list of all employees. How to solve this?

Best regards

  • Variable
    Table50000 record Table 50000
    i integer
    j integer
    emplyeearr code 20 Dimension in property 100
    Onprereport
    Table50000.reset;
    if table50000.findset then begin
    i := 1;
    repeat
    employeearrIdea := table5000.code;
    i := i + 1;
    until table50000.next = 0
    end;

    Onaftergetrecord
    for j := 1 to i -1 do begin
    Use empolyeearr[j]
    end;
  • In reply to sbhatbng:

    the lightbulb you see is 'Idea', not sure why it put the variable like that.
  • In reply to sbhatbng:

    Thanks!
    I do not have access to table 5000 so I need to use RecRef type and I need to set all code on OnPreReport().
  • When you read the values in OnPreReport you are reading and replace/writing to same variable [EmployeeNo:=FieldRef.VALUE;]. Hence when the loops finishes, only the last read value is stored in it and that is displayed when the report prints.

    You must write the code in OnAfterGetRecord to read the records one by one or you must write this information into Array or temp table and read that Array or temp table in the OnAfterGetRecord trigger of a Dataitem.
  • use integer as dataitem.
    write code below in opredataitem:
    RecRefe.OPEN(50000);
    FieldRef:=RecRefe.FIELD(4);
    IF NOT RecRefe.FINDSET THEN;
    CurrReport.BREAK;
    SETRANGE(NUMBER,1,RecRefe.COUNT);

    write code below in opredataitem:
    iF Number = 1 Then
    RecRefe.FINDFIRST
    ELSE
    RecRefe.NEXT;

    EmployeeNo:=FieldRef.VALUE;
  • Why you have written your code on OnPreReport()??
    This trigger will execute only once.

    Move your code first to OnAfterGetRecord and then try.
Related