Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subscript must be between 1 and the length of script 1

Status
Not open for further replies.

austinh

Technical User
Aug 9, 2002
144
US
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?
 
You're probably doing a subscript in a formula somewhere using a computed value, you need to be more specific about errors and the formulas involved.

When Crystal errors, it susualy shows the formula that is causing it, so post that.

-k

 
Sorry for being too general.

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'
 
You might want to start out your formula with:

if isnull({Renewal_Information.RNL_Rate_Code}) or
len({Renewal_Information.RNL_Rate_Code}) = 0 then "ERROR" else//

-LB
 
Should I follow that with all the other errors and then the regular else statements?
 
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.

-k
 
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
 
Nevermind I had to change the 'or' after the second line to 'else' and everything worked fine.

Thanks for the help synapsevampire and
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top