Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: For Loop Post Reply Post New Topic
Author Message
suresh.gooty
Newbie
Newbie
Avatar

Joined: 14 Jan 2010
Location: India
Online Status: Offline
Posts: 6
Quote suresh.gooty Replybullet Topic: For Loop
     Posted: 08 Feb 2010 at 11:57pm
Hi All,

I need to check the values record by record..... that means i have to take the first id in the first row and check with 2nd to end row whether any other id available with the same ID....... if found then i need to check the current row date with the matched row date.... if the current row date is less than matched date then i want to display "This row not required" .... actually i wan t to write this code in a seperate variable and place that variable in the report......... Presently i am using the below code and it is not working

stringvar x;
stringvar y;
numbervar i;
numbervar j;
FOR I:= 1 TO COUNT(ID) STEP 1 DO
(
x:=ID
y=DATE
FOR J= 1 TO COUNT(ID) STEP 1 DO
(
IF X=ID AND Y<DATE THEN
"NOT REQUIRED"
EXIT FOR;
);
);
when i am placing this variable in report it is just displaying TRUE IN ALL THE ROWS..... what is the correct code to get the required or not required information.....?? I am using CR 2008......
Thanks & Regards,
Suresh Gooty
Sr Software Programmer
Crystal Reports XI & BO
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 10 Feb 2010 at 10:41am
CR doesn't really have this ability.  You need to identify the most recent date in the datarow, and then you can compare against it.  CR cannot dynamically read records in the report and then determine what to do.  You could create a subreport to do this, or you could modify the data if you are getting if from a stored proc, but doing a straight table join in the main report isn't going to work.
IP IP Logged
suresh.gooty
Newbie
Newbie
Avatar

Joined: 14 Jan 2010
Location: India
Online Status: Offline
Posts: 6
Quote suresh.gooty Replybullet Posted: 10 Feb 2010 at 7:37pm
Hi lockwelle,
 
Thanks a lot for your reply. Sub report idea is good and i tried and getting the required data in subreport. but my report is in landscape & I am not able to increase the width of subreport.... Again it is taking the matching record from main report.... I am not able to group in sub report.... when i am trying to group it is taking only group by id which is matching in main report........  stright join is not working... because multiple id's having multiple dates and i need only one unique id which is having the highest date...........  when i max the date column as max date it is giving the correct result for both id and date.... when i place any third column then again it is displaying duplicate records..... It is a big problem.. Let me know if you have any other option.... but normally in most of the softwares we have the option of records one by one ......... CR don't have........
Thanks & Regards,
Suresh Gooty
Sr Software Programmer
Crystal Reports XI & BO
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 11 Feb 2010 at 6:35am
hmm...Most reporting tools that I have used, treat the data as a whole.  You can't use procedural programming.  I don't use subreports too often, as I don't need them (I get really wide dataset if needed instead).  I would have thought that you can make the subreport landscape, and then expand it in the Main report.  The subreport will only be as wide as you make it in the main report.
 
I was thinking of using the subreport as a tool to find the max date for the id.  In a subreport, CR will read the desired records...hence the performance hit, but it will read them as a group, and you can a date.  I might have missed that you needed a max date...if that is the case, in the main report, create a group by id, in the header you can use the MAX() function, and then you can selectively suppress the data...or display a different value.
 
HTH
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