Results 1 to 4 of 4
  1. #1
    Pedagogic368 is offline Novice
    Windows Vista Access 2010 32bit
    Join Date
    Jul 2012
    Posts
    2

    NOT not working to exclude text

    Hello - I have one table from which I need to exclude pharmacy's based on their store numbers. I have been trying to do this using "NOT" - However it returns NOTHING (still after several hours of trying)???




    Code:
    SELECT Sheet1.[ID], Sheet1.[PHARMACY], Sheet1.[PRODUCTNAME], Sheet1.[NDCNUM], Sheet1.[assign], Sheet1.[Carrier], Sheet1.[Last], Sheet1.[First], Sheet1.[City], Sheet1.[State]
    FROM Sheet1
    WHERE (((Sheet1.[PHARMACY]) Not Like "*04505*"));
    But if I use "Like", all the pharmacy's with the number 04505 are listed out correctly

    Code:
    SELECT Sheet1.[ID], Sheet1.[PHARMACY], Sheet1.[PRODUCTNAME], Sheet1.[NDCNUM], Sheet1.[assign], Sheet1.[Carrier], Sheet1.[Last], Sheet1.[First], Sheet1.[City], Sheet1.[State]
    FROM Sheet1
    WHERE (((Sheet1.[PHARMACY]) Like "*04505*"));
    Can someone please advise me what I should be writing to exclude pharmacy's based on store numbers. Thanks in advance.

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    It seems to be saying that every store in your "Sheet1" table has "04505" as part of the pharmacy number.
    Can you confirm that is not the case?
    Can you provide some examples of pharmacy codes that do NOT contain this number?

  3. #3
    Pedagogic368 is offline Novice
    Windows Vista Access 2010 32bit
    Join Date
    Jul 2012
    Posts
    2
    thanks for the quick reply-

    Here are some examples of Pharmacy stores that should be EXCLUDED-

    Walgreens Drug Store 4542*
    Walgreens Drug Store 04505*

    Here are some examples of Pharmacy stores that should be INCLUDED -

    Walgreens Drug Store 06270*
    Walgreens Drug Store 07179*

    This is how they are listed in one of the columns on the original sheet.

    Thanks again for your reply

  4. #4
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Do they really actually have an asterisk in the Pharmacy ID value, or are you just cutting it off for purposes of this example?

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

Similar Threads

  1. Replies: 5
    Last Post: 04-06-2012, 11:06 AM
  2. exclude field in query
    By chrisy in forum Queries
    Replies: 2
    Last Post: 10-28-2011, 09:53 AM
  3. Replies: 4
    Last Post: 10-25-2011, 10:07 PM
  4. Exclude values that appear in a certain table
    By DB2010MN26 in forum Queries
    Replies: 4
    Last Post: 09-08-2010, 02:33 PM
  5. Exclude records within same criteria
    By brooke48 in forum Queries
    Replies: 14
    Last Post: 05-15-2010, 02:15 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