Results 1 to 8 of 8
  1. #1
    Mtyetti2 is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    26

    Data Type Mismatch from blank calculated field.

    I have a report that is based on a query. It calculates expiration dates for employees. For example, a medical examination expires 1 year from exam date. The problem I have is unless I have dates entered for every employee, it gives me a data type mismatch when i view the report.
    The dates aren't always required. Is there a way to have the blank calculated expiration dates to read "missing" or something similar in the report? In the query, they show up as #error.



    Thank you all so much. Hopefully an easy fix!
    Scott

  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,626
    An expression to show an alternate text should be possible. Simply: Nz([field],"Missing")

    Post query for analysis.

    Or provide db. 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
    Mtyetti2 is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    26
    Still no luck. Used Nz([MedicalExpires], "missing") as the control source in the report. Still kicks back Data Type Mismatch.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Odd. The expression works for me.
    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.

  5. #5
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Used Nz([MedicalExpires], "missing") as the control source in the report
    Why aren't you using this in the query? That is where I would have the expression.

    Plus, it is faster in the query that calculating in a control source of a control in the report.

  6. #6
    Mtyetti2 is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    26

    DB Attached

    Sample database is attached. When you open the report, it gives the Data Type mismatch. I've tried several options, including putting the equation in the Query instead of the Control Source. No avail.
    As you can see, the 'medexpires' field is a calculated field.

    Thanks for the help!
    Attached Files Attached Files

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    The issue is DateSerial errors on Null or empty string - all number conversion functions do.

    MedicalExp: IIf(IsNull([Medical]), Null, DateAdd("m",13,DateSerial(Year([Medical]),Month([Medical]),1))-1)
    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.

  8. #8
    Mtyetti2 is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    26
    June7, you are a genius! That fixed it!!!

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

Similar Threads

  1. Replies: 1
    Last Post: 07-24-2014, 08:35 PM
  2. My calculated field data type is not working
    By Access_Novice in forum Access
    Replies: 1
    Last Post: 11-09-2013, 05:00 AM
  3. Replies: 1
    Last Post: 07-19-2013, 12:00 PM
  4. Replies: 2
    Last Post: 03-19-2013, 09:36 PM
  5. data type mismatch
    By jgelpi16 in forum Programming
    Replies: 5
    Last Post: 08-02-2010, 04:15 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