Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IsNull?? How does this work?

Status
Not open for further replies.

kevnatajax

Technical User
Jun 25, 2002
14
US
Below is a formula field I'm using and I need to only diplay it when numbers are in the field. Is ISNULL the answer and How would I put it in this formula?


select {Clmincr.DURATION}
case 1:
"2001"
case 2:
"2000"
case 3:
"1999"
case 4:
"1998"
case 5:
"1997"
case 6:
"1996"
case 7:
"1995"
case 8:
"1994"
case 9:
"1993"
case 10:
"1992"
case 11:
"1991"
case 12:
"1990"
 
Hi,

Instead of using case statement use if then else logic. The formula goes like this if isnull({Clmincr.DURATION})=1 then 2001 else if isnull({Clmincr.DURATION})=2 then 2002 likewise complete your entire formula. I think Isnull can be used only in if statements I am not 100% sure about this.



Thanks,
Hamida
 
Hi,

I am sorry Ignore the above post. Try this
if isnull({Clmincr.DURATION})or {Clmincr.DURATION}=1 then
"2001"
else
if isnull({Clmincr.DURATION})or {Clmincr.DURATION}=2 then
"2002"
Try replacing "or" with "and" and see the results.


Thanks,
Hamida
 
Dude,

I don't think you want to be doing

if isnull({Clmincr.DURATION})or {Clmincr.DURATION}=1 then
"2001"
else
if isnull({Clmincr.DURATION})or {Clmincr.DURATION}=2 then...

For one thing, if the field was null in the first place, the first if would catch it. You wouldn't need to have it in the subsequent sub-ifs as well. Also, with the above formula, nulls and Durations of 1 would be treated exactly the same way. Is that what you want?

I don't really get "I need to only diplay it when numbers are in the field". If the field didn't have any numbers in it, then it wouldn't show up anyway, would it? I mean, it'd already be null. I'm going to assume that you mean you want the case to be displayed if the Duration is not null.

The long and the short of it is that Hamida is right about IsNull being used with Ifs rather than Case. You can't use IsNull in a Case argument, but you can use it in an If which contains a Case.

If Not IsNull({Clmincr.DURATION}) Then
SELECT {Clmincr.DURATION}
CASE 1:"2001"
CASE 2:"2000"
...
Default:""

(You would have to use the Default of the Case to return the null, rather than attempt to do it with the Else of the container If.)

All the best,

Naith
 
A formula will NOT print when it tries to use a field and encounters a null value. So your original formula should do exactly what you want. If it doesn't let us know. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top