I keep getting this error message, "A subscript must be between 1 and the length of the string", when I run the report with certain dates but not with others. Any idea what I have to do or change to fix this?
Here is the formula that its giving the error for
I hope its not too sloppy.
if {Renewal_Information.RNL_Rate_Code} in ['Y','WY','QY']
and ({Renewal_Information_Jt_Mbr.RNL_Rate_Code}[Len({Renewal_Information_Jt_Mbr.RNL_Rate_Code})-1]) = "J"
and ({Renewal_Information_Jt_Mbr.RNL_Rate_Code}[Len({Renewal_Information_Jt_Mbr.RNL_Rate_Code})-4]) = "Z"
then 'JSTORSECJTMB'
else if {Renewal_Information.RNL_Rate_Code} in ['Y','WY','QY']
and ({Renewal_Information_Jt_Mbr.RNL_Rate_Code}[Len({Renewal_Information_Jt_Mbr.RNL_Rate_Code})-4]) = "Z"
then 'NOJSTORSECJTMB'
else if {Renewal_Information.RNL_Rate_Code} in ['Y','WY','QY']
then 'ERROR'
else if not(left({Renewal_Information.RNL_Rate_Code},1) in ['A','B','C','D','G','H','I','O','P','Q','W'])
then 'ERROR'
else if ({Renewal_Information.RNL_Rate_Code}[Len({Renewal_Information.RNL_Rate_Code})-1]) = "J"
and ({Renewal_Information.RNL_Rate_Code}[Len({Renewal_Information.RNL_Rate_Code})-4]) = "Z"
then 'JSTORPRIJTMB'
else if ({Renewal_Information.RNL_Rate_Code}[Len({Renewal_Information.RNL_Rate_Code})-1]) = "J"
and ({Renewal_Information.RNL_Rate_Code}[Len({Renewal_Information.RNL_Rate_Code})-4]) <> "Z"
then 'JSTORINDMB'
else if ({Renewal_Information.RNL_Rate_Code}[Len({Renewal_Information.RNL_Rate_Code})-4]) <> "Z"
then 'NOJSTORINDMB'
else if ({Renewal_Information.RNL_Rate_Code}[Len({Renewal_Information.RNL_Rate_Code})-4]) = "Z"
then 'NOJSTORPRIJTMB'
else 'ERROR'
The issue is that your formula assumes that there's always data in {Renewal_Information.RNL_Rate_Code}.
So as LB points out, checking for null or length 0 might fix this, but more importantly, check that it is of valid length for the subscripting being performed.
LB omitted the second field used, so the starting formula should be:
if isnull({Renewal_Information.RNL_Rate_Code}) or
len({Renewal_Information.RNL_Rate_Code}) = 0
or
if isnull({Renewal_Information_Jt_Mbr.RNL_Rate_Code}) or
len({Renewal_Information_Jt_Mbr.RNL_Rate_Code}) = 0 then "ERROR"
else
For instance if one value is a length of 1, it will get by LB's check, but still error out.
Is this what you were talking about 'synapsevampire'?
if isnull({Renewal_Information.RNL_Rate_Code}) or
len({Renewal_Information.RNL_Rate_Code}) = 0
or
if isnull({Renewal_Information_Jt_Mbr.RNL_Rate_Code}) or
len({Renewal_Information_Jt_Mbr.RNL_Rate_Code}) = 0 then "ERROR"
else
if {Renewal_Information.RNL_Rate_Code} in ['Y','WY','QY']
and ({Renewal_Information_Jt_Mbr.RNL_Rate_Code}[Len({Renewal_Information_Jt_Mbr.RNL_Rate_Code})-1]) = "J"
and ({Renewal_Information_Jt_Mbr.RNL_Rate_Code}[Len({Renewal_Information_Jt_Mbr.RNL_Rate_Code})-4]) = "Z"
then 'JSTORSECJTMB'
else if {Renewal_Information.RNL_Rate_Code} in ['Y','WY','QY']
and ({Renewal_Information_Jt_Mbr.RNL_Rate_Code}[Len({Renewal_Information_Jt_Mbr.RNL_Rate_Code})-4]) = "Z"
then 'NOJSTORSECJTMB'
else if {Renewal_Information.RNL_Rate_Code} in ['Y','WY','QY']
then 'ERROR'
else if not(left({Renewal_Information.RNL_Rate_Code},1) in ['A','B','C','D','G','H','I','O','P','Q','W'])
then 'ERROR'
else if ({Renewal_Information.RNL_Rate_Code}[Len({Renewal_Information.RNL_Rate_Code})-1]) = "J"
and ({Renewal_Information.RNL_Rate_Code}[Len({Renewal_Information.RNL_Rate_Code})-4]) = "Z"
then 'JSTORPRIJTMB'
else if ({Renewal_Information.RNL_Rate_Code}[Len({Renewal_Information.RNL_Rate_Code})-1]) = "J"
and ({Renewal_Information.RNL_Rate_Code}[Len({Renewal_Information.RNL_Rate_Code})-4]) <> "Z"
then 'JSTORINDMB'
else if ({Renewal_Information.RNL_Rate_Code}[Len({Renewal_Information.RNL_Rate_Code})-4]) <> "Z"
then 'NOJSTORINDMB'
else if ({Renewal_Information.RNL_Rate_Code}[Len({Renewal_Information.RNL_Rate_Code})-4]) = "Z"
then 'NOJSTORPRIJTMB'
else 'ERROR'
I put in the formula that you wrote above but when I check it for errors it says that there should be a 'then' keyword at the end. I tried removing the 'else error' part but it still asks for a 'then' keyword.
Any suggestions
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.