How to get Not Like statement to work in Access

Starr N 20 Reputation points
2025-10-01T18:40:34.8833333+00:00

I'm trying to isolate typing mistakes in one column of data vs. another using the "not like" statement in an Access query but it doesn't seem to be working. For example, I have two columns of numbers and a third "total" column. If the numbers in the total column are "not like" the first two columns added together, I want it to show the rows that dont add up but it keeps giving me the opposite. Can someone help?

Microsoft 365 and Office | Access | For business | Other
{count} votes

Answer accepted by question author
  1. Tammy-Ng 5,585 Reputation points Microsoft External Staff Moderator
    2025-10-02T03:45:19.8333333+00:00

    Dear Starr N
    Welcome, and thank you for sharing your issue in the Q&A forum.

    Based on the information you provided, I understand that you're trying to isolate rows where the "Total" column does not match the sum of two other numeric columns, using the NOT LIKE statement. However, you're getting the opposite result from what you expected.

    The core issue here is the misuse of the NOT LIKE operator. This operator is designed for pattern matching in text fields, not for performing numeric comparisons. When applied to numbers, it can produce inaccurate or unexpected results.

    To compare numeric values properly, you should use the "not equal to" operator (<>) instead of NOT LIKE. Here's the correct syntax:

    [Total Column] <> ([Column1] + [Column2])
    

    Show more lines

    By replacing NOT LIKE with <> in your query criteria, Access will correctly display only the rows where the sum is incorrect.
    To ensure this solution works perfectly for your data environment, I’d appreciate it if you could provide a bit more detail:

    1. Data Types: Could you confirm whether the columns you're working with (Column1, Column2, and Total) are formatted as Number or Text in Access?
    2. Sample Data: If possible, please share a few sample rows (5–10) from these columns. This will help me test the logic and ensure the query syntax works correctly with your actual data, including any edge cases.

    Your input will be very helpful in finding the best solution for your situation. Thanks again, and I look forward to your reply!

    2 people found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.