Results 1 to 2 of 2
  1. #1
    AlexTheGr8 is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Feb 2019
    Location
    Ontario
    Posts
    11

    Question Multiple independent criteria across one record?

    A bit of a weird request, I hope I can word it correctly. Basically I want a query that returns values for a row only where some parameters are met, but each one is separate from the other.

    So in my table, each record relates to an agency. And that row shows how that one agency did on several yes/no questions. If they got a 'no' on question 1, then I want the query to return both the field that says 'no', AND the field to its right where the staff would write 'notes'. So the query essentially will provide a list to staff on only questions that the agency failed, and the notes that were given for that question.



    The issue I'm running into is that each question is separate of each other, and so when I write in my criteria to only return values where the answer is 'no', I can only do that once before it will return nothing. Only records where an agency got a 'no' on every answer will be returned because the query is being literal. I tried putting it in the 'or' section of the query design but I might be doing that wrong.

    Any thoughts or guidance? Below a segment of the SQL code, stopped after 2 questions because it's a massive query (but repetitive).

    SELECT OperationalReviews.Provider, OperationalReviews.OpReviewYear, OperationalReviews.OpReviewStarted, OperationalReviews.OpReviewClosed, OperationalReviews.OpQ1YesNo, OperationalReviews.OpQ1MinutesDate, OperationalReviews.OpQ1Comments, OperationalReviews.OpQ1ActionTaken, OperationalReviews.OpQ1DateClosed, OperationalReviews.OpQ2YesNo, OperationalReviews.OpQ2Comments, OperationalReviews.OpQ2MeetingDate1, OperationalReviews.OpQ2MeetingDate2, OperationalReviews.OpQ2MeetingDate3, OperationalReviews.OpQ2MeetingDate4, OperationalReviews.OpQ2ActionTaken, OperationalReviews.OpQ2DateClosed, OperationalReviews.OpQ3YesNo, OperationalReviews.OpQ3Comments, OperationalReviews.OpQ3ActionTaken, OperationalReviews.OpQ3DateClosed, OperationalReviews.OpQ4YesNo1, OperationalReviews.OpQ4YesNo2, OperationalReviews.OpQ4Comments, OperationalReviews.OpQ4ActionTaken, OperationalReviews.OpQ4DateClosed, OperationalReviews.OpQ5YesNo, OperationalReviews.OpQ5YesNo2, OperationalReviews.OpQ5Comments, OperationalReviews.OpQ5ActionTaken, OperationalReviews.OpQ5DateClosed, OperationalReviews.OpQ6YesNo, OperationalReviews.OpQ6YesNo2, OperationalReviews.OpQ6Comments, OperationalReviews.OpQ6ActionTaken, OperationalReviews.OpQ6DateClosed
    FROM OperationalReviews
    WHERE ((Not (OperationalReviews.OpQ1YesNo)="Yes - Pass"));



    Thanks!
    A

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Query cannot dynamically select/exclude fields - a field is either in query or it isn't for all records.

    Probably need to normalize data structure. Each question response should be a record, not multiple sets of similar name fields.

    A UNION query can rearrange fields to records. There is a limit of 50 SELECT in a UNION. There is no designer for UNION, must type or copy/paste in SQLView of query builder.
    Code:
    SELECT Provider, OpReviewYear, 1 AS QID, "question1" AS Question, OpQ1YesNo AS Response, OpQ1Comments AS Comments FROM OperationalReviews
    UNION SELECT Provider, OpReviewYear, 2, "question2", OpQ2YesNo, OpQ2Comments FROM OperationalReviews
    ...
    UNION SELECT Provider, OpReviewYear, 50, "question50", OpQ50YesNo, OpQ50Comments FROM OperationalReviews;
    Include whatever other fields you want. Put whatever you want between quote marks for each question description. Use that query like a table (except can't edit data) as source for subsequent queries.

    SELECT * FROM qryUNION WHERE NOT Response = "Yes - Pass";

    I am guessing you don't have 50 questions because table would not have enough fields since each response set appears to have at least 5 associated fields.
    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: 14
    Last Post: 03-21-2017, 07:00 AM
  2. Totals Query - Independent criteria
    By scampbell in forum Queries
    Replies: 2
    Last Post: 11-14-2013, 03:25 PM
  3. Replies: 1
    Last Post: 07-03-2013, 10:39 AM
  4. Replies: 1
    Last Post: 06-12-2011, 07:08 AM
  5. Find existing record with multiple criteria
    By TheWedgie in forum Forms
    Replies: 1
    Last Post: 03-25-2009, 10:24 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