Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

‘Road Not Taken’ error

Status
Not open for further replies.

Madawc

Programmer
Sep 5, 2002
7,628
GB
My workplace is currently upgrading from Crystal 8.5 to Crystal 10, both using databases created using SQL 8. A problem occurred with a report that had been running for more than a year with no problems before the upgrade. It does not use the parameters directly: instead it checks them and assigns a value if they have not been entered:
Code:
if isnull ({?Date_To})
or {?Date_To} = date(0,0,0)
then {DateControl.DateStamp}
else {?Date_To}
This is something which I wrote while I was much less experienced in Crystal, and I'd do it differently now. After all, a date parameter always defaults to the current date. But it was still very surprising that it caused a blank to be displayed, even though no attempt was made to use the value in question.
Upon investigation, I found that there were no problems if the reference was to a Null value in an existing record. But for unknown reasons, no records were being read for the DateControl table. And when there was no such record, the ‘road not taken’ formula. And the same thing happens in Crystal 8.5; if there are no occurrences of a record, a conditional reference to it kills the formula even when it is not used.

I'm re-writing the report so that the problem should not occur at all. But does anyone understand what's going on here?


[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
My means to handle this across the various ways one might call a report and versions is as follows, BTW, a date parametr does NOT always default to the current date if the parameter isn't slected by the user:

Prepopulate the parameter with a date that would never be selected, for instance 1/1/1970

Alter your code to:

if {?Date_To} <> cdate(1970,1,1) then {DateControl.DateStamp}
else
{?Date_To}

The purpose of the code eludes me other than to display some value, it doesn't limit rows, if this is intended for the record selection formula, it would be a bit different than the above.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top