Results 1 to 3 of 3
  1. #1
    Gary Childress is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2012
    Posts
    34

    Need blank option in a "between" two dates search

    I have a form called "Switchboard". On the form are two text boxes formatted for date called "SearchText1" and "SearchText2". I also have a query called "Main Events Table Query". "Main Events Table Query" has the criteria below in the criteria field of the field "Event Start Date". When a user types in a date range in the two text boxes it will pull up records whose value in "Event Start Date" field is between those two dates. HOWEVER, if the user leaves one or both fields blank it will not pull up any records. The code I'm using to do this is below. Is there a way to construct the expression below in such a way that if the user leaves the fields blank ALL records will come up instead of none? In other words I want the user to have the option to either use dates in their search criteria when they open the following form or else not use dates in their search criteria when they open the form.

    Code:
    Between [Forms]![Switchboard]![SearchText1] And [Forms]![Switchboard]![SearchText2]
    Thank you for any assistance.

    PS: The form "Switchboard" has a button on it which opens up the form "Main Events Form" which is populated by the query "Main Events Table Query". So when the user types in their filter criteria on the form Switchboard and then clicks the button to launch "Main Events Form" the form will load with the records matching the desired criteria.



    Please let me know if you need any other info. Thanks again.

  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:

    Between Nz([Forms]![Switchboard]![SearchText1], #1/1/1900# And Nz([Forms]![Switchboard]![SearchText2],#12/31/2900#)
    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
    Gary Childress is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2012
    Posts
    34
    OMG! It worked! Thank you so much!

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

Similar Threads

  1. Replies: 3
    Last Post: 12-06-2014, 03:59 AM
  2. Replies: 11
    Last Post: 06-18-2013, 07:48 AM
  3. Replies: 8
    Last Post: 03-05-2013, 01:20 PM
  4. Replies: 2
    Last Post: 11-14-2012, 04:47 PM
  5. Replies: 1
    Last Post: 09-05-2008, 12:07 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