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

How to avoid a Preview Empty Page

edited November 2005 in General
Hi, When user clicks on a Print buttom on a form, it calls tppReport
Print method, and report is previwed on screen.
But sometimes there is no records to show, and preview screen is
completely empty. How can I avoid to show this empty screen, and show a
message like this:
'There is no records to process'

I've tried to put one or all of these lines on AfterOpenDataPipelines
report event, but with no success:
ppReportTest.Reset;
ppReportTest.Stop;
ppReportTest.CloseDataPipelines;
Thanks.



--- posted by geoForum on http://delphi.newswhat.com

Comments

  • edited November 2005
    Hi,

    Try using the TppReport.NoDataBehaviors property. This is a published
    property available in the Delphi Object Inspector and gives you options to
    display a message on the report or a message box when no data is present.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited November 2005
    I couldn't do it using TppReport.NoDataBehaviors property because it's
    options are correlated each others and there is no possibility to set
    them all FALSE.
    So, with no data I always get a single blank page displayed on the
    standard Print Preview form, there is no possible combinations to avoid
    it.
    It's easy to check for no data AfterOpenDataPipelines, and then
    displaying a message with code, but apparently there is no way to stop
    the process and avoid the single blank page that follows it.


    to



    --- posted by geoForum on http://delphi.newswhat.com
  • edited November 2005
    Hi,

    What exactly would you like to happen? Why not just close the preview form
    automatically if the no-data case is true?

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited November 2005
    >Hi,
    I would like the preview form not to be openened, since it is completely
    blank

    true?
    How to do it automatically (without having to click on Close button)?

    Thanks,
    Roberto freitas

    present.
    show a



    --- posted by geoForum on http://delphi.newswhat.com
  • edited November 2005
    Hi Roberto,

    You could check the datapipeline or dataset before calling Report.Print to
    see if there is any data available. If not, then simply do not call
    Report.Print and display a message.


    Try:

    Report.PreviewForm.Close;

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited November 2005
    >You could check the datapipeline or dataset before calling Report.Print
    to see if there is any data available. If not, then simply do not call
    Report.Print and display a message.

    I can't do this way because I use BeforeOpenDataPipelines event to apply
    custom parameter values to SQL and generate custom SQL.


    I've tried it, but it doesn't close the blank preview page.

    Anyway, I'll give all this stuff up, unless you have yet another
    sugestion.
    Thank you.
    Roberto

    completely
    is
    avoid
    stop
    published
    options
    tppReport
    AfterOpenDataPipelines



    --- posted by geoForum on http://delphi.newswhat.com
This discussion has been closed.