Solved

Crystal MUltiple If statements

Posted on 2008-10-03
6
1,005 Views
Last Modified: 2012-08-14
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
   
0
Comment
Question by:PSERS
  • 3
  • 2
6 Comments
 
LVL 77

Expert Comment

by:peter57r
ID: 22633680
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};

0
 

Author Comment

by:PSERS
ID: 22633767
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
0
 

Author Comment

by:PSERS
ID: 22633885
Additional information.

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

thanks

ron
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 77

Assisted Solution

by:peter57r
peter57r earned 250 total points
ID: 22634003
All the possible outputs from the formula field must be the same data type.
If they are not already the same then you have to convert them to be so.
0
 

Accepted Solution

by:
PSERS earned 0 total points
ID: 22634225
CASEHISTORY.CTH_CASE_TYPE} was deffined as small integer all the other fields were definded as varchar. I converted the CASEHISTORY.CTH_CASE_TYPE}
 to string and all is now working.

Thanks you so much.  I have been working on this for 2 days.  
This contact can now be close and i would like to give you double points if i could.

thanks again
ron
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 22636619
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
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

27 Experts available now in Live!

Get 1:1 Help Now