Solved

Crystal MUltiple If statements

Posted on 2008-10-03
6
1,004 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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 …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

706 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

18 Experts available now in Live!

Get 1:1 Help Now