Results 1 to 3 of 3
  1. #1
    prs312 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Aug 2014
    Posts
    11

    Query Criteria Problem: Include all of [Field-A] where one of [Field-B] (for [Field-A]) = "Criteria"

    I'm having an issue specifying the correct criteria to filter my query. The criteria is based on two fields:
    [Field-A] = SubjectID
    [Field-B] = PhaseName

    Subjects advance through Phases in the following order:
    "Screening">"Post-Implant">"Optimization">"Randomized Testing">"Follow-up"

    I'm trying to only include data in the query of subjects who have at least reached the "Optimization" phase. However, if they have data from later phases I want to include that too. Attached is an example of what this query currently looks like, and boxed in red are the only parts I would like to maintain. I greatly appreciate any help with this problem.



    Click image for larger version. 

Name:	FilterCritereaExample.jpg 
Views:	7 
Size:	170.7 KB 
ID:	22009

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    So you want all the records for each SubjectID that have reached the Optimization phase. There will always be an Optimization before there can be "Randomized Testing" and "Follow-up"?

    SELECT * FROM tablename WHERE SubjectID IN (SELECT SubjectID FROM tablename WHERE PhaseName = "Optimization");

    If you want to be able to sort by the phase sequence, need to assign an alpha or number value to each phase (or a date value could be used to sort, unless phases could occur in same day). So in query calculate a field with:

    Switch([PhaseName="Screening",1 , [PhaseName]="Post-Implant",2, [PhaseName]="Optimization",3, [PhaseName]="Randomized Testing",4, [PhaseName]="Follow-up",5)

    Alternatively, have a table of these phase names with a field for the order value. Include that table in query.
    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.

  3. #3
    prs312 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Aug 2014
    Posts
    11
    Yes. And your suggestion did just that. Thanks very much June!

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

Similar Threads

  1. Replies: 5
    Last Post: 11-23-2014, 03:54 PM
  2. Replies: 3
    Last Post: 07-16-2013, 02:28 PM
  3. Replies: 3
    Last Post: 04-22-2013, 06:08 AM
  4. Replies: 1
    Last Post: 03-03-2012, 10:17 PM
  5. Criteria field in query set to "no selection"
    By 4thangel in forum Access
    Replies: 2
    Last Post: 06-24-2011, 12:43 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