Results 1 to 5 of 5
  1. #1
    esh112288 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2012
    Posts
    14

    Query to list only records containing a word

    Click image for larger version. 

Name:	post.jpg 
Views:	9 
Size:	48.3 KB 
ID:	9811
    I have an image above showing my 2 tables within my query. As you can see, I have 2 fields linked back to the same table, Receiving Area and an Area where Discovered. I did this because they're both the same list of areas.



    I'm looking to display all QA records that have a "Value Stream" of Fusion from the Area table. I want it to have this "Value Stream" in either the Receiving Area OR the Area Where Discovered, not both.

    Under Area Where Discovered in my Query, I'm writing:
    Code:
     [Areas]![Value Stream] Like "Fusion"
    This is adding a new column to the Query where
    Code:
     [Areas]![Value Stream] Like "Fusion"
    Now it appears that the Query is looking for all records with a Receiving Area AND an Area Where Discovered that have both the SAME Area and Value Stream. Not just the same Value Stream.

    How can I write this query to find all QA records with a Receiving Area within Fusion Value Stream OR an Issuing Area within Fusion Value Stream?

    Thanks

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,628
    Post the entire sql statement for analysis.

    Use wildcard with LIKE operator or just use =.

    If you want OR operation then each criteria must be on separate lines of the criteria rows in the query grid.

    What do you mean by 'adding a new column'?
    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
    esh112288 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2012
    Posts
    14
    The following is the SQL for the query.

    Code:
    SELECT QA.[QA Number], QA.[QA Type], QA.[Discovered On], QA.Shift, QA.[Discovered By], QA.[Area Where Discovered], QA.[Receiving Area], QA.[Machine ID], QA.[Product Being Rejected], QA.[Date Produced], QA.[Lot Number or Cavity Number], QA.[RBS Die Number or Mold Letter], QA.[Details from Issuer], QA.[Immediate Actions Taken], QA.[Technician Addressing QA]
    
    
    FROM Areas INNER JOIN QA ON (Areas.[Area ID] = QA.[Area Where Discovered]) AND (Areas.[Area ID] = QA.[Receiving Area])
    
    
    
    
    WHERE (((QA.[Discovered On]) Between Date() & " 6:00:00" And Date()-1 & " 6:00:00" Or (QA.[Discovered On]) Between Date() & " 6:00:00" And Date()-1 & " 6:00:00") AND ([Areas]![Value Stream]="Fusion"));
    The AND statement at the end is what needs to be adjusted. Instead of Areas being Fusion, it needs to be that the Value Stream of the Receiving Area = Fusion OR the Value Stream of the Area Where Discovered = Fusion. Disregard the time/date item, that works.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,628
    Oh boy, think I understand now.

    Include Areas table in the query twice, one join on Area Where Discovered field and one join on Receiving Area. The query will show tables Areas and Areas_1.
    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.

  5. #5
    esh112288 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2012
    Posts
    14
    Yup that worked perfectly! Can't believe I didn't think of that before. Thanks

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

Similar Threads

  1. Replies: 2
    Last Post: 02-28-2012, 12:43 PM
  2. Replies: 11
    Last Post: 01-26-2012, 09:28 AM
  3. Mailmerge: Making a list - Access to word
    By Ribido in forum Access
    Replies: 3
    Last Post: 01-07-2012, 12:40 PM
  4. Import a list of names from Word to access
    By WickedGoodOutdoors in forum Import/Export Data
    Replies: 3
    Last Post: 01-04-2011, 05:25 PM
  5. Replies: 3
    Last Post: 03-25-2010, 12:31 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