Results 1 to 3 of 3
  1. #1
    suwilson008 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Sep 2014
    Posts
    2

    Question IIF statement returning #Error in select rows, data type mismatch in criteria expression

    Hello,

    I'm trying to create an expression in a new field using the IIF function, but I haven't been successful. I'm returning a #Error in some rows, and otherwise unexpected results in other rows, and I can't see what's causing the issue. Any guidance would be appreciated!

    I'm trying to do the following:
    Create an expression within a query titled IIR Population that populates "IIR" if the expression is true, or "N/A" if false

    IIR Population: IIf(([Retail / Non-Retail]="Retail") And ([Store Type]="NEWFU") And ([Life in Months]>"84") And ([Cat Minor Category]<>"PARKING") And ([Cat Major Category]<>"INTANGIBLES"),"IIR","N/A")

    In the attachment, there are two tabs...one for the Snapshot table, and the other for the results of the query

    The [Retail / Non-Retail] column on the Query Results tab is a field in the database that's also built on an IIF expression in the same query I'm trying to add this new expression to...not sure if this has anything to do with my issue?

    Retail / Non-Retail: IIf([Snapshot].[RC]="999999","Non-Retail","Retail")

    If I try to do anything with the newly created (but totally incorrect) IIR Population field in Access, I get the following error message:


    Data type mismatch in criteria expression

    Please help!!

    Thank you,
    Susie
    Attached Files Attached Files

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Post the query you attempt. Does it join the two tables? What data type is RC field? If it is number the don't use quote marks around 999999.

    Advise no spaces or special characters/punctuation (underscore is exception) in naming convention. Better would be Retail_NonRetail.
    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
    suwilson008 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Sep 2014
    Posts
    2
    Thank you! Your answer was on the right track for my issue. It was actually my [Life in Months] field that was set as a number. I removed the quotes and it now works as expected...woo hoo!!

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

Similar Threads

  1. Replies: 3
    Last Post: 07-21-2014, 09:33 AM
  2. Replies: 1
    Last Post: 05-02-2013, 01:29 AM
  3. Replies: 1
    Last Post: 05-11-2012, 10:59 AM
  4. Data type mismatch in criteria expression
    By bobt_1234 in forum Queries
    Replies: 3
    Last Post: 02-13-2012, 03:37 PM
  5. Replies: 2
    Last Post: 05-17-2011, 02:40 PM

Tags for this Thread

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