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

Exception handling printing one record at a time

edited November 2009 in General
Hi,

our application can send ReportBuilder reports via email.
Basically we have a form with a report (ie Invoices) and, when the user
press the "send email" button, we:
1. set the pipeline to print a single record (Pipeline.RangeBegin :=
rbCurrentRecord; Pipeline.RangeEnd := reCurrentRecord)
2. set the report to export to PDF
3. for every record we call Report.Print, get the PDF and send it via email.
Then we move to the next record until EOF.

We also log sending date and errors, if any.

The whole thing works fine despite the following issue.
Suppose the report has an error: in example a TppVariable with something
wrong in the OnCal event (like Value :=
CurrToStr(Pipeline['THIS_FIELD_DOES_NOT_EXIST']))

I would expect a "cannot convert null to currency" error for every record.
So if I try to email 10 records I should get 10 errors inside our log.
Instead:
1. the first record fire the "cannot convert null to currency" exception. It
actually fires twince. The exception get trapped and logged.
2. the following records no more fires exception. Looking to our log
everything is fine, but the attached PDF is invalid: it's only a few KB and
Adobe Reader complains it's empty.

Looks like when the first error raise, successive calls to Report.Print will
fail silently.
(You usually calls Report.Print just once, but because we have to split a 10
records report in 10 single-record reports we call it multiple times).

How can I "reset error checking" and get errors (if any) for every record?

Delphi 2006
ReportBuilder 11.04 Enterprise Edition

Kind regards,
Corrado

Comments

  • edited November 2009
    Hi Corrado,

    This is not a known issue. If you trace into the RBuilder source where the
    exception is thrown, is the code being executed correctly?

    Rather than moving through the pipeline manually, a better method would be
    to simply create a Query and alter the search condition based on which
    record you would like to print (either using parameterized SQL or with
    AutoSearch in DADE).

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited November 2009
    This is a multi-part message in MIME format.
This discussion has been closed.