Problem With Null

Z

zyus

I hv this expression in my report field

(Sum(Abs(([NPLFLG] Like "N" And [ARRMTH] Not Between 1 And 5))))

Problem arise when my NPLFLG field having Null Value...how can i handle it ?

TQ
 
B

Brendan Reynolds

zyus said:
I hv this expression in my report field

(Sum(Abs(([NPLFLG] Like "N" And [ARRMTH] Not Between 1 And 5))))

Problem arise when my NPLFLG field having Null Value...how can i handle it
?

TQ


(Sum(Abs((NZ([NPLFLG],"") Like "N" And [ARRMTH] Not Between 1 And 5))))

.... or ...

(Sum(Abs((([NPLFLG] & "") Like "N" And [ARRMTH] Not Between 1 And 5))))

In other words, use either the NZ() function or concatenation to convert the
Null values to empty strings.

Note that those are double quotes with nothing between them, no spaces.
 
Z

zyus

My NPLFLG will consist of these 3 value

1. N
2. Y
3. null

null is equal to N.
null is NOT equal to Y

Can the expression suggested by you will handle my issue as above

Brendan Reynolds said:
zyus said:
I hv this expression in my report field

(Sum(Abs(([NPLFLG] Like "N" And [ARRMTH] Not Between 1 And 5))))

Problem arise when my NPLFLG field having Null Value...how can i handle it
?

TQ


(Sum(Abs((NZ([NPLFLG],"") Like "N" And [ARRMTH] Not Between 1 And 5))))

... or ...

(Sum(Abs((([NPLFLG] & "") Like "N" And [ARRMTH] Not Between 1 And 5))))

In other words, use either the NZ() function or concatenation to convert the
Null values to empty strings.

Note that those are double quotes with nothing between them, no spaces.
 
J

Jeff C

--
Jeff C
Live Well .. Be Happy In All You Do


zyus said:
My NPLFLG will consist of these 3 value

1. N
2. Y
3. null

null is equal to N.
null is NOT equal to Y

Can the expression suggested by you will handle my issue as above

(Sum(Abs((NZ([NPLFLG],"N") Like "N" And [ARRMTH] Not Between 1 And 5))))

... or ...

(Sum(Abs((([NPLFLG] & "N") Like "N" And [ARRMTH] Not Between 1 And 5))))








Brendan Reynolds said:
zyus said:
I hv this expression in my report field

(Sum(Abs(([NPLFLG] Like "N" And [ARRMTH] Not Between 1 And 5))))

Problem arise when my NPLFLG field having Null Value...how can i handle it
?

TQ


(Sum(Abs((NZ([NPLFLG],"") Like "N" And [ARRMTH] Not Between 1 And 5))))

... or ...

(Sum(Abs((([NPLFLG] & "") Like "N" And [ARRMTH] Not Between 1 And 5))))

In other words, use either the NZ() function or concatenation to convert the
Null values to empty strings.

Note that those are double quotes with nothing between them, no spaces.
 
B

Brendan Reynolds

zyus said:
My NPLFLG will consist of these 3 value

1. N
2. Y
3. null

null is equal to N.
null is NOT equal to Y


Null is neither equal to nor not equal to anything. Try the following in the
Immediate window ...

? Null = "N"
Null
? Null <> "Y"
Null

The NZ() expression can be used to convert a Null value to another value. It
takes an optional second argument which specifies the value you want to be
used to replace Null values. The following example will replace Null values
with the letter "N" ...

NZ([NPLFLG], "N")

NZ() is an Access function, it will work fine as long as your query is used
only within Access. If you think you may need to use your query other than
via Access, you can use the IIF() and IsNull() functions instead ...

IIF(IsNull([NPLFLG]), "N", [NPLFLG])
 
J

John Spencer

I would use the following expression in a query.n
Abs(Sum((NPLFLG is Null or NPLFLG = 'N') AND ArrMth Not Between 1 and 5)))

John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County

Brendan said:
zyus said:
My NPLFLG will consist of these 3 value

1. N
2. Y
3. null

null is equal to N.
null is NOT equal to Y


Null is neither equal to nor not equal to anything. Try the following in
the Immediate window ...

? Null = "N"
Null
? Null <> "Y"
Null

The NZ() expression can be used to convert a Null value to another
value. It takes an optional second argument which specifies the value
you want to be used to replace Null values. The following example will
replace Null values with the letter "N" ...

NZ([NPLFLG], "N")

NZ() is an Access function, it will work fine as long as your query is
used only within Access. If you think you may need to use your query
other than via Access, you can use the IIF() and IsNull() functions
instead ...

IIF(IsNull([NPLFLG]), "N", [NPLFLG])
 
B

Brendan Reynolds

John Spencer said:
I would use the following expression in a query.n
Abs(Sum((NPLFLG is Null or NPLFLG = 'N') AND ArrMth Not Between 1 and
5)))


Good point, John, yes, no function call required.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Calculation In Query 1
Replace Null In Text Field 2
To Add % In Query 6
Query Null 1
Date Calculation 2
Pattern Query 14
Calculate Null Field 2
Null Value Query 1

Top