Results 1 to 6 of 6
  1. #1
    jj1 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2014
    Posts
    128

    Query Not Populating multiple results

    I am using the query below


    What I am trying to do is get 4 combinations



    1) Department + source of Tag+ specific Date
    2) Department + Specific Date
    3) Source of Tag + Specific Date
    4) All records


    This query is meeting my 2nd and 3rd condition however if I delete the paramters for 2nd and 3rd 1st combination works fine. But I want all four conditions met in one query



    SELECT [Unsafe Act Unsafe Condition].*, [Unsafe Act Unsafe Condition].Department, [Unsafe Act Unsafe Condition].Date, [Unsafe Act Unsafe Condition].[Source Of Tag], [Unsafe Act Unsafe Condition].[Close Date]
    FROM [Unsafe Act Unsafe Condition]
    WHERE ((([Unsafe Act Unsafe Condition].Department)=[Forms]![frmHighLevelReport]![cboDepartment]) AND (([Unsafe Act Unsafe Condition].Date) Between [Forms]![frmHighLevelReport]![cboStartDate] And [Forms]![frmHighLevelReport]![cboEndDate] Or ([Unsafe Act Unsafe Condition].Date) Between [Forms]![frmHighLevelReport]![cboStartDate] And [Forms]![frmHighLevelReport]![cboEndDate]) AND (([Unsafe Act Unsafe Condition].[Source Of Tag])=[Forms]![frmHighLevelReport]![cboSourceOfTag])) OR ((([Unsafe Act Unsafe Condition].Department)=[Forms]![frmHighLevelReport]![cboDepartment]) AND (([Unsafe Act Unsafe Condition].Date) Between [Forms]![frmHighLevelReport]![cboStartDate] And [Forms]![frmHighLevelReport]![cboEndDate] Or ([Unsafe Act Unsafe Condition].Date) Between [Forms]![frmHighLevelReport]![cboStartDate] And [Forms]![frmHighLevelReport]![cboEndDate])) OR ((([Unsafe Act Unsafe Condition].Date) Between [Forms]![frmHighLevelReport]![cboStartDate] And [Forms]![frmHighLevelReport]![cboEndDate] Or ([Unsafe Act Unsafe Condition].Date) Between [Forms]![frmHighLevelReport]![cboStartDate] And [Forms]![frmHighLevelReport]![cboEndDate]) AND (([Unsafe Act Unsafe Condition].[Source Of Tag])=[Forms]![frmHighLevelReport]![cboSourceOfTag]));

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    answered on other board.

    Your WHERE may be wrong
    In the access qry design, if each date range is for separate fields, then they must be on different lines of the criteria.
    dept + TAG + DATE on 1 line
    dept + date on line 2
    ...
    It will look like a stair step

    Click image for larger version. 

Name:	OR.png 
Views:	9 
Size:	5.8 KB 
ID:	18391

  3. #3
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    If you want all 4 conditions met in a single query, then why bother with a WHERE clause at all, given that condition 4 is "All Records"?

    Am I missing somethig here?

  4. #4
    jj1 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2014
    Posts
    128
    Its not working. It's not giving me results I want.

    As I mentioned I want 4 combinations through one query

    1) Department + source of Tag+ specific Date
    2) Department + Specific Date
    3) Source of Tag + Specific Date
    4) All records



    The step layout is giving me all records not specific criteria's I want.

  5. #5
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    I *think* the where clause you posted is correct for your first three conditions.

    But I still don't understand why you say you want "...4 combinations through one query..." when one of the conditions is "All records". Are you saying you want to be able to select which condition of the 4 you want? If so, you need 4 separate queries.

    Your where clause above is for conditions 1 - 3; if it is giving you all records, then it is probably because every record satisfies at least one of those conditions.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    If you are getting all records then that means each record meets at least one of the criteria.

    I'm with John_G, what you want makes no sense.
    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. Replies: 5
    Last Post: 05-21-2013, 02:21 PM
  2. Replies: 4
    Last Post: 07-10-2012, 01:51 PM
  3. Replies: 1
    Last Post: 02-04-2012, 02:07 AM
  4. Replies: 4
    Last Post: 09-30-2011, 10:09 PM
  5. Multiple Query Results Sorted Together
    By Rawb in forum Reports
    Replies: 1
    Last Post: 12-10-2009, 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