Results 1 to 3 of 3
  1. #1
    cmf0106 is offline Novice
    Windows XP Access 97
    Join Date
    Dec 2009
    Posts
    6

    If and only if statement, to fix overflow error

    Im trying to produce an if and only if statement where if only does the calculation if the denominator is not zero.

    Where did I go wrong?

    Calc: iif(
    [listpriceorig]<>0,
    [listprice]/
    [listpriceorig]*100,0])

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows XP Access 2002
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Try:
    Calc: IIF(Nz([listpriceorig],0)<>0,[listprice]/[listpriceorig]*100,0])

  3. #3
    PianoMan64 is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2009
    Posts
    29

    Reply to your questions about IIF Statement

    Quote Originally Posted by cmf0106 View Post
    Im trying to produce an if and only if statement where if only does the calculation if the denominator is not zero.

    Where did I go wrong?

    Calc: iif([listpriceorig]<>0,[listprice]/[listpriceorig]*100,0])
    Hello cmf0106,

    You have to make sure that both the numerator and denominator are not Zero and also are not null.

    There are two function you can use to check for Null Values. That is NZ() aka Not Zero and IsNull() for if a value is null will return true.

    The function will check for a null value and then you can set it to whatever value you wish.

    Example: NZ(VariableNameHere, Numerical Value to set to when NULL)

    Example: IsNull(VariableNameHere)

    Usage like IIF(NZ(ListPrice,0) > 0 AND NZ(Listpriceorig,0) > 0,[listprice]/[listpriceorig]*100],0)

Please reply to this thread with any new information or opinions.

Similar Threads

  1. IIF statement
    By james1982 in forum Access
    Replies: 1
    Last Post: 07-20-2009, 09:38 AM
  2. how to use IF then statement
    By ronnie4 in forum Access
    Replies: 1
    Last Post: 03-17-2009, 11:32 PM
  3. Syntax Error In Insert Into Statement
    By frankvfox in forum Queries
    Replies: 1
    Last Post: 09-09-2008, 12:35 PM
  4. Run time error '6': Overflow
    By wasim_sono in forum Access
    Replies: 0
    Last Post: 06-22-2007, 06:44 AM
  5. "Overflow" error message.
    By joeferraro2000 in forum Queries
    Replies: 0
    Last Post: 03-08-2007, 06:36 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums