Home End User
New Blog Posts: Merging Reports - Part 1 and Part 2

Direct to Printer?

edited August 2007 in End User
Hi Guys,

Using the following...

MyExplorer.LoadReport('Test Report', 0);
MyReport.Print;

How do i get the report to go directly to the printer rather than via the
print preview dialog?

I have set the MyReport DeviceType property to Printer but it didn't make any
difference.

Regards & TIA,

Ian

--

Comments

  • edited August 2007
    Ian Branch wrote:


    Set the ShowPrintDialog property of your ppReport to false

    HTH

    Arno

    --
  • edited August 2007
    Arno Verhoeven wrote:
    Hi Arno,

    It wasn't set at design time and just to be sure I set it to false at run time
    and I still get the dialog.

    Regards,

    Ian
    --
  • edited August 2007
    OK - Found it. I had to specifically set the DeviceType to Printer in code as
    well.

    MyExplorer.LoadReport('Test Report', 0);
    MyReport.ShowPrintDialog := False;
    MyReport.DeviceType := 'Printer'
    MyReport.Print;


    Regards,

    Ian


    --
  • edited August 2007

    Correct. The report definition saves/restores the published properties of
    the report. So you need to first load the report definition and then set the
    properties.

    --
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited August 2007
    Nard Moseley (Digital Metaphors) wrote:


    Hi Nard,

    Thanks for the validation.

    OK. Next step.

    Same report, has a DataPipeline called Invoice. Invoice has a Search Criteria
    of invnumb = 10.

    Once the report is loaded via this means, how/where do I change the search
    criteria to say invnumb = 20, before printing?

    Regards & TIA,

    Ian

    --
  • edited August 2007
    OK. I found & have created the following..

    procedure TForm4.MyReportGetAutoSearchValues(Sender: TObject);
    begin
    if (MyReport.AutoSearchFieldCount = 0) then Exit;

    if (MyReport.AutoSearchFields[0].FieldName = 'Invnumb') then
    MyReport.AutoSearchFields[0].SearchExpression := '20';
    end;

    But it keeps popping up the search dialoge, and puts the existing
    'searchexpression, 10, in the dialog. Yes I can change it and it works however
    I need it to simply accept the 20 and continue without the dialog.

    Regards,

    Ian

    --
  • edited August 2007
    Rest, stand down, don't panic...All working now. Small trap for young players
    the field name needs to be of the same case as that in the report.

    "MyReport.AutoSearchFields[0].FieldName = 'INVNUMB'" 'Invnumb' wouldn't work.


    Ian



    --
  • edited August 2007

    // load the report
    MyExplorer.LoadReport('Test Report', 0);

    // configure the report

    MyReport.ShowPrintDialog := False;
    myReport.ShowAutoSearchDialog := False;

    if (MyReport.AutoSearchFieldCount > 0) then
    if (MyReport.AutoSearchFields[0].FieldName = 'INVNUMB') then
    MyReport.AutoSearchFields[0].SearchExpression := '20';

    // print

    MyReport.DeviceType := 'Printer'
    MyReport.Print;



    --
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
This discussion has been closed.