Re: IIF () or If Then Else?
Welcome to CodeGuru forums!
Code:
If Not IsNull({@Diag Date}) Then {@Diag Date}
Else
If Not IsNull({@Consult Date}) Then {@Consult Date}
Else
{@Create Date}
If it's Crystal Reports then it's important to see:
menu/Options/Reporting/ReadingData/Convert Database Values to Default
If it is not checked then you could test with IsNull
If it is checked then you should test with: Date({table.datefield}) = Date(0,0,0)
Re: IIF () or If Then Else?
Hi,
Thank you for your response. With the code that you gave me, only the value of the {@Diag Date} field populates the formula field where all three fields used in the code are populated. Otherwise it is null.
Re: IIF () or If Then Else?
You are evaluating formula fields and only you know the code : {@Diag Date}, {@Consult Date} and {@Create Date}
So share with us and post the code of the formulas
Re: IIF () or If Then Else?
All three formula fields, {@Diag Date}, {@Consult Date} and {@Create Date}, use the date() function to pull the date part of three date-time fields, DX_Dtm, Diag_DTtm, and Create_DTtm. So they are date(DX_Dtm), date(Diag_DTtm), and date(Create_DTtm). I used the original fields in the formula and had the same results.
Re: IIF () or If Then Else?
The IIF() function and the if then else statement both seem to test the first part of the code, If Not IsNull({@Diag Date}) Then {@Diag Date}, and it does not go on from there.
Re: IIF () or If Then Else?
Quote:
The IIF() function and the if then else statement both seem to test the first part of the code, If Not IsNull({@Diag Date}) Then {@Diag Date}, and it does not go on from there
Because the formula field is not null
Apply the formula from post #2 to original table fields
But before enter to : menu/Options/Reporting/ReadingData/Convert Database Values to Default
Uncheck it and you could test with IsNull
Check it and you must test with: Date({table.datefield}) = Date(0,0,0)
Re: IIF () or If Then Else?
If Convert Database Values to Default is not checked and I use: If Not IsNull({@Diag Date}) Then {@Diag Date}
Else
If Not IsNull({@Consult Date}) Then {@Consult Date}
Else
{@Create Date} it is still the same,
If it is checked and I use it by checking with date(0,0,0) it pulls only the value of {@Create Date}
as the value of the formula field where all three are populated.
Re: IIF () or If Then Else?
"Check it and you must test with: Date({table.datefield}) = Date(0,0,0) " It should be <> Date(0,0,0). It worked then. Thank you very much for your help!
Re: IIF () or If Then Else?
I can't find the thumbs up on the thread tools menu, sorry!