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

Usage of a copied report & not available DBfields anymore

edited December 2009 in General
Hello,

in my application the user can desing and use several reports for different
tasks.
Example: a report for an offer and one for an invoice.

It's likely that those reports will have some similar parts, so once the
user designed one of those reports, I would like to give him the possibility
within the application to copy this report and to use it as a basis for
other reports.

The problem is, that there will be not only similar parts, but also
different parts - mainly the assigned DBFields. That's where the trouble
begins.

Example:
an offer has a field "offerno", which is used in the report of the offer.
The invoce has for that purpose the field "invoiceno". Both have the same
purpose, but different fieldnames and values. So the pipeline of the invoice
doesn't have a field "offerno" in its fields. RB can load such a report,
even if the pipeline doesn't have one or several fields. The report element
has that missing DBFiled assigned (no alias, but the real fieldname).
If I save / preview such a report under such circumstances, an error occurs
(per missing field). It's in the IDE only, but still.

So here I have the following options, I think:
1) Search for the elements with missing DBFields and reassign them
2) Have RB to remove the assigned DBFields, if they can't be foung in the
pipeline
3) To react in my application once such an error occurs and to offer the
user to choose another field or something like that
4) Anything else (better), which I've missed here?

In all 3 cases I'm not that sure how to proceed...

1) Such fields can be assigned not only to elements like DBText or DBMemo,
but also to ppGroups etc. What is the best way to find all such elements /
fields? Working with ComponentCount, checking of the class, checking if the
assigned DBFiled can be found in the pipeline?

2) Is there a way to achieve that? At least that would cause all the error
in the background.

3) Are there any events to react to such errors and methods to handle them
somehow?

4) A great thing would be, if RB could offer a dialog with such "missing"
fields, where the user can choose other, currently available fields instead
of those missing fields. Maybe it's worth it to be considered as a potential
feature ;)

Hope you know what I mean and can help me.

Regards,
Mark

Comments

  • edited December 2009
    Hi Mark,

    1. The easiest way to resolve all incorrect field references would be to
    use a report object loop. For each component that has its IsDataAware
    property set to True, you can further manipulate to meet the new dataset's
    needs.

    For groups you can loop through the Report.Groups list.

    http://www.digital-metaphors.com/rbWiki/Delphi_Code/Layouts/Report_Object_Loop

    2. Another option that could be achieved manually using a report object
    loop.

    3. There are no events that fire directly before a pipeline tries to resolve
    each field. If a field cannot be found, I believe an exception is thrown
    however once this occcurs it may be too late to change it. You essentially
    would need to do all this processing before the pipeline is opened to be
    sure all fields are valid. BeforeOpenDataPipelines perhaps?

    4. Thanks for the suggestion.

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited December 2009
    Correction to number 3: There is no exception raised when a field name is
    incorrect. The report will print with an empty DBText.

    --
    Regards,

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

    Best Regards,

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

    I was just wondering, if there are other ways to accomplish that, but the
    solution with the report object loop seems to work fine.
    The exception of #3 might have been raised from the DataSet, since such a
    field is not in it, but as I said: with the loop everything I need can be
    done so far I see it.

    Thank you and kind regards,
    Mark

This discussion has been closed.