Link to home
Start Free TrialLog in
Avatar of PSERS BIT
PSERS BITFlag for United States of America

asked on

Crystal MUltiple If statements

i am trying to build dynamic grouping in my report using a parameter passed from my vb.net program.  
I can not get a multi line if statement to woek in my formula.  My formula is a follows.
if   {?Group1}  = "STAFF"    then      {CASEHISTORY.CTH_STAFF_RESP} ;
 if  {?Group1}   = "TYPE"     then    {CASEHISTORY.CTH_CASE_TYPE} ;
 if   {?Group1}  = "SUBTYPE"  then      {CASEHISTORY.CTH_CASE_SUBTYPE} ;
 if   {?Group1}  = "SSNO"     then     {CASEHISTORY.CTH_SSNO};
the above 4 LINES compile compiles ok but does not work.   if i only use one line like below it works.
 if   {?Group1}  = "STAFF" then      {CASEHISTORY.CTH_STAFF_RESP};
If i try to use else statements i get syntax errors.
if   {?Group1}  = "STAFF"    then      {CASEHISTORY.CTH_STAFF_RESP} else  
 if  {?Group1}   = "TYPE"     then    {CASEHISTORY.CTH_CASE_TYPE} else
 if   {?Group1}  = "SUBTYPE"  then      {CASEHISTORY.CTH_CASE_SUBTYPE} ELSE
 if   {?Group1}  = "SSNO"     then     {CASEHISTORY.CTH_SSNO};
i get a syntax error on the the third if stating a number is required here.

Can anyone help with the correct syntax to build a dynamic group in my report.
thanks
ron
   
Avatar of peter57r
peter57r
Flag of United Kingdom of Great Britain and Northern Ireland image

Use a select case to make this easy:


select {?Group1}
case "STAFF":
{CASEHISTORY.CTH_STAFF_RESP}
case "TYPE":
{CASEHISTORY.CTH_CASE_TYPE}
Case "SUBTYPE":
{CASEHISTORY.CTH_CASE_SUBTYPE}
Case "SSNO":
 {CASEHISTORY.CTH_SSNO}
default:
{CASEHISTORY.  some other field};

Avatar of PSERS BIT

ASKER

I copied your code and added a valid field for the default and i get an error when i try to syntax check .  the error i get is "A number is required here"
 select {?Group1}
case "STAFF":
{CASEHISTORY.CTH_STAFF_RESP}
case "TYPE":
{CASEHISTORY.CTH_CASE_TYPE}
------------------------------------------> from this point down is highlited blue and here is where i get the error
Case "SUBTYPE":
{CASEHISTORY.CTH_CASE_SUBTYPE}
Case "SSNO":
 {CASEHISTORY.CTH_SSNO}
default:
{CASEHISTORY.CTH_SSNO};

thanks ron
Additional information.

I am using vb.net 2003 to design the report. NOT the full blown crystal developer.

thanks

ron
SOLUTION
Avatar of peter57r
peter57r
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mike McCracken
Mike McCracken

For what it is worth, you could also do this with the If-then-else
You still need to convert the integer to a string


if   {?Group1}  = "STAFF"    then
     {CASEHISTORY.CTH_STAFF_RESP} ;
else if  {?Group1}   = "TYPE"     then
     cstr({CASEHISTORY.CTH_CASE_TYPE},0) ;
else if   {?Group1}  = "SUBTYPE"  then
     {CASEHISTORY.CTH_CASE_SUBTYPE} ;
else if   {?Group1}  = "SSNO"     then
     {CASEHISTORY.CTH_SSNO};

mlmcc