Results 1 to 3 of 3
  1. #1
    rmayur is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jan 2015
    Location
    Mumbai
    Posts
    20

    Exclamation How to write query in access using NOT IN

    selectqry = "SELECT RP.* FROM Partners AS P, Redemption_report AS RP " & _
    "WHERE P.partner_name = RP.redemption_partner And type ='Standard' and " & _
    "RP.order_description not like '*_Stay*' and P.partner_name = 'Demo Units' and " & _
    "RP.country_name NOT IN ("Israel", "Turkey", "Serbia", "South Africa")"



    Here in place of Israel compile error coming "End of statement" ..
    Plz any one can help me how to make it correct

  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,632
    This expression really should be in a JOIN clause: P.partner_name = RP.redemption_partner

    However, names are very poor key fields.

    Use apostrophes as delimiters for the text parameters or double the quote marks.

    "RP.country_name NOT IN ('Israel', 'Turkey', 'Serbia, 'South Africa')"

    "RP.country_name NOT IN (""Israel"", ""Turkey"", ""Serbia"", ""South Africa"")"
    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
    rmayur is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jan 2015
    Location
    Mumbai
    Posts
    20
    Thanks...

    I write these way and it's get executed

    selectqry = "SELECT RP.* FROM Partners AS P, Redemption_report AS RP " & _
    "WHERE P.partner_name = RP.redemption_partner And type ='Standard' and " & _
    "RP.order_description not like '*_Stay*' and P.partner_name = 'Demo Units' and " & _
    "(RP.country_name NOT IN(" & Chr(34) & "Israel" & Chr(34) & "," & Chr(34) & "Turkey" & Chr(34) & "," & Chr(34) & "Serbia" & Chr(34) & "," & Chr(34) & "South Africa" & Chr(34) & "))"

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

Similar Threads

  1. Write conflict - Access 2003
    By mafrank101 in forum Access
    Replies: 7
    Last Post: 10-10-2012, 07:44 PM
  2. Help to write query?
    By mlandis in forum Queries
    Replies: 4
    Last Post: 02-17-2012, 09:42 AM
  3. How Do I Write This Query?
    By TxTcher in forum Forms
    Replies: 8
    Last Post: 08-13-2010, 01:50 PM
  4. How would I write this query?
    By tigers in forum Queries
    Replies: 1
    Last Post: 02-08-2010, 08:29 AM
  5. write a query how to???
    By flamingo in forum Queries
    Replies: 0
    Last Post: 01-13-2009, 03:57 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