Modifying Print Records function

I have a unique requirement. I need to print an alternate sales invoice report, depending on the value of a boolean on the SalesInvHeader. I wanted to make this a system level-type of function, so I started by adding an option value to the Usage field on Report Selection table, then made an entry for the alt. invoice. Secondly, I went to the Print Records function in the Sales Invoice Header table and modified the code as follows: WITH SalesInvHeader DO BEGIN COPY(Rec); MESSAGE(’%1’,Rec.“No.”); IF “Meter Level Billing” THEN BEGIN CurrUsage := ReportSelection.Usage::“S.Meter Level Invoice”; END ELSE BEGIN CurrUsage := ReportSelection.Usage::“S.Invoice”; END; ReportSelection.SETRANGE(Usage,CurrUsage); ReportSelection.SETFILTER(“Report ID”,’<>0’); ReportSelection.FIND(’-’); REPEAT REPORT.RUNMODAL(ReportSelection.“Report ID”,ShowRequestForm,FALSE,SalesInvHeader); UNTIL ReportSelection.NEXT = 0; END; Note: The MESSAGE call is for debugging. When I click the Print button on the Posted Sales Invoice form, and the boolean is TRUE, I would think that the alt. invoice report would launch? No brainer. But it doesn’t, it always launches the default invoice. The Boolean is never TRUE. I put some MESSAGE calls in there to see what is going on, and I found that the MESSAGE function showing the Sales Invoice Header No. returns a BLANK value. How could Rec be blank or empty? Since Print Records is a system function that could be called from myriad places, I am hesitant to add a Parameter to this function and pass the Boolean that way. For reference, this is the code called with the Print button: CurrForm.SETSELECTIONFILTER(SalesInvHeader); SalesInvHeader.PrintRecords(TRUE); This all seems so simple to me, what am I missing?[:(]

replace: ReportSelection.SETRANGE(Usage,CurrUsage); ReportSelection.SETFILTER(“Report ID”,’<>0’); ReportSelection.FIND(’-’); REPEAT REPORT.RUNMODAL(ReportSelection.“Report ID”,ShowRequestForm,FALSE,SalesInvHeader); UNTIL ReportSelection.NEXT = 0; with ReportSelection.setfilter(Usage,’%1’,CurrUsage); ReportSelection.SETFILTER(“Report ID”,’%1’,’<>0’); if ReportSelection.FIND(’-’)then REPORT.RUNMODAL(ReportSelection.“Report ID”,ShowRequestForm,FALSE,SalesInvHeader);

Yes… you miss something: CurrForm.SETSELECTIONFILTER(SalesInvHeader); IF (SalesInvHeader.FIND(’-’)) THEN REPEAT SalesInvHeader.PrintRecords(TRUE); UNTIL (SalesInvHeader.NEXT = 0);

Thank you Alfonso, that worked…