View Full Version : Help with If then formula


js3
02-01-2012, 07:31 AM
I need help converting a simple If then formula that is used in Crystal 8.5 to Crystal 10. Below is the formula as I would write it in 8.5

IF{INMAST.Prodkey}IN ['P12','P13','P14','P15','P24','P28','P32','P33','P 34'] THEN BU01 else
if {INMAST.Prodkey}IN['P01','P03','P04','P05','P07','P11','P19','P26','P 29',P30','31'] THEN BU02 else
if {INMAST.Prodkey}IN ['P08','P20','P23','P27','P36','P37','P38','P39'] THEN BU03 else
if {INMAST.Prodkey}IN ['P21'] then BU04 else
if {INMAST.Prodkey}IN ['P16','P25'] then BU00

when I entered this everything after the first [ turned green which is what happens in 8.5 when you use // I changed all the sqare brackest to " which fixed that problem but then when I ran a check on the formula it stoped me right after the first then and said a statement is required. I tried "BU01" and 'BU01' as well. What am I doing wrong.

Thank you

MSAccessRookie
02-01-2012, 09:15 AM
I need help converting a simple If then formula that is used in Crystal 8.5 to Crystal 10. Below is the formula as I would write it in 8.5

IF{INMAST.Prodkey}IN ['P12','P13','P14','P15','P24','P28','P32','P33','P 34'] THEN BU01 else
if {INMAST.Prodkey}IN['P01','P03','P04','P05','P07','P11','P19','P26','P 29',P30','31'] THEN BU02 else
if {INMAST.Prodkey}IN ['P08','P20','P23','P27','P36','P37','P38','P39'] THEN BU03 else
if {INMAST.Prodkey}IN ['P21'] then BU04 else
if {INMAST.Prodkey}IN ['P16','P25'] then BU00

when I entered this everything after the first [ turned green which is what happens in 8.5 when you use // I changed all the sqare brackest to " which fixed that problem but then when I ran a check on the formula it stoped me right after the first then and said a statement is required. I tried "BU01" and 'BU01' as well. What am I doing wrong.

Thank you

I cannot remember if the type of quote makes a difference, and I do not have CR 8.5 or CR 10 to test, but I have never used a single quote (') in that situation. I use a double quote (") instead.

Try leaving the brackets ([, ], {, and }) alone, and changing the single quotes (') to double quotes (") to see if there is any difference.

kevlray
02-01-2012, 12:11 PM
First off there is a missing quote on line two before the P30. Second, you will need to enclose the BU01, BU02, etc. in single or double quotes.