cancel
Showing results for 
Search instead for 
Did you mean: 

Crystal Code error

Former Member
0 Kudos

I have the following code in a Formula Field

WhilePrintingRecords;

Shared numberVar counter;

//increments the loop so that all parameter entries can be displayed

Shared stringVar CC_display;

select HasValue({?PF_EqClassCode})

case true :

CC_display := "Class Codes: " + Chr(10);

for counter := 1 to Count({?PF_EqClassCode}) do

(

CC_display := CC_display + ToText({?PF_EqClassCode}[counter],0,"") + " | ";

)

case false :

CC_display := "Class Codes: All";

CC_display;

When I test it the last three lines are highlighted and I get the message:

"The remaining text does not appear to be part of the formula."

I cannot figure out what I am doing wrong.

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Try making this change:


WhilePrintingRecords;
Shared numberVar counter;
//increments the loop so that all parameter entries can be displayed
Shared stringVar CC_display;
select HasValue({?PF_EqClassCode})
case true : ( //Add open paren
CC_display := "Class Codes: " + Chr(10);
for counter := 1 to Count({?PF_EqClassCode}) do
(
CC_display := CC_display + ToText({?PF_EqClassCode}counter,0,"") + " | ";
)
)  //Add close paren
case false : (//Add open paren
CC_display := "Class Codes: All";
) //Add close paren
CC_display;

The issue is that you're trying to run two lines of code within the first part of the case statement, so Crystal doesn't recognize the second part.

If this doesn't work, you'll have to move the For loop so a separate formula that returns a string and change the code to somethign like this:


WhilePrintingRecords;
Shared numberVar counter;
//increments the loop so that all parameter entries can be displayed
Shared stringVar CC_display;
select HasValue({?PF_EqClassCode})
case true :
CC_display := "Class Codes: " + Chr(10) + {@NewForLoopFormula};
case false :
CC_display := "Class Codes: All";
CC_display;

-Dell

Answers (0)