Monday, February 29, 2016

Crystal Reports : Why should you care about Subreporting?

I have a love/hate relationship with Subreports. It's true, I owe them mightily for the occasional bailout from bad situations. They are an excellent method to display data from somewhere completely unrelated in a quick-and-dirty way.

Simply, this is way to insert a Crystal Report inside another. Think about it like inserting an image file into a document. The subreport is for all intents and purposes, its own full-blown crystal report.

The two reports can be related via "links", or they can be completely separate. When a subreport is linked, you can pass things like parameters to it. So, if your "Main" report is prompting for a Date Range, you could then pass on that same selected Date Range to a subreport parameter. This is what I personally struggle with sometimes. 

However, if they are separate (not linked) it's simply a way to have two or more reports all embedded into one "main" report. I've seen this used a few times in the field, and it can be useful.

But the more experience I got with Crystal and SQL, the more I found myself using alternative methods to get and display data. Subreports are often used when you're trying to work yourself out of a corner; in a perfect world, all your data is returned as relatable (i.e. joinable) tables or views. If this isn't the case, it's almost always better to fix the underlying problem rather than clutch at subreports out of desperation.

It's because of this that subreports are rarely used. Consequently, I find myself having to learn them "all over again" from time to time.

So, here are a few things I consider when getting ready to us a subreport;

- Do I need to use a subreport to return my data? Is it otherwise accessible via a table or view?

- Once I add a subreport, it becomes a little difficult to get formatting to look just right. I might find myself spending hours fine-tuning the appearance of the layout.

- Embedded subreports can be confusing to modify after-the-fact. They appear in the "main" report as objects, and must be right-clicked and edited in a separate tab. If I open a mess of tabs in Crystal, I might lose track of where I am and start editing the wrong thing.

- Subreports will add time to the report refresh duration.

And now, without further adieu, we can move on and actually see how they work.


aliya seen said...

The nursing application personal statement is best for making reports and assignments. You can write perfect statement.

sunk818 said...

I had a very complicated reported (SQL heavy, lot of date calculations, etc). I ended up using a sub-report to separate out the query. In some instances, I'd advocate for sub-reports to help divided the performance load. Having two separate data sources and have them linked on the Crystal level is extremely inefficient. So, having a sub-report as way to join the data can sometimes be the better approach.