Results 1 to 3 of 3
  1. #1
    kontorirott is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    2

    IIF statement retuns a type mismatch error - but only for a certain format of data

    So here is a deal. I have a long list of articles, all imported into Access from TXT file, field is a text. A large portion of them begins with four zeros, and I need to filter them and convert into 6 signs codes, the latter 6 signs. there are also lots of 10 signs codes, that must remain as they are. Now what had put me in deadlock is that IIF statement selects easily the rows beginning with "0000" and produces Right(([field]);6), or six last signs from all types of articles (as positive statement criteria): all numeric, combined alpha-numeric, all alphabetical (100% alphabetical field are filtered with negative criteria, which is just reproducing the whole field) - the only exception is alpha-numeric combinations that begin with a letter. Those query rows produce an type mismatch error, like when you are entering a number in a text field. But if it is a text source, both for numbers and alpha-numeric combinations, and it is okay to select certain fields from this text string - why am I getting an error only for alpha-numeric combinations, beginning with a letter? Why is this happening and how can I get rid of this? so it cannot be alpha instead of number or vice versa, it cannot be alpha/number instead of boolean - it must be something else. any ideas, please?

  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,943
    Need code to analyse. Post the IIf expression. Post the entire SQL statement. If you want, provide db for analysis. Follow instructions at bottom of my post.
    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
    kontorirott is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    2
    Hahaa, got it. me stupid. here's the IIF statement:

    Short-long_division: IIf(Left(([BR_new]![Part number]);4)=0;Right(([BR_new]![Part number]);6);[BR_new]![Part number])

    and the fault was Numeric field in the expression, I have changed =0 to ="0000" and it was working as I needed it to. Thank you everybody!

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

Similar Threads

  1. Data type mismatch error
    By Tomfernandez1 in forum Programming
    Replies: 5
    Last Post: 10-05-2012, 07:27 AM
  2. Data type mismatch error
    By nigelbloomy in forum Programming
    Replies: 1
    Last Post: 08-01-2012, 09:19 AM
  3. Replies: 1
    Last Post: 05-11-2012, 10:59 AM
  4. Replies: 14
    Last Post: 02-08-2012, 03:36 PM
  5. Data type mismatch error
    By AccessUser123 in forum Queries
    Replies: 1
    Last Post: 05-22-2011, 07:48 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