Results 1 to 6 of 6
  1. #1
    turk1559 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jul 2014
    Location
    New Jersey, USA
    Posts
    4

    Unhappy Query Parameters Returning All Results

    Hi y'all. I'm trying to filter a query using multiple parameters, but I keep getting the entire unfiltered query. I want to be able to input some parameters and skip others by leaving them blank but the two potential methods I've been able to come up with result in either all results being shown or nothing being shown when I leave a parameter blank. Any ideas?
    Code:
    SELECT I.IID, I.IncidentDate, D.Shift, I.EID, EI.EmployeeName, D.DepartmentName, D.Supervisor, C.ReportCategory, I.IncidentDescription
    
    FROM ((I INNER JOIN C ON I.[CID] = C.[CID]) INNER JOIN D ON I.[DID] = D.[DID]) INNER JOIN EI ON I.[EID] = EI.[EID]
    
    
    GROUP BY I.IID, I.IncidentDate, D.Shift, I.EID, EI.EmployeeName, D.DepartmentName, D.Supervisor, C.ReportCategory, I.IncidentDescription
    
    
    HAVING ((((I.IncidentDate)=[When was the report filed?],"*") AND ((D.Shift)=[Which Shift?] OR "*") AND ((I.EID)=[Target Employee ID #] OR "*") AND ((EI.EmployeeName)=[Employee's Name? (First and Last)] OR "*") AND ((D.DepartmentName)=[Which Department?] OR "*") AND ((C.ReportCategory)=[Which Category?] OR "*"));


  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,525
    It will get messy in design view, but here's one way:

    http://access.mvps.org/access/queries/qry0001.htm

    personally I'd use a form for user input.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    turk1559 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jul 2014
    Location
    New Jersey, USA
    Posts
    4
    That sounds like the opposite of what I'm trying to do. I want to set it up so that if I only input employee ID it will give me only entries with that employee ID. If i do the ID and department, its just filtered by the id and department etc etc

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,525
    Did you try it?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    turk1559 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jul 2014
    Location
    New Jersey, USA
    Posts
    4
    Well I'll be damned it worked like a charm. Thank you!

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

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

Similar Threads

  1. Query not returning all expected results
    By amenitytrust in forum Queries
    Replies: 6
    Last Post: 11-05-2012, 07:13 AM
  2. Select Query returning no Results
    By Rhemo in forum Access
    Replies: 2
    Last Post: 09-15-2012, 04:11 AM
  3. Query returning more results than wanted
    By thedanch in forum Queries
    Replies: 4
    Last Post: 06-19-2012, 08:24 AM
  4. Query Bug? Not returning consistent results
    By trb5016 in forum Queries
    Replies: 4
    Last Post: 06-15-2010, 12:00 PM
  5. Query not returning all of the results
    By velvettiger in forum Queries
    Replies: 4
    Last Post: 03-11-2010, 06:56 AM

Tags for this Thread

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