Understanding "Null"

  • Thread starter Thread starter Mike Revis
  • Start date Start date
M

Mike Revis

Hi Group
Access 2000 winxppro

Why is "Null" not "Less than 1"?

My field [QtyLabel] is number data type.

When the form opens on a new record the field has a zero in it. Normal
right?

My command button to preview the report has this
If [QtyLabel] < 1 then
msgbox etc...
Me.QtyLabel.setfocus
Else
DoCmd.OpenReport etc...
End If

As long as the field has a zero in it this works.

If I delete the zero (creating a null condition, I think) then I get an
error opening the report.

If I use

If IsNull(QtyLabel) or [QtyLabel] < 1 then etc...

It works under either condition.

I think I know that "Null" is "nothing". It is not <1 because it is nothing.

As always any thoughts, comments or suggestions are welcome.

Mike
 
Null means "unknown". Since you don't know what Null is supposed to be,
there's no way of knowing whether or not it's less than 1.

Rather than what you've got, you could also use

If Nz(Me.[QtyLabel], 0) < 1 Then

In that way, if what's in QtyLabel is Null, it'll be replaced by 0,
otherwise it'll use whatever's in QtyLabel.
 
Null is the absence of a value. "less than 1" evaluates specific values in
comparison to 1: for instance, .999999 (on and on) is less than one, zero
is less than 1, -1 is less than 1. you see the difference in the logic?

if you don't like using the longer expression

If IsNull(Me!QtyLabel) or Me!QtyLabel < 1 Then

then try this expression instead, as

If Nz(Me!QtyLabel, 0) < 1 Then

you can read up on the Nz() function in Help, to learn how it works.

hth
 
Thanks tina, and Douglas also
I've been trying to avoid Nz but it looks as if I'm going to have to learn
it.

Mike

tina said:
Null is the absence of a value. "less than 1" evaluates specific values in
comparison to 1: for instance, .999999 (on and on) is less than one, zero
is less than 1, -1 is less than 1. you see the difference in the logic?

if you don't like using the longer expression

If IsNull(Me!QtyLabel) or Me!QtyLabel < 1 Then

then try this expression instead, as

If Nz(Me!QtyLabel, 0) < 1 Then

you can read up on the Nz() function in Help, to learn how it works.

hth


Mike Revis said:
Hi Group
Access 2000 winxppro

Why is "Null" not "Less than 1"?

My field [QtyLabel] is number data type.

When the form opens on a new record the field has a zero in it. Normal
right?

My command button to preview the report has this
If [QtyLabel] < 1 then
msgbox etc...
Me.QtyLabel.setfocus
Else
DoCmd.OpenReport etc...
End If

As long as the field has a zero in it this works.

If I delete the zero (creating a null condition, I think) then I get an
error opening the report.

If I use

If IsNull(QtyLabel) or [QtyLabel] < 1 then etc...

It works under either condition.

I think I know that "Null" is "nothing". It is not <1 because it is nothing.

As always any thoughts, comments or suggestions are welcome.

Mike
 
you're welcome, and don't be afraid of the Nz() function - it works very
simply, and is an extremely handy tool. :)


Mike Revis said:
Thanks tina, and Douglas also
I've been trying to avoid Nz but it looks as if I'm going to have to learn
it.

Mike

tina said:
Null is the absence of a value. "less than 1" evaluates specific values in
comparison to 1: for instance, .999999 (on and on) is less than one, zero
is less than 1, -1 is less than 1. you see the difference in the logic?

if you don't like using the longer expression

If IsNull(Me!QtyLabel) or Me!QtyLabel < 1 Then

then try this expression instead, as

If Nz(Me!QtyLabel, 0) < 1 Then

you can read up on the Nz() function in Help, to learn how it works.

hth


Mike Revis said:
Hi Group
Access 2000 winxppro

Why is "Null" not "Less than 1"?

My field [QtyLabel] is number data type.

When the form opens on a new record the field has a zero in it. Normal
right?

My command button to preview the report has this
If [QtyLabel] < 1 then
msgbox etc...
Me.QtyLabel.setfocus
Else
DoCmd.OpenReport etc...
End If

As long as the field has a zero in it this works.

If I delete the zero (creating a null condition, I think) then I get an
error opening the report.

If I use

If IsNull(QtyLabel) or [QtyLabel] < 1 then etc...

It works under either condition.

I think I know that "Null" is "nothing". It is not <1 because it is nothing.

As always any thoughts, comments or suggestions are welcome.

Mike
 

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

Back
Top