Crystal Reports SELECT CASE statement

2019-01-29 12:20发布

问题:

I have a switch statement in a Crystal Report that looks like this:

stringvar tag := {table1.field1};  //contains a string value

select tag case
  'First Value': {table1.field3}
  'Second Value': {table4.field9}
  default: 'Unknown';

But when I try to save the formula, I get this error:

---------------------------
Crystal Reports
---------------------------
The remaining text does not appear to be part of the formula.
---------------------------
OK   
---------------------------

And it highlights the formula beginning with the single quote before the word "Second" in my example.

What stupid syntax error am I making?

回答1:

Shouldn't this be written as...

select (tag )
  case 'First Value': {table1.field3}
  case 'Second Value': {table4.field9}
  default: 'Unknown';

?
Note, I just looked the syntax online; I'm not a Crystal Reports specialist...