Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Database values into array Post Reply Post New Topic
Author Message
hazel4832
Newbie
Newbie
Avatar

Joined: 17 Aug 2009
Online Status: Offline
Posts: 5
Quote hazel4832 Replybullet Topic: Database values into array
     Posted: 17 Aug 2009 at 1:09pm
I have a database that has over 1000 products in it. In this database
there's a field called TSICOD that can either be Yes or No. There are
15 products in this database that have yes in this field. The rest are
no. I an trying to load these 15 item numbers into an array in Crystal
Reports. I created the array, but when I go to run the report I get
the error: "A loop was evaluated more than the maximum number of times
allowed." My variable is p and for some reason it is going up to
100001, but it is staying on the same database record (the first
record). Can anyone help me with this?

Thanks in advance.

Code:
global StringVar Array ProArray;
numbervar p=0;

 do
(If Next({ITMMASTER.TSICOD_2}) = "YES" Then
ProArray

:={ITMMASTER.ITMREF_0};
 p:=p+1;)
while (not nextisnull({ITMMASTER.ITMREF_0}));

IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 18 Aug 2009 at 6:20am
you might try doing this in subreport.  Currently, it is sitting on one record.  I don't know if Crystal has a function to move to the next record, but I doubt it.  In a subreport, it would read all the records, and you wouldn't need the loop, just the if statement.
 
HTH
IP IP Logged
hazel4832
Newbie
Newbie
Avatar

Joined: 17 Aug 2009
Online Status: Offline
Posts: 5
Quote hazel4832 Replybullet Posted: 18 Aug 2009 at 6:46am
I actually do have this in a subreport. I'll try it without the loop. Thanks.
IP IP Logged
hazel4832
Newbie
Newbie
Avatar

Joined: 17 Aug 2009
Online Status: Offline
Posts: 5
Quote hazel4832 Replybullet Posted: 18 Aug 2009 at 7:36am
I tried it wothout the loop. Although it didn't error out, it still doesn't seem to be putting anything into the loop. I have:
Shared StringVar Array ProArray;
redim ProArray[15];
numbervar p:=1;
stringvar itm;

itm:=Next({ITMMASTER.TSICOD_2});
(If itm = "YES" Then
ProArray

:={ITMMASTER.ITMREF_0};
 p:=p+1);
in the detail section and then:
whileprintingrecords;

ProArray[3];
in the report footer section.
But it still prints out blank.

Any suggestions?



Edited by hazel4832 - 18 Aug 2009 at 7:37am
IP IP Logged
hazel4832
Newbie
Newbie
Avatar

Joined: 17 Aug 2009
Online Status: Offline
Posts: 5
Quote hazel4832 Replybullet Posted: 18 Aug 2009 at 8:29am
Nevermind. I figure it out. For anyone curious...

You need to have p set to 1 in the report header.
Then use the function:
Global StringVar Array ProArray;
global numbervar p;
stringvar itm;

itm:={ITMMASTER.TSICOD_2};
(If itm = "YES" Then
(redim preserve ProArray[ubound(ProArray)+1];
ProArray

:={ITMMASTER.ITMREF_0};
 p:=p+1));

In the detail section.

Thanks.

IP IP Logged
charls
Newbie
Newbie


Joined: 27 Jul 2010
Location: South Africa
Online Status: Offline
Posts: 2
Quote charls Replybullet Posted: 27 Jul 2010 at 10:37pm
Hi Hazel

when you say "you need to have p set to 1 in the report header." what do you mean. A formula [global numbervar p:=1;]placed into the report header?

Did you need to use [whileprintingrecords;]

Thank you for posting your findings it seems is very helpful
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum