Results 1 to 6 of 6
  1. #1
    athyeh is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jun 2013
    Posts
    170

    Problems with New Year and Greater than or Equal Criteria in Query

    Hi Folks,

    Hoping that this will be a simple fix, I have this criteria embedded in the Date Field of a query

    >=Format([Forms]![Reporting]![FromAR],"mm/dd/yyyy") And <=Format([Forms]![Reporting]![ToAR],"mm/dd/yyyy")

    It was working fine until the new year occured, and now when I try to pull a date range between that includes 12/31/2013-1/1/2014, the query fails to draw any results.



    I'm assuming because the query doesn't register that 1/1/2014 is "Greater than" 12/31/2013? Can anybody help me troubleshoot?

    Thanks!

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Just a guess, but have you tried:
    >=CDate(Format([Forms]![Reporting]![FromAR],"mm/dd/yyyy")) And <=CDate(Format([Forms]![Reporting]![ToAR],"mm/dd/yyyy"))
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    athyeh is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jun 2013
    Posts
    170
    Quote Originally Posted by Bob Fitz View Post
    Just a guess, but have you tried:
    >=CDate(Format([Forms]![Reporting]![FromAR],"mm/dd/yyyy")) And <=CDate(Format([Forms]![Reporting]![ToAR],"mm/dd/yyyy"))
    Just did, came back with "This expression is typed incorrectly...." error.

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    What is the Data Type of the field.
    Also, second guess:
    Between CDate(Format([Forms]![Reporting]![FromAR],"mm/dd/yyyy")) And CDate(Format([Forms]![Reporting]![ToAR],"mm/dd/yyyy"))
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Why do you need to use format function?

    Format function results in a string value. The CDate function should convert back to a true date value but since it is still not working, I suspect something is wrong with the values input to textboxes and/or the dates stored in table.
    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.

  6. #6
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    the format is changing your date to a string so you're trying to find something between two text values which is going to give you inconsistent results.

    have you tried:

    between [Forms]![Reporting]![FromAR] And [Forms]![Reporting]![ToAR]

    as your criteria instead.

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

Similar Threads

  1. Replies: 1
    Last Post: 07-26-2013, 11:30 AM
  2. Criteria not equal to and null
    By andy-29 in forum Access
    Replies: 7
    Last Post: 11-21-2012, 06:16 PM
  3. Query criteria from form (just the year)
    By user622 in forum Forms
    Replies: 2
    Last Post: 07-26-2011, 09:51 AM
  4. Greater than or equal to date
    By stryder09 in forum Access
    Replies: 1
    Last Post: 04-14-2011, 03:54 PM
  5. Replies: 1
    Last Post: 12-09-2005, 10:29 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