Results 1 to 3 of 3
  1. #1
    bignate is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Aug 2013
    Posts
    47

    Question WHERE statement (between) in a query

    I use this


    'WHERE ((OperationalRiskEventTable.DateReported)>=Forms!U pdateForm!UDateBegin And (OperationalRiskEventTable.DateReported)<=Forms!Up dateForm!UDateEnd)'
    in a query by form.
    The problem is that you have to enter a date in the between values for results to show. If I don't enter information into a different field such as Full Name but I enter in 40 into Age then everyone that is 40 years old will show. On the other hand if I enter 40 into the Age field but I leave the Date Reported fields empty then no results will show.

    How can I change it so that I don't have to enter dates into the date reported fields for results to show?

    Thanks

  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
    Try Nz:

    WHERE OperationalRiskEventTable.DateReported BETWEEN Nz(Forms!UpdateForm!UDateBegin,#1/1/1900#) And Nz(Forms!UpdateForm!UDateEnd,#12/31/2900#)

    BETWEEN AND operator is inclusive for the range ends.
    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
    bignate is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Aug 2013
    Posts
    47
    Thanks June7 that was what I needed

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

Similar Threads

  1. IIF Statement in query
    By mariposanegra225 in forum Queries
    Replies: 7
    Last Post: 10-24-2012, 02:15 PM
  2. if statement in sql statement, query builder
    By 54.69.6d.20 in forum Access
    Replies: 4
    Last Post: 09-11-2012, 07:38 AM
  3. Replies: 3
    Last Post: 07-10-2012, 05:23 AM
  4. query iif statement help
    By swat in forum Queries
    Replies: 4
    Last Post: 09-30-2011, 11:48 AM
  5. Query/IiF statement
    By peacepower in forum Queries
    Replies: 1
    Last Post: 08-23-2011, 04:05 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