Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: If else then statement Post Reply Post New Topic
Author Message
impalacrazy
Newbie
Newbie
Avatar

Joined: 21 Jul 2008
Location: United States
Online Status: Offline
Posts: 7
Quote impalacrazy Replybullet Topic: If else then statement
     Posted: 21 Jul 2008 at 2:16pm
Hi below is the code i have in place in a formula on my report:
***********************************************************
If {@Arrival Date} > {@Triage time} or {@Triage time} < {@Dr time} then
(
    {@Triage time}
)
else if  {@Arrival Date} > {@Dr time} or {@Arrival Date} > {@Triage time} then
(
    {@Dr time}
)
else
    {@Arrival Date}
***********************************************************
So my error is this. each field creates a date from an excel spreadsheet. for some reason it will only do one of the statements which is the arrival > triage. Can someone let me know why it wont go through the whole statement and populate the field with the correct date instead of it being blank.
 
thanks
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 22 Jul 2008 at 3:18pm
Can any of these values be null?
 
-Dell
IP IP Logged
impalacrazy
Newbie
Newbie
Avatar

Joined: 21 Jul 2008
Location: United States
Online Status: Offline
Posts: 7
Quote impalacrazy Replybullet Posted: 22 Jul 2008 at 3:20pm
yes some of the fields could have a null value (no date) which is my biggest issue.
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 22 Jul 2008 at 3:25pm
Ok, that's where part your problem is.  You need to test for null values.
 
Also, you're testing for  {@Arrival Date} > {@Triage time} in two of the if statements.  The way an If statement works is that it processes through until it finds a true value and then doesn't look at any other conditions.  So, if  {@Arrival Date} > {@Triage time} then it will ALWAYS be cause in the first If.  In English rather than code, what do you want this If statement to do?
 
-Dell
IP IP Logged
impalacrazy
Newbie
Newbie
Avatar

Joined: 21 Jul 2008
Location: United States
Online Status: Offline
Posts: 7
Quote impalacrazy Replybullet Posted: 22 Jul 2008 at 3:40pm

What i would like it to do is this. The data i get comes in a excel file. Now in the file there is one date feild and 3 time fields. My report goes and concatenates these feilds together.

From there i am looking to compare the feilds and place in a new feild the lowest of the times. so for example if the (arrival) datetime in is greater than (triage) datetime or (dr time) datetime then the (dr time) should be placed in the feild. if the (arrival) datetime is greater than (triage) datetime and (triage) datetime is less than (dr time) then the (triage) date time is placed in the feild.
 
hopefully that is clear let me know if its not.
 
Thanks for your help, really appreciate it, this will help me from having to keep doing it manually.Cry
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 22 Jul 2008 at 4:08pm

If you want to ignore the nulls, you'll need to modify your formulas.   Something like this:

if IsNull({table.timefield}) then
   <some date/time in the future>
else
   <your current formula>

Your If statement would then look something like this:

If {@Arrival Date} > {@Triage time}  then 
(
  if {@Triage time} > {@Dr time} then
    {@Dr time}
  else
    {@Triage time}
}
else
(
  if {@Arrival date} > {@Dr Time} then
    {@Dr Time}
  else
    {@Arrival date}
)
 
-Dell
IP IP Logged
impalacrazy
Newbie
Newbie
Avatar

Joined: 21 Jul 2008
Location: United States
Online Status: Offline
Posts: 7
Quote impalacrazy Replybullet Posted: 22 Jul 2008 at 4:23pm

thanks alot. I will give this a try and see if it works.

Embarrassed

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