This is a quick post, showing how to create striped rows that increase the readability of a report, and a few other points along the way.
- Crystal Reports for Enterprise (CRE) BI4.0 SP02
- Microsoft's AdventureWorks database
- A UNX universe (required for use with CRE).
- That you have a UNX universe created.
- That you have Crystal Reports for Enterprise (CRE) or Crystal Reports 2008 or Crystal Reports 2011 installed. The screenshots are in CRE, but the steps are very similar in old-school Crystal.
First, the base report. This is close to how my report appears if I simply drag the objects onto the page.
It does the job, but is fairly unremarkable. So…
- Right click in the body section of the report and select Format Section…
- Next to the Color option, click the formula icon. If you're not familiar with Crystal, these little icons allow you to set the value of a property at run-time with code.
The formula workshop will open up. This is largely the same in CRE as it is in CR 2008/2011.
- Enter the following code:
- Click Save and Close down in the bottom right.
- Click Close to the format window. You should now see something like this:
- Lastly, I'll add a line and set the header band and major fonts to blue.
Remainder is just like Mod, except it's called Remainder. RecordNumber is a sequential number that increments with each new row. This is a quick way to check if the row is an odd or even number. The logic then colours the background differently for odd and even rows. If you're new to Crystal syntax, remember that the formula you write must result in something that makes sense to the property that you're setting. In this case, that's a colour (or color).