Results 1 to 6 of 6
  1. #1
    Grave is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Aug 2012
    Location
    Osan AB, South Korea
    Posts
    7

    Filtering a Query with One Criteria over Multiple Fields

    Hi,

    I have a database that tracks various inspection due dates on industrial support equipment. Each piece of equipment has several different inspection cycles (180-day, 365-day, 720-day, etc). Basically what I'm trying to create is a report that will show equipment that is due any of their inspections, that fall under a user-defined date range.



    For example, my query looks something like this:

    EQUIPMENT ID 180-DAY INSPECTION 365-DAY INSPECTION 720-DAY INSPECTION
    G1137 29-DEC-12 25-JAN-13 15-JAN-14
    G1140 29-DEC-12 27-OCT-12 04-SEP-12
    G1141 08-AUG-12 21-AUG-12 09-AUG-12

    What I want to do is have the user click on a button to open up a new form. Then, the user will enter in a START DATE and END DATE, and click another button to initiate the query. What I want the query to do is look at ALL the different inspections, and if ANY of the inspection dates for that particular piece of equipment falls within the specified date range, I want that particular piece of equipment (along with all it's inspection dates) to display.

    I can get the query set up to do this for one Field at a time, but not multiple ones simultaneously. Any help would be greatly appreciated!

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    Add the same criteria to all the fields, but each on a different line. In SQL view, that makes it OR instead of AND.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,967
    Did you try OR operator? The criteria goes under each field, but on different Criteria lines in the query design grid. Criteria: BETWEEN Forms!formname!StartDate AND Forms!formname!EndDate.
    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.

  4. #4
    Grave is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Aug 2012
    Location
    Osan AB, South Korea
    Posts
    7
    Quote Originally Posted by pbaldy View Post
    Add the same criteria to all the fields, but each on a different line. In SQL view, that makes it OR instead of AND.
    That did the trick, thanks!

    Quote Originally Posted by June7 View Post
    Did you try OR operator? The criteria goes under each field, but on different Criteria lines in the query design grid. Criteria: BETWEEN Forms!formname!StartDate AND Forms!formname!EndDate.
    I did try the OR operator, however, what I did wrong was put the same criteria on the same line all the way across. Putting them on a different OR line did the trick.

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    No problemo!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    Grave is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Aug 2012
    Location
    Osan AB, South Korea
    Posts
    7
    Ok, now for Step #2 for my report:

    They way I currently have it set up: The user clicks a button, and it opens up a form. The form has a START DATE and END DATE text field. Once the user inputs the date range, they click a "submit" button, and that takes them right to the query. How do I get this into a report format? What I want to do is have the user select their date range, and when they hit the "submit" button, it generates a report based off the results shown in the query.

    When I try and create a report using the query directly, a "enter parameter value" popup shows up.

    ** EDIT **

    Disregard... I figured it out. I need to take a break now, lol!

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

Similar Threads

  1. Filtering with Criteria in SQL Query?
    By Huddle in forum Reports
    Replies: 44
    Last Post: 10-21-2013, 02:11 PM
  2. Replies: 2
    Last Post: 02-20-2012, 08:32 AM
  3. Multiple Fields in Criteria - String
    By alsoto in forum Forms
    Replies: 3
    Last Post: 08-24-2011, 12:23 PM
  4. FindFirst with multiple fields in criteria
    By compooper in forum Programming
    Replies: 5
    Last Post: 07-22-2011, 10:29 AM
  5. Replies: 1
    Last Post: 07-13-2011, 11:00 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