Ants
Ants

Reputation: 390

Why is my SQL query not returning any records when it should be?

I have a select query with a bunch of where clauses. I tested a couple situations and they worked great! BUT tested another situation and it didn't return anything when it should have.

In access, i used the "create query" feature, I put all the same values and it returned 4 records, which is what it is expected! So, why is my query not able to find these records?

Set rstV = cdb.OpenRecordset("SELECT * FROM " & tableVName & " WHERE ValveSize IN (" & mVSize & "," & mLineSize & ") AND ValveFamily = '" & confgType & _
    "' AND CV >= " & mCV & " AND NO = 'X'")

when I remove NO = 'X' , then it finds a bunch of records (including the ones that I am looking for), but I need NO='X' so that I can specifically find those 4 records.

i have a feeling that 'X' might be causing the issue some how, but it worked in other situations. I tried looking at columns field properties and it all looks good...

please help!

Upvotes: 0

Views: 171

Answers (1)

Gustav
Gustav

Reputation: 55806

Is far as I recall, YES and NO could be values, so try using brackets around NO:

[NO] = 'X'

Upvotes: 2

Related Questions