PSERS BIT
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_RES P} ;
if {?Group1} = "TYPE" then {CASEHISTORY.CTH_CASE_TYPE } ;
if {?Group1} = "SUBTYPE" then {CASEHISTORY.CTH_CASE_SUBT YPE} ;
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_RES P};
If i try to use else statements i get syntax errors.
if {?Group1} = "STAFF" then {CASEHISTORY.CTH_STAFF_RES P} else
if {?Group1} = "TYPE" then {CASEHISTORY.CTH_CASE_TYPE } else
if {?Group1} = "SUBTYPE" then {CASEHISTORY.CTH_CASE_SUBT YPE} 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
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_RES
if {?Group1} = "TYPE" then {CASEHISTORY.CTH_CASE_TYPE
if {?Group1} = "SUBTYPE" then {CASEHISTORY.CTH_CASE_SUBT
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_RES
If i try to use else statements i get syntax errors.
if {?Group1} = "STAFF" then {CASEHISTORY.CTH_STAFF_RES
if {?Group1} = "TYPE" then {CASEHISTORY.CTH_CASE_TYPE
if {?Group1} = "SUBTYPE" then {CASEHISTORY.CTH_CASE_SUBT
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
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_RES P}
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_SUBT YPE}
Case "SSNO":
{CASEHISTORY.CTH_SSNO}
default:
{CASEHISTORY.CTH_SSNO};
thanks ron
select {?Group1}
case "STAFF":
{CASEHISTORY.CTH_STAFF_RES
case "TYPE":
{CASEHISTORY.CTH_CASE_TYPE
--------------------------
Case "SUBTYPE":
{CASEHISTORY.CTH_CASE_SUBT
Case "SSNO":
{CASEHISTORY.CTH_SSNO}
default:
{CASEHISTORY.CTH_SSNO};
thanks ron
ASKER
Additional information.
I am using vb.net 2003 to design the report. NOT the full blown crystal developer.
thanks
ron
I am using vb.net 2003 to design the report. NOT the full blown crystal developer.
thanks
ron
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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_RES P} ;
else if {?Group1} = "TYPE" then
cstr({CASEHISTORY.CTH_CASE _TYPE},0) ;
else if {?Group1} = "SUBTYPE" then
{CASEHISTORY.CTH_CASE_SUBT YPE} ;
else if {?Group1} = "SSNO" then
{CASEHISTORY.CTH_SSNO};
mlmcc
You still need to convert the integer to a string
if {?Group1} = "STAFF" then
{CASEHISTORY.CTH_STAFF_RES
else if {?Group1} = "TYPE" then
cstr({CASEHISTORY.CTH_CASE
else if {?Group1} = "SUBTYPE" then
{CASEHISTORY.CTH_CASE_SUBT
else if {?Group1} = "SSNO" then
{CASEHISTORY.CTH_SSNO};
mlmcc
select {?Group1}
case "STAFF":
{CASEHISTORY.CTH_STAFF_RES
case "TYPE":
{CASEHISTORY.CTH_CASE_TYPE
Case "SUBTYPE":
{CASEHISTORY.CTH_CASE_SUBT
Case "SSNO":
{CASEHISTORY.CTH_SSNO}
default:
{CASEHISTORY. some other field};