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 sizbut 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 & Size Of The Array?

Status
Not open for further replies.

M4XiMuS

Programmer
Sep 1, 2009
7
US
I've been working through this report for the last few days, trying to get the last 2 updates as well as the date & time parsed out of a Remedy work log.

I have 3 formulas setup to return the specified fields above, all of which return no errors when I save & close each one. However, once I try to export the report to Excel (Data Only) one of the reports returns the error message "A subscript must be between 1 and the size of the array." Here is the formula @2ndLastUpdate:

whileprintingrecords;
stringvar x := {MOD_TRB_Trouble.Work_Log};
stringvar array y := split({MOD_TRB_Trouble.Work_Log},"NNOC - Group");
numbervar i;
numbervar j := ubound(y);
stringvar z;


z := y[j-1];
z

The y[j-1] reference is the portion of the formula returning the error.

For reference, here are the other 2 formulas built into my report:

@LastUpdate:

whileprintingrecords;
stringvar x := {MOD_TRB_Trouble.Work_Log};
stringvar array y := split({MOD_TRB_Trouble.Work_Log},"NNOC - Group");
numbervar i;
numbervar j := ubound(y);
stringvar z;


z := y[j];
z

Lastly...

@Date

right({@2ndLastUpdate},53)

This one has me really stumped. Any thoughts/hints to get headed in the right direction would be greatly appreciated!

-Scott
 
Thew one potential problem I see is with z := y[j-1].

If your array only has one element, perhaps an instance where NNOC - Group does not exist in the string, you are subtracting 1 from the number of elements. In that case it would try to return y[0] which is not a valid array.

Try

if j > 1 then
z:=y[j-1]
else
z:=y[1]

_____________________________________
Crystal Reports XI Developer Version
Intersystems Cache 5.X ODBC connection

 
@CoSpringsGuy

Understood. Your solution worked flawlessly... THANKS!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top