Results 1 to 4 of 4
  1. #1
    K44Devil is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    2

    Expression Criteria Causing Data Type Mismatch Error

    I have an expression within a query that calculates the difference between two dates like this:

    Days Late: [filing date]-(DateSerial([related year],[fymonth],[fyday])+[minoffiling time])



    This returns the number I'm looking for. However, I'm only interested in positive numbers that would indicate a late filing. Inputting >0 as my criteria results in a data type mismatch error.

    I suspect it has something to do with the fields [fymonth] and [fyday] which are expressions from another query that pull the 12 and 31 from "12/31" which itself is stored as a text field <--- problem right here??

    Please help. I've wasted enough time. Keep in mind that I'm hardly literate in SQL so I've been working primarily out of the design grid.

    Thanks!!

  2. #2
    burrina's Avatar
    burrina is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    Are any of those values Null by chance? Try wrapping with Nz.

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    I don't understand why >0 errors. The expression should result in a number value or Null if any of the terms is Null. I can't replicate the issue.

    If you want to 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.

  4. #4
    K44Devil is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    2
    I knew it was something simple! June7, I felt like you. It didn't make sense. That same code worked fine last week but I made one change which added null value records.

    Wrapping it with Nz did the trick!

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

Similar Threads

  1. Replies: 1
    Last Post: 05-02-2013, 01:29 AM
  2. Replies: 1
    Last Post: 05-11-2012, 10:59 AM
  3. Query Criteria Causing Data Mismatch Error
    By jrubenol in forum Queries
    Replies: 2
    Last Post: 09-14-2011, 09:34 AM
  4. Replies: 2
    Last Post: 05-17-2011, 02:40 PM
  5. Data type mismatch in criteria expression
    By shexe in forum Queries
    Replies: 2
    Last Post: 09-01-2010, 12:47 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