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

Printerdevices

edited February 2002 in General
(Rep = TppReport)
--------Code--------
if FindReportPrinter(ininaam,'Voorbeeld') = 'Ja' then
begin
rep.DeviceType := 'Screen';
end;
if FindReportPrinter(ininaam,'Voorbeeld') = 'Nee' then
begin
rep.DeviceType := 'Printer';
end;
try
if FindReportPrinter(ininaam,'Selectie') = 'Ja' then
begin
rep.ShowPrintDialog := true;
end;
if FindReportPrinter(ininaam,'Selectie') = 'Nee' then
begin
rep.ShowPrintDialog := false;
end;
finally
rep.ResetDevices;
rep.PrinterSetup.DocumentName := Application.Title + ' ' + ininaam;
rep.print;
end;
--------Code--------

When used this code gives me irregular results in my delphi program. One
would assume that if you use this code and the result of the function
FindReportPrinter(ininaam,'Voorbeeld') is 'Ja' (dutch for yes) or
FindReportPrinter(ininaam,'Selectie') is ja that you would get a preview
dialog and
a printersetup dialog. This is true and works ok. If I get Nee and Nee you
should assume that the report would go directly to the printer, without a
preview screend and without a printersetup dialog. Unfortunately that doesnt
work all the time :(. Some times it does go directly to the printer and some
times it does not, then I first get the dialog that mentions the report is
going to the printer, then i get a preview. Other times i get a preview and
then nothing.

This is very irritating offcorse :). I tried putting a resetdevices before
the print but doesn't suffice and does not solve the problem. What could I
do that i just
let the report do what I tell it to! (listen to the master! @#$%# :))

Help!

Comments

  • edited February 2002
    Ow i found out something much more funny. Btw the code I gave in my former
    message, is called upon in the 'beforeprint' event. But now i found out that
    if i change a setting so 'ja' will be 'nee', the first time i try to print
    it uses the old parameters and the second time i print it will use the new
    parameters. So i presume the event where the code is called, is wrong. What
    event should i try to execute this code then? I'm puzzeled!

    regards,
    Thomas
  • edited February 2002
    The Report.BeforePrint event is the best event to use to configure the
    report object before pages begin generating. However, you might not want to
    call Report.Print inside this event, since you're already inside of a call
    to Report.Print. You shouldn't need to call Report.ResetDevices either.


    Cheers,

    Jim Bennett
    Digital Metaphors

  • edited February 2002
    Unfortunately that doesn't help me :(, still there is no good response to
    not letting the printdialog and the preview display show the first time. I
    even tried with closing the program and restarting it. That didn't give the
    desired result eather.

    :(


  • edited February 2002
    What does FindReportPrinter do? It may be possible that the value it reurns
    is always causing the if statements to evaluate to false? Then since you
    have no 'else' to catch a problem, the Report.DeviceType may not be getting
    set correctly. I can't reproduce the problem, it is always working correctly
    here. Can you send a working example to support@digital-metaphors.com which
    shows this problem.

    Cheers,

    Jim Bennett
    Digital Metaphors

This discussion has been closed.