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

Need to cancel report from OnNoData

edited May 2004 in General
Is that possible?

In the OnNoData event I would like to cancel the report.

I tried using Report.Cancel, but the report still shows up even though it is
empty.

Is there a way to do that? Essentially I would like to bring up a message
"No data for this report... etc" and then cancel the report, i.e. not show
it at all.

Thank you.

Comments

  • edited May 2004
    I don't have Delphi up but try setting a flag in OnNoData (FCancelReport :=
    True) then in the OnCreatePreviewer post a WM_CLOSE message to the
    previewer.
    --
    Ed Dressel
    Team DM
  • edited May 2004
    Thank you for your reply.

    However FCanceReport property or OnCreatePreviewer event do not exist in my
    version - 6.02 Enterprise.

    Is there some other way to cancel report if there is no data? Basically I
    would like to show a custom message to the user and that is all.
    When I bring up the custom message via the OnNoData event, the report still
    comes up after that and is empty.


  • edited June 2004
    Hi John,

    If you do not want the report to show up at all, I would suggest simply
    checking your dataset before calling Report.Print for no records. Something
    like the following...

    - Using TQuery...

    if (Query.RecordCount = 0) then
    ShowMessage('No Data for this Report')
    else
    ppReport1.Print;


    - Using DBPipeline

    if (ppDBPipeline.BOF) and (ppDBPipeline.EOF) then
    ShowMessage('No Data for this Report')
    else
    ppReport1.Print;

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.