Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    Hawkeyesv is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2021
    Posts
    11

    Query Condition


    I tried to make a criteria in access to only show entries that are not “US”. When I used “” or <> I get the following error message: Data type mismatch in criteria expression. When I looked at the table, the field is short text so I’m not sure what is going on. Thanks in advance for your help!

  2. #2
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,821
    Hi

    Use this: Not In("US")

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    dont use different dbl-quotes. use only "" (left of the ENTER key)
    then you can use <> "US"

    that slant dbl-quote is not even on the keyboard.

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    You could be using table lookup fields, so it is not "US" at all, but a numeric?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  5. #5
    Hawkeyesv is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2021
    Posts
    11
    Quote Originally Posted by mike60smart View Post
    Hi

    Use this: Not In("US")
    Unfortunately that did not work

  6. #6
    Hawkeyesv is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2021
    Posts
    11
    What you provided was what I tried- I made a typo in my post

  7. #7
    Hawkeyesv is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2021
    Posts
    11
    I originally thought that, but I have a different query that made a criteria to be "US" and it worked. So it is recognizing the field as text

  8. #8
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    Might be time to show the query sql ?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  9. #9
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,821
    Can you upload the database?

  10. #10
    Hawkeyesv is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2021
    Posts
    11
    Quote Originally Posted by Welshgasman View Post
    Might be time to show the query sql ?
    #SELECT DISTINCT [Vsl Act Team Members DT].Field15, [Vsl Act Team Members DT].Field26, [ Vsl Act Team Members DT].Field24, [Vsl Act Team Members DT].Field32, [Vsl Act Team Members DT].Field43, [Vsl Act Team Members DT].Field45, [Vsl Act Team Members DT].Field17, [Vsl Act Team Members DT].Field2, DateValue([Field4]) AS Expr1

    FROM [Vsl Act Team Members DT]

    WHERE ((([Vsl Act Team Members DT].Field33) Not In ("US")))

    ORDER BY DateValue([Field4]) DESC;

  11. #11
    Micron is online now Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    I originally thought that, but I have a different query that made a criteria to be "US" and it worked. So it is recognizing the field as text
    That query is for the same field in the same table? If not, I'm inclined to agree with the numeric idea. Try a new select query and for US field, enter a number (e.g. 2) and see if a) it allows that, and b) if it returns something.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  12. #12
    Hawkeyesv is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2021
    Posts
    11
    Quote Originally Posted by Micron View Post
    That query is for the same field in the same table? If not, I'm inclined to agree with the numeric idea. Try a new select query and for US field, enter a number (e.g. 2) and see if a) it allows that, and b) if it returns something.
    I changed the format from long to short text, and it appears to be functioning now. Thank you!

  13. #13
    Micron is online now Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    Well I appreciate the thanks but I'm confused. I don't see how what I suggested helped given what you've just reported. Plus you originally said it was short text, now you're saying you changed it from long to short
    When I looked at the table, the field is short text so I’m not sure what is going on.
    When using text criteria on a text field, it should not matter if it is short or long anyway, so there's that too.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  14. #14
    Hawkeyesv is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2021
    Posts
    11
    So it turns out it’s actually not working. The error message does not appear when I type in a number for the criteria. But in the table that feeds like the query the data type is clearly text. Why is this?

  15. #15
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,157
    I suspect you have used lookup fields in your table design.

    They can be very confusing, and are generally discouraged. http://access.mvps.org/Access/lookupfields.htm
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. IIF condition in a query
    By mismag in forum Queries
    Replies: 3
    Last Post: 03-04-2021, 04:14 PM
  2. Possible to use query is LIKE condition?
    By ctakacs in forum Access
    Replies: 3
    Last Post: 01-06-2021, 06:34 AM
  3. Query help to write a condition
    By Dgalaxy in forum Access
    Replies: 6
    Last Post: 06-03-2020, 11:34 AM
  4. Need help with condition in a query
    By NightWalker in forum Queries
    Replies: 1
    Last Post: 09-30-2016, 01:18 PM
  5. If Condition Query in Access
    By Vishan in forum Queries
    Replies: 3
    Last Post: 10-30-2012, 12:05 PM

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