Solved

Crystal MUltiple If statements

Posted on 2008-10-03
6
1,011 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
On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

 
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 101

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] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
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 …
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

635 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