Results 1 to 6 of 6
  1. #1
    3 Star Lounger
    Join Date
    Jul 2001
    Posts
    280
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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. #2
    Super Moderator WebGenii's Avatar
    Join Date
    Jan 2001
    Location
    Redcliff, Alberta, Canada
    Posts
    4,066
    Thanks
    2
    Thanked 5 Times in 5 Posts

    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
    [b]Catharine Richardson (WebGenii)
    WebGenii Home Page
    Moderator: Spreadsheets, Other MS Apps, Presentation Apps, Visual Basic for Apps, Windows Mobile

  3. #3
    3 Star Lounger
    Join Date
    Jul 2001
    Posts
    280
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Double If IsNull (Access 2000)

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

  4. #4
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    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
    Regards
    John



  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    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. #6
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Double If IsNull (Access 2000)

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


    I agree.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

Posting Permissions

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