on 11-21-2014 5:17 PM
Hello Expert,
Please help me with this. i have following If else in my crystal report 2008 and it only considers first IF condition and ignores rest of ifs.
IF {CCS_ScheduleMatrixRpt;1.period4} [(InStr ({CCS_ScheduleMatrixRpt;1.period4}, ";") - 1)] = "4" Then
{CCS_ScheduleMatrixRpt;1.period4} [(InStr ({CCS_ScheduleMatrixRpt;1.period4}, " ") + 1) To Length ({CCS_ScheduleMatrixRpt;1.period4})]
ELSE IF {CCS_ScheduleMatrixRpt;1.period2} [(InStr ({CCS_ScheduleMatrixRpt;1.period2}, ";") - 1)] = "4" Then
{CCS_ScheduleMatrixRpt;1.period2} [(InStr ({CCS_ScheduleMatrixRpt;1.period2}, " ") + 1) To Length ({CCS_ScheduleMatrixRpt;1.period2})]
ELSE IF {CCS_ScheduleMatrixRpt;1.period3} [(InStr ({CCS_ScheduleMatrixRpt;1.period3}, ";") - 1)] = "4" Then
{CCS_ScheduleMatrixRpt;1.period3} [(InStr ({CCS_ScheduleMatrixRpt;1.period3}, " ") + 1) To Length ({CCS_ScheduleMatrixRpt;1.period3})]
ELSE IF {CCS_ScheduleMatrixRpt;1.period5} [(InStr ({CCS_ScheduleMatrixRpt;1.period5}, ";") - 1)] = "4" Then
{CCS_ScheduleMatrixRpt;1.period5} [(InStr ({CCS_ScheduleMatrixRpt;1.period5}, " ") + 1) To Length ({CCS_ScheduleMatrixRpt;1.period5})]
ELSE IF {CCS_ScheduleMatrixRpt;1.period1} [(InStr ({CCS_ScheduleMatrixRpt;1.period1}, ";") - 1)] = "4" Then
{CCS_ScheduleMatrixRpt;1.period1} [(InStr ({CCS_ScheduleMatrixRpt;1.period1}, " ") + 1) To Length ({CCS_ScheduleMatrixRpt;1.period1})]
ELSE IF {CCS_ScheduleMatrixRpt;1.period6} [(InStr ({CCS_ScheduleMatrixRpt;1.period6}, ";") - 1)] = "4" Then
{CCS_ScheduleMatrixRpt;1.period6} [(InStr ({CCS_ScheduleMatrixRpt;1.period6}, " ") + 1) To Length ({CCS_ScheduleMatrixRpt;1.period6})]
ELSE IF {CCS_ScheduleMatrixRpt;1.period7} [(InStr ({CCS_ScheduleMatrixRpt;1.period7}, ";") - 1)] = "4" Then
{CCS_ScheduleMatrixRpt;1.period7} [(InStr ({CCS_ScheduleMatrixRpt;1.period7}, " ") + 1) To Length ({CCS_ScheduleMatrixRpt;1.period7})]
ELSE IF {CCS_ScheduleMatrixRpt;1.period8} [(InStr ({CCS_ScheduleMatrixRpt;1.period8}, ";") - 1)] = "4" Then
{CCS_ScheduleMatrixRpt;1.period8} [(InStr ({CCS_ScheduleMatrixRpt;1.period8}, " ") + 1) To Length ({CCS_ScheduleMatrixRpt;1.period8})]
Please please help me here have spent so many hours on this...
Thanks in advance
Regards,
H
Hi,
Try this: Did you mean this one
IF {CCS_ScheduleMatrixRpt;1.period4} [(InStr ({CCS_ScheduleMatrixRpt;1.period4}, ";") - 1)] = "4"
Then
{CCS_ScheduleMatrixRpt;1.period4} [(InStr ({CCS_ScheduleMatrixRpt;1.period4}, " ") + 1) To Length ({CCS_ScheduleMatrixRpt;1.period4})]
Thanks,
DJ
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here's an example of how it could be done using a case/switch statement:
NumberVar atSemiP8 := InStr({CCS_ScheduleMatrixRpt;1.period8}, ";") - 1;
NumberVar atSemiP7 := InStr({CCS_ScheduleMatrixRpt;1.period7}, ";") - 1;
NumberVar atSemiP6 := InStr({CCS_ScheduleMatrixRpt;1.period6}, ";") - 1;
NumberVar atSemiP5 := InStr({CCS_ScheduleMatrixRpt;1.period5}, ";") - 1;
NumberVar atSemiP4 := InStr({CCS_ScheduleMatrixRpt;1.period4}, ";") - 1;
NumberVar atSemiP3 := InStr({CCS_ScheduleMatrixRpt;1.period3}, ";") - 1;
NumberVar atSemiP2 := InStr({CCS_ScheduleMatrixRpt;1.period2}, ";") - 1;
NumberVar atSemiP1 := InStr({CCS_ScheduleMatrixRpt;1.period1}, ";") - 1;
Switch(
{CCS_ScheduleMatrixRpt;1.period4}[atSemiP4] = "4", {CCS_ScheduleMatrixRpt;1.period4}[(InStr({CCS_ScheduleMatrixRpt;1.period4}, " ") + 1) To Length({CCS_ScheduleMatrixRpt;1.period4})],
{CCS_ScheduleMatrixRpt;1.period2}[atSemiP2] = "4", {CCS_ScheduleMatrixRpt;1.period2}[(InStr({CCS_ScheduleMatrixRpt;1.period2}, " ") + 1) To Length({CCS_ScheduleMatrixRpt;1.period2})],
{CCS_ScheduleMatrixRpt;1.period3}[atSemiP3] = "4", {CCS_ScheduleMatrixRpt;1.period3}[(InStr({CCS_ScheduleMatrixRpt;1.period3}, " ") + 1) To Length({CCS_ScheduleMatrixRpt;1.period3})],
{CCS_ScheduleMatrixRpt;1.period5}[atSemiP5] = "4", {CCS_ScheduleMatrixRpt;1.period5}[(InStr({CCS_ScheduleMatrixRpt;1.period5}, " ") + 1) To Length({CCS_ScheduleMatrixRpt;1.period5})],
{CCS_ScheduleMatrixRpt;1.period1}[atSemiP1] = "4", {CCS_ScheduleMatrixRpt;1.period1}[(InStr({CCS_ScheduleMatrixRpt;1.period1}, " ") + 1) To Length({CCS_ScheduleMatrixRpt;1.period1})],
{CCS_ScheduleMatrixRpt;1.period6}[atSemiP6] = "4", {CCS_ScheduleMatrixRpt;1.period6}[(InStr({CCS_ScheduleMatrixRpt;1.period6}, " ") + 1) To Length({CCS_ScheduleMatrixRpt;1.period6})],
{CCS_ScheduleMatrixRpt;1.period7}[atSemiP7] = "4", {CCS_ScheduleMatrixRpt;1.period7}[(InStr({CCS_ScheduleMatrixRpt;1.period7}, " ") + 1) To Length({CCS_ScheduleMatrixRpt;1.period7})],
{CCS_ScheduleMatrixRpt;1.period8}[atSemiP8] = "4", {CCS_ScheduleMatrixRpt;1.period8}[(InStr({CCS_ScheduleMatrixRpt;1.period8}, " ") + 1) To Length({CCS_ScheduleMatrixRpt;1.period8})],
true, ""
)
However, as Abhilash stated, this will only process as far as the first "true" result in the comparison. So, if you want to process all 8 periods so that you can display each on your report, you'll need to do a separate formula for each period in order to get the correct value for each of them.
-Dell
Hi,
Try this:
If
(
{CCS_ScheduleMatrixRpt;1.period4} [(InStr ({CCS_ScheduleMatrixRpt;1.period4}, ";") - 1)] = "4"
or {CCS_ScheduleMatrixRpt;1.period2} [(InStr ({CCS_ScheduleMatrixRpt;1.period2}, ";") - 1)] = "4"
or {CCS_ScheduleMatrixRpt;1.period3} [(InStr ({CCS_ScheduleMatrixRpt;1.period3}, ";") - 1)] = "4"
or {CCS_ScheduleMatrixRpt;1.period5} [(InStr ({CCS_ScheduleMatrixRpt;1.period5}, ";") - 1)] = "4"
or {CCS_ScheduleMatrixRpt;1.period1} [(InStr ({CCS_ScheduleMatrixRpt;1.period1}, ";") - 1)] = "4"
or {CCS_ScheduleMatrixRpt;1.period6} [(InStr ({CCS_ScheduleMatrixRpt;1.period6}, ";") - 1)] = "4"
or {CCS_ScheduleMatrixRpt;1.period7} [(InStr ({CCS_ScheduleMatrixRpt;1.period7}, ";") - 1)] = "4"
or {CCS_ScheduleMatrixRpt;1.period8} [(InStr ({CCS_ScheduleMatrixRpt;1.period8}, ";") - 1)] = "4"
)
else if
(
{CCS_ScheduleMatrixRpt;1.period4}[atSemiP4] = "4", {CCS_ScheduleMatrixRpt;1.period4}[(InStr({CCS_ScheduleMatrixRpt;1.period4}, " ") + 1) To Length({CCS_ScheduleMatrixRpt;1.period4})] or
{CCS_ScheduleMatrixRpt;1.period2}[atSemiP2] = "4", {CCS_ScheduleMatrixRpt;1.period2}[(InStr({CCS_ScheduleMatrixRpt;1.period2}, " ") + 1) To Length({CCS_ScheduleMatrixRpt;1.period2})] or
{CCS_ScheduleMatrixRpt;1.period3}[atSemiP3] = "4", {CCS_ScheduleMatrixRpt;1.period3}[(InStr({CCS_ScheduleMatrixRpt;1.period3}, " ") + 1) To Length({CCS_ScheduleMatrixRpt;1.period3})] or
{CCS_ScheduleMatrixRpt;1.period5}[atSemiP5] = "4", {CCS_ScheduleMatrixRpt;1.period5}[(InStr({CCS_ScheduleMatrixRpt;1.period5}, " ") + 1) To Length({CCS_ScheduleMatrixRpt;1.period5})] or
{CCS_ScheduleMatrixRpt;1.period1}[atSemiP1] = "4", {CCS_ScheduleMatrixRpt;1.period1}[(InStr({CCS_ScheduleMatrixRpt;1.period1}, " ") + 1) To Length({CCS_ScheduleMatrixRpt;1.period1})] or
{CCS_ScheduleMatrixRpt;1.period6}[atSemiP6] = "4", {CCS_ScheduleMatrixRpt;1.period6}[(InStr({CCS_ScheduleMatrixRpt;1.period6}, " ") + 1) To Length({CCS_ScheduleMatrixRpt;1.period6})] or
{CCS_ScheduleMatrixRpt;1.period7}[atSemiP7] = "4", {CCS_ScheduleMatrixRpt;1.period7}[(InStr({CCS_ScheduleMatrixRpt;1.period7}, " ") + 1) To Length({CCS_ScheduleMatrixRpt;1.period7})] or
{CCS_ScheduleMatrixRpt;1.period8}[atSemiP8] = "4", {CCS_ScheduleMatrixRpt;1.period8}[(InStr({CCS_ScheduleMatrixRpt;1.period8}, " ") + 1) To Length({CCS_ScheduleMatrixRpt;1.period8})]
}
Am not sure see how this happens...
--dj
Hi H,
After each Then statement, terminate it with ";". Without the termination, Crystal thinks the rest of the statement is all part of the first Else. Like a paragraph without a period, it all becomes one long run-on sentence.
IF {CCS_ScheduleMatrixRpt;1.period4} [(InStr ({CCS_ScheduleMatrixRpt;1.period4}, ";") - 1)] = "4" Then
{CCS_ScheduleMatrixRpt;1.period4} [(InStr ({CCS_ScheduleMatrixRpt;1.period4}, " ") + 1) To Length ({CCS_ScheduleMatrixRpt;1.period4})];
ELSE IF {CCS_ScheduleMatrixRpt;1.period2} [(InStr ({CCS_ScheduleMatrixRpt;1.period2}, ";") - 1)] = "4" Then
{CCS_ScheduleMatrixRpt;1.period2} [(InStr ({CCS_ScheduleMatrixRpt;1.period2}, " ") + 1) To Length ({CCS_ScheduleMatrixRpt;1.period2})];
ELSE IF {CCS_ScheduleMatrixRpt;1.period3} [(InStr ({CCS_ScheduleMatrixRpt;1.period3}, ";") - 1)] = "4" Then
{CCS_ScheduleMatrixRpt;1.period3} [(InStr ({CCS_ScheduleMatrixRpt;1.period3}, " ") + 1) To Length ({CCS_ScheduleMatrixRpt;1.period3})];
ELSE IF {CCS_ScheduleMatrixRpt;1.period5} [(InStr ({CCS_ScheduleMatrixRpt;1.period5}, ";") - 1)] = "4" Then
{CCS_ScheduleMatrixRpt;1.period5} [(InStr ({CCS_ScheduleMatrixRpt;1.period5}, " ") + 1) To Length ({CCS_ScheduleMatrixRpt;1.period5})];
ELSE IF {CCS_ScheduleMatrixRpt;1.period1} [(InStr ({CCS_ScheduleMatrixRpt;1.period1}, ";") - 1)] = "4" Then
{CCS_ScheduleMatrixRpt;1.period1} [(InStr ({CCS_ScheduleMatrixRpt;1.period1}, " ") + 1) To Length ({CCS_ScheduleMatrixRpt;1.period1})];
ELSE IF {CCS_ScheduleMatrixRpt;1.period6} [(InStr ({CCS_ScheduleMatrixRpt;1.period6}, ";") - 1)] = "4" Then
{CCS_ScheduleMatrixRpt;1.period6} [(InStr ({CCS_ScheduleMatrixRpt;1.period6}, " ") + 1) To Length ({CCS_ScheduleMatrixRpt;1.period6})];
ELSE IF {CCS_ScheduleMatrixRpt;1.period7} [(InStr ({CCS_ScheduleMatrixRpt;1.period7}, ";") - 1)] = "4" Then
{CCS_ScheduleMatrixRpt;1.period7} [(InStr ({CCS_ScheduleMatrixRpt;1.period7}, " ") + 1) To Length ({CCS_ScheduleMatrixRpt;1.period7})];
ELSE IF {CCS_ScheduleMatrixRpt;1.period8} [(InStr ({CCS_ScheduleMatrixRpt;1.period8}, ";") - 1)] = "4" Then
{CCS_ScheduleMatrixRpt;1.period8} [(InStr ({CCS_ScheduleMatrixRpt;1.period8}, " ") + 1) To Length ({CCS_ScheduleMatrixRpt;1.period8})];
Thanks,
Brian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.