Bug when using Previous() and Next() in Headers and Footers

Friday 19 June 2026 @ 10:37 am

I found a strange bug in Crystal Reports today. It has to do with the functions Previous() and Next(). These functions normally return the value from either the record just BEFORE the current record, or the record just AFTER the current record.

To see the bug you can download my example report. It is a simple report that lists 31 Order IDs, sorted in ascending order, for one customer group. In the group header and group footer it displays the first and last order IDs.  It also has two formula fields that use Previous() and Next() to display the second order and the next to last order.  Everything works correct as long as the details are shown.

But, if you hide the details to create a summary version of the report, the two formulas show different values. The Next() formula now returns the value of the last order ID while the Previous() formula returns the first order ID.  There is no reason why these formulas should change values after hiding the details, so this is a bug.

Also, if you double-click the customer name to drill down, the formulas now show their original expected values in the drill-down window.

If you use suppress instead of hide the behavior is the same.  However, if suppress using a condition formula instead of the check mark, then the formulas work as expected in both detail and summary layouts.  I tested this in in CR v8.5 (2001) and CR 2016 and got the same results in both, so I assume this is universal, although I have not tested this in CR 2020.

The only solution I have found to correctly display these formulas in headers and footers is to avoid the normal hide/suppress check marks and instead use a suppress condition formula.  Any formula condition works, so here are two simple examples:

If you want the report to allow drill-down to the details (like using ‘Hide’) then use the following as the suppress formula:

DrilldownGroupLevel = 0

If you don’t need the drill-down behavior then you can simply use:

True

Both of these get rid of details while allowing the Previous() and Next() functions to work normally in the summary report.

(For examples of my most popular formulas, please visit the FORMULAS page on my website.)






Comments are closed.

Recrystallize Pro