Results 1 to 2 of 2
  1. #1
    cykchanaa is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2015
    Posts
    4

    How to modify query criteria for ranges?

    I currently have a query that references controls from my "Main" form using the criteria below.



    Between [Forms]![Main]![Minarea].[Value] And [Forms]![Main]![Maxarea].[Value] Or [Forms]![Main]![Minarea].[Value] Is Null Or [Forms]![Main]![Maxarea].[Value] Is Null

    I would like to make this criteria work even if I leave one of the boxes empty. For example if Minarea is 10 then I would get all the results greater than 10 even if Maxarea was left empty and vice versa. Currently the query requires both boxes to be filled to run.

    Thanks in advance.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Can assign an alternate parameter that the data cannot possibly be outside of.

    Between Nz([Forms]![Main]![Minarea],0) AND Nz([Forms]![Main]![Maxarea],99999)

    However, I never use dynamic parameterized queries. I prefer: http://www.allenbrowne.com/ser-62.html
    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.

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

Similar Threads

  1. query lots of different ranges
    By freddie in forum Database Design
    Replies: 5
    Last Post: 10-10-2014, 10:14 AM
  2. Date Between Ranges for SQL Query
    By BigSloppyJoes2000 in forum Queries
    Replies: 7
    Last Post: 02-13-2014, 05:09 PM
  3. Query by date for multiple ranges
    By Xarkath in forum Queries
    Replies: 2
    Last Post: 06-11-2013, 01:47 PM
  4. Modify a query
    By saray in forum Queries
    Replies: 2
    Last Post: 06-08-2013, 02:05 PM
  5. Replies: 2
    Last Post: 07-19-2012, 06:23 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