Results 1 to 4 of 4
  1. #1
    shin_mitsugi is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    May 2014
    Posts
    8

    IFF statement script question

    I am trying to write an IFF statement that will fill in a specific dollar amount depending on what item has been purchased. For example, if the item is a car, then $1000, if its a truck, then $1500.



    I imagined the code to be something like:

    IIF([Product]="car",$1000,IIF([Product]="Truck",$1500,""))

    However, if I were to type this into ACCESS it doesn't work. Access produces an error that says "you cannot set "price" to the calculated data type." What does this mean and can anybody please write the formula in the way that Access needs it to be written?

    Thank you so much!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,645
    Don't include the $ sign. Also, if this is a number type field then can't use the "" empty string. Use a number or Null.

    Where are you using this expression?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Where are you trying to enter this calculation?
    Also, get rid of the $ sign before the number. Currency formatting will take care of that, but you just want a strict number in there, with nothing else.

  4. #4
    snipe's Avatar
    snipe is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    287
    To summarize what these guys said...

    If the "Price" field is a number type:

    IIF([Product]="car",1000,IIF([Product]="Truck",1500,null))

    If the "Price" field is a text type:

    IIF([Product]="car","1000",IIF([Product]="Truck","1500",null))


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

Similar Threads

  1. Iff Statement Question
    By LanieB in forum Queries
    Replies: 3
    Last Post: 01-11-2013, 03:44 PM
  2. Replies: 6
    Last Post: 01-05-2013, 05:23 PM
  3. New Line in VBA Script
    By tylerg11 in forum Forms
    Replies: 8
    Last Post: 01-04-2012, 02:01 PM
  4. Replies: 2
    Last Post: 10-13-2011, 09:14 AM
  5. Login Script
    By theITguy in forum Access
    Replies: 2
    Last Post: 03-06-2009, 03:37 AM

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