Passing variables to request form of report

Hi all!
Our company is still working with the Classic Client and 4.0 database. I've a question about passing data into variables on a request form.
  • I have a tabular form which has the table Sales Line as source
  • On this form I have a button which sets the filters to the record which is selected on the form and based on this record, it runs runs a report
lRecSalesLine.RESET;
lRecSalesLine.SETVIEW(Rec.GETVIEW);
lRecSalesLine.COPYFILTERS(Rec);
lRecSalesLine.SETRANGE(lRecSalesLine."Line No.", "Line No.");
lRecSalesLine.SETRANGE(lRecSalesLine."Document No.", "Document No.");
lRecSalesLine.SETRANGE(lRecSalesLine."Sell-to Customer No.", "Sell-to Customer No.");

REPORT.RUNMODAL(50008,TRUE,FALSE,lRecSalesLine)
  • I want to have a textbox on the request form that, upon running the report, gets the default value from the field "Sales Line".Quantity (the idea is that each sold product gets a label attached on the box, so sold quantity is mostly the amount of prints)
  • The reason that I want it in a textbox on the request form, is that I want to be able to change the amount of prints if needed (Some customers want labels on both sides, for example)
  • The part that handles the multiple prints works fine already: the problem is that I can't get the value to the request form .
  • I've created a Global Variable 'NoOfCopies' of the type integer
  • I've created a text box, which property 'SourceExpr' is 'NoOfCopies
  • When I click on a blank part of the request form, and click on C/AL code, I get the section 'Report - OnInit()'. In this section I put the code
NoOfCopies := "Sales Line".Quantity;
  • When running the report the value of NoOfCopies stays '0'
  • If I replace the code with 'NoOfCopies = 3;' the value of NoOfCopies on the request form is 3

Can someone please tell me what I'm doing wrong? I think it is just something small, but I can't figure out, what I'm doing wrong.
Thanks in advance!
"Make it idiot-proof and someone will invent a better idiot..."

Best Answers

Answers

  • danielbouwmeesterdanielbouwmeester Member Posts: 22
    Thanks very much, both of you: it's working now! I've created both a 'set'-function and a 'get'-function. I've another question:

    I've set up a report variable, and this is working now: but now I want to use multiple reports. I've created an If-Then routine to choose between multiple report variables, but can't this be done easier? When calling the function I have a integer parameter with the reportnr., which I want to use, so maybe this can be used?
    IF recLabelLayoutJVDO.ReportID = 50008 THEN BEGIN
      CLEAR(report50008);
      report50008.SETTABLEVIEW(lRecSalesLine);
      report50008.USEREQUESTFORM(TRUE);
      report50008.RUNMODAL;
    END ELSE IF recLabelLayoutJVDO.ReportID = 50009 THEN BEGIN
      CLEAR(report50009);
      report50009.SETTABLEVIEW(lRecSalesLine);
      report50009.USEREQUESTFORM(TRUE);
      report50009.RUNMODAL;
    END ELSE IF recLabelLayoutJVDO.ReportID = 50010 THEN BEGIN
      CLEAR(report50010);
      report50010.SETTABLEVIEW(lRecSalesLine);
      report50010.USEREQUESTFORM(TRUE);
      report50010.RUNMODAL;
    END ELSE IF recLabelLayoutJVDO.ReportID = 50011 THEN BEGIN
      CLEAR(report50011);
      report50011.SETTABLEVIEW(lRecSalesLine);
      report50011.USEREQUESTFORM(TRUE);
      report50011.RUNMODAL;
    END ELSE IF recLabelLayoutJVDO.ReportID = 50088 THEN BEGIN
      CLEAR(report50088);
      report50088.SETTABLEVIEW(lRecSalesLine);
      report50088.USEREQUESTFORM(TRUE);
      report50088.RUNMODAL;
    END ELSE
      ERROR(textNoLabel);
    
    "Make it idiot-proof and someone will invent a better idiot..."
Sign In or Register to comment.