Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: If Then Else, The Remaining Text ... Post Reply Post New Topic
Author Message
bshort1023
Newbie
Newbie
Avatar

Joined: 18 Jan 2012
Location: United States
Online Status: Offline
Posts: 18
Quote bshort1023 Replybullet Topic: If Then Else, The Remaining Text ...
    Posted: 17 Dec 2015 at 9:39am
"The remaining text does not appear to be part of the formula.".

This works if I leave off the Else  "All" at the end;

As soon as I put it back in I get the error message.

NumberVar numEmpID;
NumberVar numRowIdent;
NumberVar numStartOfEmployeeNumbers;
NumberVar numLengthOfFinalString;
StringVar strEmpID;
StringVar strFinalString;

numEmpID := Instr({BAQReportParameter.Filter1}, "EmpID");

If numEmpID <> 0 Then

    numRowIdent := Instr({BAQReportParameter.Filter1}, "RowIdent") +8;
    strEmpID := mid({BAQReportParameter.Filter1}, numEmpID, (numRowIdent - numEmpID));
    numStartOfEmployeeNumbers := Instr(strEmpID, "FieldValue") + 11;
    numLengthOfFinalString := Length(strEmpID) - numStartOfEmployeeNumbers - 25;
    strFinalString := mid(strEmpID, numStartOfEmployeeNumbers, numLengthOfFinalString);
    Replace(strFinalString, "~", ", ");

Else

    "All";


Thanks,

Bill Short
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 17 Dec 2015 at 9:56am
Put parens around the then clause statements.  If you don't  then only the statement  numRowIdent := Instr({BAQReportParameter.Filter1}, "RowIdent") +8; will be considered part of the then statement.

If numEmpID <> 0 Then
(
    numRowIdent := Instr({BAQReportParameter.Filter1}, "RowIdent") +8;
    strEmpID := mid({BAQReportParameter.Filter1}, numEmpID, (numRowIdent - numEmpID));
    numStartOfEmployeeNumbers := Instr(strEmpID, "FieldValue") + 11;
    numLengthOfFinalString := Length(strEmpID) - numStartOfEmployeeNumbers - 25;
    strFinalString := mid(strEmpID, numStartOfEmployeeNumbers, numLengthOfFinalString);
    Replace(strFinalString, "~", ", ");
)
Else

    "All";

IP IP Logged
bshort1023
Newbie
Newbie
Avatar

Joined: 18 Jan 2012
Location: United States
Online Status: Offline
Posts: 18
Quote bshort1023 Replybullet Posted: 18 Dec 2015 at 3:31am
Thanks for the response.  That was it.  Works great now.

Thanks again.

Bill
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.