# Thread: Double If IsNull (Access 2000)

1. ## Double If IsNull (Access 2000)

I want to build a condition with the following syntax:

If either quantity or carton is null Then..

The following line does not take into account the cartons and i continue to get the message
only for the quantity.That is, i may have filled in cartons, but in this case the code does not work.

Where is my mistake?

If IsNull(Me.Quantity) Or ( Me.cartons] Then
MsgBox "You must enter either a quantity or cartons!", vbCritical
Cancel = True

2. ## Re: Double If IsNull (Access 2000)

Try
If IsNull<font color=red>(</font color=red>(Me.Quantity) Or ( Me.cartons]<font color=red>)</font color=red> Then

Cheers

3. ## Re: Double If IsNull (Access 2000)

Thank you. Now it works fine and i get the result i wanted

4. ## Re: Double If IsNull (Access 2000)

I would have thought that

If (IsNull(Me.Quantity) Or IsNull(Me.cartons]) ) Then would be safer

Here is a table of how the or function is evluated. One Null does not necessarily result in a Null outcome.

If expression1 is And expression2 is Then result is
True True True
True False True
True Null True
False True True
False [False False
False Null Null
Null True True
Null False Null
Null Null Null

5. ## Re: Double If IsNull (Access 2000)

You are correct, you must use two separate calls to IsNull for consistent results. The outer parentheses are not strictly necessary (they won't hurt either):

If IsNull(Me.Quantity) Or IsNull(Me.cartons]) Then

6. ## Re: Double If IsNull (Access 2000)

>>IIf (IsNull(Me.Quantity) Or IsNull(Me.cartons]) ) Then would be safer <<

I agree.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•