Results 1 to 15 of 15
  1. #1
    aboondocksaint2 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    19

    Help with query criteria

    So I am trying to exclude search results from people in "IL" for a homework assignment. I am positive that typed "IL" right in the fields that its supposed to be in.Click image for larger version. 

Name:	Problem with criteria.PNG 
Views:	11 
Size:	28.9 KB 
ID:	16277 That is what I have for the query. This is what I get when I run it. The date part is working right. Click image for larger version. 

Name:	problem 2.PNG 
Views:	11 
Size:	11.8 KB 
ID:	16278

  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,652
    Since you have the 2 criteria on different lines, you get an "OR" comparison. The records returned meet the other criteria, so are returned. Sounds like you want the criteria on the same line, which gets you an "AND" comparison.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Because you have the Date criteria on a separate Criteria row, it is treated as an OR condition, that is return records where:
    Either:
    -The state code is not "IL"
    OR
    -The start date is prior to 7/1/213

    That means if EITHER of those two conditions are met, the record will be returned.

    If you want an AND condition, where you only want records to be returned where BOTH those conditions are met, you must put both those Criteria on the same criteria row.


    EDIT: Sorry, I got interrupted on a phone call while typing up my response did not see Paul already replied.

  4. #4
    aboondocksaint2 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    19
    I do want the or conditions that I am sure of because the next part of the assignment is to build one with an and condition. If I am reading that stuff right then with those conditions I should not see anything from "IL" right?

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    No, you'll still see records from IL if the date is less than 7/1/13. Read JoeM's explanation. If you had an NV record that was after 7/1/13, it would also be returned. It fails the date criteria but passes the <>IL criteria. Or means it only has to pass one or the other, not both.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    aboondocksaint2 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    19
    Oh ok I am starting to get it now. But I need to get to work so I will have to play with it some more later. Thanks for all your help guys.

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    No problem, and welcome to the site by the way!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    aboondocksaint2 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    19
    Thanks!!!!! So a little update when I had imported some data that it needed it didn't import all of it. That problem is now solved. So I deleted my queries to rebuild them. Now I have another problem. I built my query and now it doesn't show ANY data. I am really new to MS access so I am probably missing something obvious but here is what I have.Click image for larger version. 

Name:	Capture5.jpg 
Views:	5 
Size:	79.0 KB 
ID:	16285Click image for larger version. 

Name:	Capture6.jpg 
Views:	5 
Size:	70.1 KB 
ID:	16286Click image for larger version. 

Name:	Capture7.jpg 
Views:	5 
Size:	100.8 KB 
ID:	16287

  9. #9
    aboondocksaint2 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    19
    This is the exact text in my textbook "Create a query that displays the GuestLast, City, State/Prov, ReservationID, StartDate, and EndDate fields for all guest from Illinois (IL). Do not include the State/Prov field in the query results. Sort the gquery in ascending order by cidy. Save the query and IllinoisGuests and then run it.

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    One of the joins doesn't look right.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  11. #11
    aboondocksaint2 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    19
    How do I change that?

  12. #12
    aboondocksaint2 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    19
    Got it!!!!! Also all the criteria is showing good thanks for all your help guys!!!!!!!

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

  14. #14
    aboondocksaint2 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    19
    Got another question about Calculated fields should I just make a new thread or ask in this one?

  15. #15
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Got another question about Calculated fields should I just make a new thread or ask in this one?
    A brand new question that is not dependent on the previous question should go in a new thread, so it shows up as a new question.
    Otherwise, most everyone who has not already replied to this thread won't see it as a new question.

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

Similar Threads

  1. Replies: 4
    Last Post: 05-02-2013, 11:07 AM
  2. Replies: 5
    Last Post: 05-01-2013, 11:39 AM
  3. Replies: 5
    Last Post: 09-20-2012, 03:27 PM
  4. Replies: 5
    Last Post: 08-02-2012, 09:44 AM
  5. Replies: 1
    Last Post: 07-13-2011, 11:00 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