Results 1 to 3 of 3
  1. #1
    kagoodwin13 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Feb 2012
    Posts
    181

    Query Between Dates, or Null

    I'm looking for the syntax on how to do a query I've done many times, but I've lost the source code.

    Process for command:
    1. Select Start Date on Form
    2. Select End Date on Form
    3. Press "Run Query" and query selects based on criteria between dates
    4. If Start Date is empty, query selects based on less than End Date
    5. If End Date is empty, query selects based on greater than Start Date
    6. If Start Date and End Date are empty, query selects all results

    Does anyone have this query handy?



    Thanks in advance!

  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,770
    Maybe like:

    SELECT * FROM tablename WHERE [date field] BETWEEN Nz(Forms!formname![Start Date], #1/1/1900#) AND Nz(Forms!formname![End Date], #12/31/2999#);
    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
    kagoodwin13 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Feb 2012
    Posts
    181
    Yes, that's it! Thank you June.

    Code:
    Between Nz([Forms]![frmSEARCH]![txtStart_Date],#1/1/1900#) And Nz([Forms]![frmSEARCH]![txtEnd_Date],#9/9/9999#)

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

Similar Threads

  1. Replies: 3
    Last Post: 10-29-2013, 04:30 PM
  2. Replies: 21
    Last Post: 06-25-2013, 09:22 AM
  3. Replies: 8
    Last Post: 06-13-2012, 08:08 PM
  4. Replies: 1
    Last Post: 02-23-2012, 02:27 PM
  5. Replies: 2
    Last Post: 08-01-2011, 09:30 AM

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