Monday, April 2, 2012

Crystal Reports : Controlling Report Sections with Parameters

Here is something I found when working for a client recently. They had one Crystal Report that listed out Phone Calls from a database and then provided some summary information for each Customer that was called.

In this case, Management only wanted to see the Summary (Group Header and Footers) portion of the report. The Sales Reps need to see the list of Phone Calls (Detail Section).

So, this is easy, right? Just have two reports and Suppress the appropriate Sections. But this makes administration tedious. Simple tasks like adding a single field become doubled in time spent.

A better way could be to only have one report, and have it prompt the end user for "Details" or "No Details". Here is how you could do it;

1. Create a Parameter called {?DetailChoice}

2. Make {?DetailChoice} a simple drop down list with only two available values; "Detail" and "No Detail"

3. Open your Section Expert by right-clicking on the left-hand side of your section separators in the Crystal Designer, then selecting "Format Section"

4. Select the Details section

5. Check the box labeled "Suppress (No Drill Down)"

6. Click the "X-2" box next to it to specify a condition

7. In the Formula Editor, paste in the following code:

{?DetailChoice} = "No Detail"

8. Ok your way out

Now, when you refresh your report, you can select whether or not to Suppress the Detail section (Phone Calls). Select "No Detail" to Suppress the Detail Section. For me, this opened up a whole new world of Report efficiency.