Crystal Reports SELECT CASE statement

77,230

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...

Share:
77,230
JosephStyons
Author by

JosephStyons

I started out as a professional developer using Delphi and Oracle in a Win32 client-server environment for a manufacturing company. I worked for five years in consulting, implementing solutions for dozens of clients and using many disparate technologies. Since then, I've worked for and with the non-profit industry, building applications that help them move their missions forward. My bread-and-butter is VB.NET and C# against a SQL Server back-end using a SOA architecture. But I can and will use whatever tool gets the job done, and I've had fun doing so with Angular, jQuery, ASP.NET, PHP, and even my own homemade frameworks to deliver solutions against that platform.

Updated on June 09, 2020

Comments

  • JosephStyons
    JosephStyons almost 4 years

    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?

  • JosephStyons
    JosephStyons over 14 years
    You got it - I was just being obtuse today I guess
  • mjv
    mjv over 14 years
    @Joseph I relate to that, I got them days too :-) That's where SO is a fine place: we find an audience for discussing both complicated matter or basic-typos-type-of-bugs on these "foggy days".