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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stumped on string conversion problem

Status
Not open for further replies.

Malekish

Technical User
Dec 8, 2008
36
0
0
US
I'm getting the dreaded "A subscript must be between 1 and the size of the array" error. Searching for that error produces many results and I know what's causing it but I just can't figure out why in this case.

Handed an old report at my new job and told a) understand how it works and b) fix :p

CR version 11
ODBC connection to MS SQL
Date field defined as either typing in or by clicking on dates in pop up box
(Start Date: 12/01/2008. End Date: 12/07/2008)

Formula: CommDailyServiceLevel
shared numbervar array COMMDailyServiceLevel;

COMMDailyServiceLevel[tonumber(right({@End Date}, 2))];

In the error description it has all relevant info:
{@End Date} = "20081207"
var COMMDailyServiceLevel: []
exp tonumber(right({@End Date],2): 7

So... I'm trying to create an array from 1 to 7 (in this example) and it's choking on something. Does the array need to be initialized first? What am I missing?

Thanks in advance for any assistance!
 
Is there more to this forumula? I am not sure I can help you because I am having trouble figuring out what you're (this formula) is trying to do...

But try this...

//modified formula
shared numbervar array COMMDailyServiceLevel;
COMMDailyServiceLevel :=[tonumber(right({@End Date}, 2))];
COMMDailyServiceLevel[1]

-- Jason
"It's Just Ones and Zeros
 
You haven't populated the array with anything--unless the array is populated in an earlier section or in a subreport. If in a subreport, make sure the subreport is not suppressed and that the section containing it is not suppressed or hidden.

-LB
 
Ok, noobie user question time. How do I go searching about for where that array is populated in an earlier section, is there an easy way? Using the Find/Replace for that variable name isn't finding anything.

It's not in a subreport so I don't think the array is populated, in which case I have to figure out how this thing has (mostly) worked for months with it written the way it is.
 
If you are sure there is no subreport, then check all formulas in the field explorer to see which one is populating the array. Once you find the formula in the field list, look for it in design view and report back with what section it is located in and also show us the content of the formula.

-LB
 
Ah hah! Ok, so the original reference appears to be located within a subreport. There's where it's defining the array

Code:
shared numbervar array COMMDailyServiceLevel;
numbervar Counter;

Counter := tonumber(right({T_QUEUE_DAY.QUERY_DATE}, 2));

redim preserve COMMDailyServiceLevel[Counter];

COMMDailyServiceLevel[Counter] := {@TotalServiceLevel};

It looks like the reference in the subreport is looking at T_QUEUE_DAY.Query_date and the other reference is comparing to @End Date, as entered by user.

Quick Robin, to the Query Analyzer! Check that table!
 
Don't appear to have an 'Edit post' option.

Values in T_QUEUE_DAY.Query_date are as expected. In my above example '20081207' is in the table.

I'm new to CR but have lots of other programming experience. Check that I'm reading this right.

Create numbervar array named COMMDailyServiceLevel
Dimension (and preserve) it to right(T_QUEUE_DAY.Query_date) (in this example 7)

COMMDailyServiceLevel[7] = @TotalServiceLevel

Checking in the report, I find TotalServiceLevel being computed what appears to be correctly.

So I'm back to square one, I'm stumped. Thanks in advance for any help and mucho thanks to lbass!

 
Where is the subreport located (what report section)? And in what section is the formula that you referenced in your first post that uses the array? Also, explain whether the subreport is suppressed or whether it is in a section that is suppressed or hidden.

-LB
 
The subreport that contains the redim mentioned above is contained in a subreport located in Report Footer b.

The very first post of mine is in the main report, under formula definitions.

The subreport is neither suppressed nor hidden.

Thanks much!

 
In what report section is the formula placed? It must be in a section below the one in which the subreport is placed, e.g., in Report Footer C.

-LB
 
I finally found out what's causing the problem.

Apparently the person that set this up left out one critical note in the instructions on running this, if a location is closed for a day (for example, Thanksgiving) then a row is not created in the table that is being queried. Since the report is checking row-by-row and expecting values = number of days, a missing row tends to throw everything off. When you have an instance of a missing row just go and manually create a row of all zeros and the report works fine. Well, "fine" by suitable definitions of "fine".

LB, thanks so very much for helping me with this, I hope you have the very best holiday!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top