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

Ending a variable count

Status
Not open for further replies.

giggles7840

IS-IT--Management
Mar 8, 2002
219
US
cr xi r2
win xp

i need to end my variable count - PDates[i+1];

When it hits the last value in PDate it keeps trying to add. How do i stop it?

Formula:
stringvar array ADates := [totext({@Actual - 00 Date}),totext({@Actual - 01 Date}),totext({@Actual - 02 Date}),
totext({@Actual - 2A Date}),totext({@Actual - 03 Date}),totext({@Actual - 3A Date}),totext({@Actual - 04 Date}),
totext({@Actual - 05 Date}),totext({@Actual - 06 Date}),totext({@Actual - 07 Date}),totext({@Actual - 08 Date}),
totext({@Actual - 09 Date}),totext({@Actual - 10 Date}),totext({@Actual - 11 Date}),totext({@Actual - 12 Date})];

stringvar array PDates := [totext({@Projected - 00 Date}),totext({@Projected - 01 Date}),totext({@Projected - 02 Date}),
totext({@Projected - 2A Date}),totext({@Projected - 03 Date}),totext({@Projected - 3A Date}),totext({@Projected - 04 Date}),
totext({@Projected - 05 Date}),totext({@Projected - 06 Date}),
totext({@Projected - 07 Date}),totext({@Projected - 08 Date}),totext({@Projected - 09 Date}),
totext({@Projected - 10 Date}),totext({@Projected - 11 Date}),totext({@Projected - 12 Date})];

numbervar i := ubound(ADates);
while i > 1 and ADates = "" do
i := i - 1;

PDates[i+1];
 
Change it:

numbervar i;
for i := 1 to ubound(ADates) do (
i := i - 1
);

Not sure what PDates[i+1] is supposed to do...

I think that you'll be better off posting requirements rather than code until you become more familiar with Crystal coding.

-k
 
I am trying to grab the next value.

so if ADates = totext({@Actual - 00 Date}) then i want to display PDates = totext({@Projected - 01 Date}).
 
The error message is A subscript must be between 1 and the size of the array, which makes sense.

The var is i = 15 and the exp is i+1 = 16.

so if ADates = totext({@Actual - 12 Date})] then instead of trying to grab the next value that doesnt exist, it needs to grab its current value PDates = totext({@Projected - 12 Date})];

 
Please post:

{@Actual - 00 Date}

We don't know what's in your formulas.

I'll guess that you want:

numbervar i;
numbervar z:=0
for i := 1 to ubound(ADates) do (
if ADates = totext({@Actual - 12 Date}) then
z:=i+1
);

Honestly the whole design seems odd to me, and you haven't shared enough to allow for improving on it.

Again, I humbly suggest that you stop coding the solution and post what you have and what you need.

-k
 
Well the problem posting everything is there are many formulas that make up this one formula. The data is laid out badly.

What I can tell you is that the original posted formula works perfectly in my main report. It doesnt stop working until i put the formula in my subreport.

It looks as though it worked when i tried ending it with:
if i=15 then PDates[15] else PDates[i+1];

I'm going to test that this is correct.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top