Solved

Crystal MUltiple If statements

Posted on 2008-10-03
6
1,010 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

739 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