Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Formula Help. Post Reply Post New Topic
Author Message
Schugs
Newbie
Newbie


Joined: 08 Aug 2012
Online Status: Offline
Posts: 36
Quote Schugs Replybullet Topic: Formula Help.
    Posted: 29 Aug 2012 at 8:23am
hey can someone help me, this formula is breaking and i cant quite figure out why. It is saying that "a boolean is required here" at the first "Else if" statement.

WhileReadingRecords;
local numbervar total;
local numbervar i:=1;
local stringvar result;

if {ClassSchedule1.CourseId}=1 then
(
    Global stringvar array TD;
    Global stringvar array TDName;
    total := count(TD);

    for i:=1 to total do
    (
        result := result & td & tdname & chr(13)
    )
)
else if {ClassSchedule1.CourseId}=2 then
(
    Global stringvar array CC1;
    Global stringvar array CC1Name;
    result:="CC1"
)
else if {ClassSchedule1.CourseId}=3 then
(
    Global stringvar array CC2;
    Global stringvar array CC2Name;
    result:="CC2"
);

result

Edited by Schugs - 29 Aug 2012 at 8:51am
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 29 Aug 2012 at 11:25am
I believe you need a semicolon after the for statement.

WhileReadingRecords;
local numbervar total;
local numbervar i:=1;
local stringvar result;

if {ClassSchedule1.CourseId}=1 then
(
    Global stringvar array TD;
    Global stringvar array TDName;
    total := count(TD);

    for i:=1 to total do
    (
        result := result & td & tdname & chr(13)
    ) ;
)
else if {ClassSchedule1.CourseId}=2 then
(
    Global stringvar array CC1;
    Global stringvar array CC1Name;
    result:="CC1"
)
else if {ClassSchedule1.CourseId}=3 then
(
    Global stringvar array CC2;
    Global stringvar array CC2Name;
    result:="CC2"
);

result

If statements  and for loops are a nuisance in Crystal syntax.  Basic syntax (for me) is easier to follow.

IP IP Logged
Schugs
Newbie
Newbie


Joined: 08 Aug 2012
Online Status: Offline
Posts: 36
Quote Schugs Replybullet Posted: 30 Aug 2012 at 2:47am
so i found a work around- Though maybe someone smarter than me can explain why it works exactly, vs. just my uderstanding of "it was looking for a result that id couldnt find in the for statement"

if {ClassSchedule1.CourseId}=1 then
(
    Global stringvar array TD;
    Global stringvar array TDName;
    total := count(TD);
    Result:="Total Waiting: " & Totext(Count(td) -1,0) & chr(13);
    for i:=1 to total do
    (
        if not(td="") then
        result := result & td & " - " & tdname & chr(13)
    );
    ""
)
else if {ClassSc....

Edited by Schugs - 30 Aug 2012 at 3:02am
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.