Figure 8-11

If you'd like to have a closer look, the complete report is available in the download file for this chapter. Compile and run the report—but don't be alarmed if you get a nasty surprise!

Does your report look similar to the download? Probably not—there's one little trick that we forgot. Since the periods we used in this report are built from the current date and evaluated against the sample data (which is at least a couple of years old), the chances are that your MTD and YTD columns will be empty. Happily, you can set the system date in Crystal Reports by right-clicking the report, selecting Report ^ Set Print Date, and entering a new date and time, as shown subsequently.

This allows you to change the internal date and time used by Crystal Reports to build the time periods and some other date- and time-driven functionality. After setting the date, Crystal Reports will think that it's actually processing the report on that date and behave accordingly. (This is especially handy if you need to do point-in-time reports.)

In our case, if you set this date to 07/01/2001 or 20/12/1997 (either of these dates should be compatible with the sample data), your report should show both the MTD and YTD columns with the totals for each customer.

Print State and Document Properties

Crystal Reports has a number of special fields and properties that are generated by the system when a report is run. You will have already encountered some of these fields when adding page numbers or summary information such as the report's title, author, and so on.

Here is a list of these types of functions:




The value of the previous field to appear


The value of the next field to appear


Tests whether a field is null


Tests whether the previous field value is null


Tests whether the next field value is null


Returns the current page number


Returns the total page count


Returns the current page number of the total page count


Returns Crystal Reports internal reference of record number


Returns Crystal Reports internal reference of group number


Returns the current record selection formula for the report


Returns the current group selection formula for the report


Returns a True value when the first record is displayed


Returns a True value when the last record is displayed

Using these functions, you can quickly create formulas that can mark new records in a sorted list:

If Previous({Customer.Customer Name}) <> {Customer.Customer Name} Then Formula = "New Customer Starts Here"

or, you could print a text message at the end of your report:

If OnLastRecord = True Then Formula = " ***** END OF REPORT ***** "

Was this article helpful?

0 0

Post a comment