Question : Formula for If Statement with Null Value - Crystal Reports Developer

Hi experts,

Hopefully this is a quick and easy question but it's extremely urgent.  

I had a formula field that inlcuded the last 3 lines in the code below.  The formula worked fine, and the correct results ("No", "Yes" and "N/A") appeared on the report.  I'm trying to add a statement for fields with a null value.  It recognizes the correct records that are null, but won't display the text 'Not Answered" in the field.  The result on the report is blank.  The other if statements are still working properly.

If isnull({tblMain.Answer}) then answer = "Not Answered"   'added this line for null value
If {tblMain.Answer} = 0 Then answer = "NO"
If {tblMain.Answer} = 1 Then answer = "YES"
If {tblMain.Answer} = 99 Then answer = "N/A"

Almost forgot... I also tried the if statement like this:
If {tblMain.Answer} = "" Then answer = "Not Answered"
I got an error at the "" when trying to save the formula.  Is there any way to say isnull or = "" and get the correct response displayed on the report?

Thanks for any help!

Answer : Formula for If Statement with Null Value - Crystal Reports Developer

Try
If  IsNull({tblMain.Answer})  then answer = "Not Answered"  //'added this line for null value
ELSE If {tblMain.Answer} = 0 Then answer = "NO"
ELSE If {tblMain.Answer} = 1 Then answer = "YES"
ELSE If {tblMain.Answer} = 99 Then answer = "N/A"

Can you change the database to default the fields to -1 and test for that?

Another idea
answer = "Not Answered"
If {tblMain.Answer} = 0 Then answer = "NO"
ELSE If {tblMain.Answer} = 1 Then answer = "YES"
ELSE If {tblMain.Answer} = 99 Then answer = "N/A"

mlmcc

Random Solutions  
 
programming4us programming4us