Results 1 to 3 of 3

Thread: IIf then

  1. #1
    Join Date
    Dec 2003
    Posts
    5

    Unanswered: IIf then

    Good morning. I need a little in access 2003 help with a simple IIF statement. It is in a text box on an invoice form for the tax charged. Basically if the item sold is a new item or is service I need to check 2 different fields to see if it is tax exempt or not. Here is what I have so far

    =IIf([ser_taxex] Or [sal_taxex],([invam]-[disamt])*0.0925),0)

    If either is true then calculate tax or if both are false tax is zero. I am sure I am missing something simple.....

    As soon as I open up the form I get #Name? in the tax field on the form and a VB error "the value you entered isn't valid for this field.

    Thanks ahead of time for your help.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    i think you need to compare each of those column values to something

    for example,
    Code:
    IIf( [ser_taxex] = 'yes'
      Or [sal_taxex] = 'yes', ([invam]-[disamt])*0.0925  ,0 )
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Quote Originally Posted by r937
    i think you need to compare each of those column values to something

    for example,
    Code:
    IIf( [ser_taxex] = 'yes'
      Or [sal_taxex] = 'yes', ([invam]-[disamt])*0.0925  ,0 )
    Actually, if ser_taxex and sal_taxex are boolean fields, that part of the original code was fine, I think. r397 corrected the real problem without even commenting on it.

    =IIf([ser_taxex] Or [sal_taxex],([invam]-[disamt])*0.0925),0)

    has an extra parens after *0.0925

    Should be

    =IIf([ser_taxex] Or [sal_taxex],([invam]-[disamt])*0.0925,0)
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Posting Permissions

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