why use beforereadingrecords / whilereadingrecords / whileprintingrecords in crystal reports?

10,237

The end result will not always be the same and omitting evaluation time functions can sometimes lead to incorrect results. For example, consider that you have a report that is grouped and that you are trying to calculate simple subtotals for these groups with a variable. Say you are resetting the variable in the group header and displaying it in the footer while updating it in the details section via:

numbervar subtotal;
subtotal := subtotal + {table.numericvalue}

Crystal will evaluate this formula while reading records and before the records are in a predictable, grouped, and sorted order. It's not until the second pass, the whileprintingrecords pass, that records have been grouped and sorted. That's why group selection happens in this pass.

This is just one example, but there are a number of ways to break a report by omitting evaluation time functions, mostly having to do with using variables (at least that I can think of). Here is a great resource for details on Crystal's multiple passes: The Multi-Pass Reporting Process of the Crystal Reports Engine

Share:
10,237
tdjfdjdj
Author by

tdjfdjdj

Updated on June 05, 2022

Comments

  • tdjfdjdj
    tdjfdjdj almost 2 years

    I know crystal reports has 3 phases when it renders a report, and depending on the phase it may read static data or grouped data fields etc, but is there any benefit writing formulas in any of these phases? The end result should always be the same if I specify the phase or not?