Skip to Content
avatar image
Former Member

Crystal Code error

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    avatar image
    Former Member
    Jun 24, 2010 at 06:47 PM

    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

    Add comment
    10|10000 characters needed characters exceeded