Results 1 to 5 of 5
  1. #1
    nick404's Avatar
    nick404 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    May 2015
    Location
    Wisconsin
    Posts
    352

    Angry Not Like statement not working as expected

    Current SQL in a cbo query builder:


    Code:
    SELECT Product.Product, Product.Target
    FROM Product
    WHERE (((Product.Product) Not Like (([Product].[Product])="#5 ct CDW" And ([Product].[Product])="#5 ct HSD" 
    And ([Product].[Product])="## ct HSD (Scrubby)" And ([Product].[Product])="42 ct HSD" And ([Product].[Product])="Chassis" And ([Product].[Product]) Like "7th G*")));
    I do not want these products to appear on a combo box I have (the product name is either ambiguous or no longer run but do not want to delete and lose data connected). I am eliminating options for the user so they do not select these products that we don't use. However this SQL is not doing the trick. I still see all the options in the combo.

  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,644
    The WHERE clause makes no sense. The expression on right of Not Like will return True or False so the result of the WHERE clause is:

    WHERE Product.Product Not Like {True or False}

    Also, the AND operator requires the value of that field to meet ALL the parameters to return a True. How can that ever be possible?

    Does your value have the literal # character or are you trying to do a match on a digit in that position? I've never used # wildcard.
    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
    nick404's Avatar
    nick404 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    May 2015
    Location
    Wisconsin
    Posts
    352
    Yes matching a single digit in that position.

    Would Or work better?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,644
    Would still return a True or False which makes no sense for comparison to Product field.

    What is the reason for excluding these records as options in combobox? These products are no long available? Could this list continue to grow requiring periodic edit of the combobox RowSource? Maybe Product table needs a yes/no field Active and apply filter on this field.
    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
    nick404's Avatar
    nick404 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    May 2015
    Location
    Wisconsin
    Posts
    352
    A few products were discontinued, and there was a lot of ambiguity with others.
    For example, getting rid of '35 ct HSD' from the combo box because we want specified substrate number after. We now have 3 or 4 different '35 ct HSD' with substrate numbers after and do not want the user to just select '35 ct HSD' from the combo because they are too lazy to find the right substrate #.
    How can I arrange this so my query will not return records with those product names in it?

    I like the idea of an active field. I think I will end up doing that.

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

Similar Threads

  1. Compile error: Expected end of statement
    By ritati in forum Macros
    Replies: 1
    Last Post: 12-05-2014, 05:33 AM
  2. Expected End of Statement error
    By SamNotSoWise in forum Programming
    Replies: 5
    Last Post: 06-25-2012, 04:41 PM
  3. Add operator not working as expected
    By g4b3TehDalek in forum Queries
    Replies: 4
    Last Post: 10-05-2011, 01:09 PM
  4. Relationships not working as expected
    By Poepol in forum Access
    Replies: 1
    Last Post: 04-29-2011, 05:39 AM
  5. compile error: expected end of statement
    By RedGoneWILD in forum Programming
    Replies: 5
    Last Post: 07-29-2010, 10:12 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