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

Preview OK but no data when print

edited April 2010 in Subreports
Hi,

I have a report with 4 datapipelines link to 4 in-memory TClientDataset
(cds1,cds2,cds3 & cds4).
ClientDatasets are not linked to any table and the data was populated
manually during run-time.
I created a report with no header & footer (datapipeline set to blank) and
have a subreport in the detail band.

Sub report datapipeline is link to one of the cds.
KeepTogether set to False.
PrintBehavor set to pbSection.

When I preview the report everything shown as per expected.
When Click on print or set printdevice to 'Printer' the report printed with
no data.

I suspect the cds is at eof when RB is trying to print it.
I tried set cds.First during report.beforePrint but did not solve the
problem

Please help.
Shely

Comments

  • edited April 2010
    RB version 10.04
    Delphi 2006

  • edited April 2010
    Hi Shely,

    The fact that you are able to see the data when you preview and not when you
    print indicates that there is some different code running for the print
    option. Are you able to print directly without previewing first?

    The Datapipeline simply traverses the data as is. As a test, you might
    connect a DBGrid to your client dataset and see where the cursor is when
    printing the report to the printer. This may give you some clues on what
    exactly is happening.

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited July 2010
    Hi Nico,

    I am not able to print direct without preview it.
    If print direct, the report is blank. The report only comes out perfect when
    in preview.

    Pls help
    Shely

  • edited July 2010
    Hi Shely,

    Did you try connecting your datasets to a DBGrid to see if ReportBuilder is
    actually able to access the data? Are you able to recreate this behavior
    using a minimal application that I could run on my machine? If so, please
    send it in .zip format to support@digital-metaphors.com and I'll take a look
    at it for you.

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited July 2010
    Ni Nico,

    Very strange is that I copied all the report component, client datasets to a
    new test application and print from there and it works. The only different
    is the test app load the data from file but the actual app is appending the
    data into the client dataset during run time.

    I tried using Dbgird to show the data on screen it shown correctly (using
    the same datasource as the report data pipeline).
    When in preview the data also displayed correctly just when print it says no
    data for the report (be it direct print or print from preview screen).

    I do not know where else to look at. This problem had been bugging me for
    long time.

    Shely

  • edited July 2010
    Hi Nico,

    I use another method and it works.
    The sequence of process:

    1. Create a new client dataset (cds2) with exact structure as cds1
    2. Call cds2.loadFromFile to load the pre-save data (C:\cds1.dat) .
    3. Call cds1.createdataset and append data into cds1
    4. Call cds1.saveTofile(c:\cds1.dat)
    5. Report datapipeline is now set to use cds2 datasource.
    6. Call PPreport to print

    The report prints perfectly with the latest data.
    Could you explain why?

    Shely

  • edited July 2010
    Hi Shely,

    I'm unsure why this is happening however remember that ReportBuilder simply
    retrieves the data that it is given. If no data is showing up for a certain
    dataset, then none is available. You might want to re-check your dataset to
    be sure the data is actually available for ReportBuilder to gather.

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited August 2010
    Hi Nico,

    I found the reason! It is because ReportBuilder re-create the datamodule if
    the report is print to printer.
    If preview on screen the datamodule is not re-create that why the report is
    perfect when preview.
    When print, since ReportBuilder re-create the datamodule and all dataset are
    blank thats why it print blank.
    In my testing app because I load the cds from file during
    datamodule.oncreate that why the report can be printed.

    Shely

This discussion has been closed.