Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: if statement help Post Reply Post New Topic
Author Message
mcotten
Newbie
Newbie


Joined: 04 Mar 2010
Online Status: Offline
Posts: 5
Quote mcotten Replybullet Topic: if statement help
     Posted: 17 Mar 2010 at 3:14pm

I need to store a filed in a variable if one condition is met, and reference that fiield if another condition is met. The table name is billing.

Service Date 1                    Sub Item
01/01/2010                         0
01/01/2010                         1
02/05/2010                         2
02/23/2010                         3
01/12/2010                         0
02/23/2010                         1
 
The ones that hae sub item 0 are charges and the others are payments. If it is a 0 I need to print the service date 1. if it is anything else I need to print the date from the preceeding 0 row. I was thinking I would store the date from the 0 row when it is read so it would always be set to the correct date and print the variable if it is anything over 0. I can't for the life of me get this to work.
 
This is what I have now adn it is giving me the wrong date and only on the ones the are > 0 so it is like this
 
blank
01/01/2010
02/02/2010
02/23/2010
blank
02/23/2010
 
WhilePrintingRecords;
 
DateTimeVar srvdate;
 
if {Billing_Detail.Sub Item} = 0 then
{Billing_Detail.Service Date 1};
srvdate := {Billing_Detail.Service Date 1};
 
if {Billing_Detail.Sub Item} > 0 then
srvdate;
 
if I leave off the last if statement it print the date of the actual row and not the one from the 0 row.
 
 
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 19 Mar 2010 at 3:19am
do you mean
if {Billing_Detail.Sub Item} = 0 then (
{Billing_Detail.Service Date 1};   //I think that this line is not needed
srvdate := {Billing_Detail.Service Date 1};
);
 
if {Billing_Detail.Sub Item} > 0 then
srvdate;
 
 
without the parens, the srvdate is being updated each and every record, not just the 0
 
HTH
IP IP Logged
mcotten
Newbie
Newbie


Joined: 04 Mar 2010
Online Status: Offline
Posts: 5
Quote mcotten Replybullet Posted: 19 Mar 2010 at 2:20pm
Thank you very much, half way there. I am getting the correct dates for the ones that at > 0 but the ones that are = 0 are still blank. I don't see why they aren't being set. I tried with and without the {Billing_Detail.Service Date 1};. Since I am getting the correct date for some I know that it is going through and setting the srvdate so why isn't it setting the first date?
 
Again thank you very much for the help.
 
EDIT: I just commented out the second if and the = 0 dates were printed. It is getting stepped on somehow. I even tried printing the srvdate instead of the {Billing_Detail.Service Date 1};.  I don't get it.


Edited by mcotten - 19 Mar 2010 at 2:27pm
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