I was googling (with Bing AND Google) like crazy for a solution to this, but didn't find one from any of the open resource sites, so I figured I'd blog about my fix for this to help the next poor dev to come along.
I was getting user feedback that one of the Crystal Reports in an application that I support was intermittently crashing. When I ran the report in Visual Studio, on certain pages of the report, I observed a red X across the whole screen with a white field. Obviously something was very wrong here!!!
It boiled down to that there was a null value being used in one of my formula fields, and Crystal seems to raise an exception for nulls when they are used as part of certain types of formulas and not converted manually to an actual value first. I didn't know which field was causing the issue so I just started a divide and conquer approach. I suppressed all fields and confirmed that the report worked (select a bunch of fields, Right Click... Format Multiple Objects... Suppress). Then I started un-suppressing a few objects at a time until the report started failing again. Now I knew where the problem was (or at least one of the problems).
I then right-clicked one of the formula fields and chose "Find In Formulas" to open the formula workshop. I drilled down to the formula field (it could be in any of the sections) and found the offending one. Note that it could be a "normal" formula field or even one of the special formatting formulas (like "if this field's value is true, format as green").
I believe the "right way" to fix it is to handle NULLs properly using ISNULL() (which returns a boolean unlike the T-SQL ISNULL() ) or another appropriate method in Crystal for each and every one of your formulas. This MSDN article describes that. However, there exists another workaround as well which should be fine for most simple cases. On the top of each formula when you click into the white field where the code actually lives, you can change this box:
To say this:
If you choose "Default Values For Nulls", Crystal will substitute "" for null strings and an appropriate flavor of 0 for numeric fields. Here's some documentation that oddly seems to skip booleans.
This dropdown selection is per-formula, so it might take a lot of work to go through and change every formula in the tree view (don't forget to look at the formatting formulas too!!!), but if your report is crashing with the dreaded red X and you don't know why, this may get it working again.