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

While Do problem

Status
Not open for further replies.

Flopper

Technical User
Jan 19, 2001
140
AT
Greetings,

[Crystal 8.5].

I'm having the problem with the following section of a formula:
------------------------------------------------------------
Local Datevar Dt:= Date({@StartDate})+1;
While Dt<Date({@EndDate})
Do
(
DayCount[DayOfWeek(Dt)]:=DayCount[DayOfWeek(Dt)]+1;
Dt:= Dt+1;
);
------------------------------------------------------------
When refreshing the report i'm retrieving the following statement:

"A loop was evaluated more than the maximum number of times allowed".

This formula works on another report, however both the {@StartDate} and {@EndDate} formulas use different dates on the problematic report. On both of the reports {@StartDate}+1 could be greater than {@EndDate}, yet this hasn't caused a problem on the previous report. The maximum end date is 14/09/2005 (today) so that shouldn't be a problem. I've also attempted to stop the While command if StartDate+1 > EndDate but without success. Any ideas?

NB: This section calculates the number of days of week between Start and End Date, excluding the start and end day.

Thanks
 
Ideally it would be better to see the whole of your formula, but from the snippet you have posted here I guess Day count is an array variable ?

If this is true then crystal variables have a maximum limit of 1000 values and this may be the route of your problem.

HTH

Gary Parker
MIS Data Analyst
Manchester, England
 
Apologies, i missed that part off.

Local Numbervar Array DayCount;
Redim Preserve DayCount[7];

DayCount thus can contain no more than 7 numbers.

I understand that an array can have no more than 1000 values but this problem has not occurred in a previous report containing similar data... ah i've just figured it out. The first start date has been set to 01/01/0001 and thus, the end date for this record (13/09/2005) is somewhat greater than the 30,000 iterations allowed.

Thanks for response all the same Gary.

Phil

C'mon Liverpool! ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top