Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Query in Access ODBC Call failed

Status
Not open for further replies.

nflutter

Technical User
Aug 7, 2005
34
GB
I`m trying to write a query in access using the query builder but I am getting an ODBC error message when I try to run it. The SQL behind the query is:

SELECT AUDIT_HEADER.ACCOUNT_REF, AUDIT_HEADER.DETAILS
FROM AUDIT_HEADER
WHERE (((AUDIT_HEADER.DETAILS) Not Like "*deleted*"));

I can run all other types of queries to the same DB and they work fine, the problem is when I try to run a 'Not Like' filter. Am I writing the query correctly?
 
Thanks for quick response. Tried all variations but with no joy. I have made a new query just using NOT and I get the same problem, the SQL is:

SELECT AUDIT_HEADER.ACCOUNT_REF, AUDIT_HEADER.DETAILS
FROM AUDIT_HEADER
WHERE ((Not (AUDIT_HEADER.DETAILS)='deleted'));

I cant see anything wrong with this but it still returns ODBC call failed. If I do the same statement with = instead of NOT it works fine, the error only occurs when I use the NOT statement. Maybe the ODBC driver is the problem?
Any comments appreciated.
 
And this?
Code:
SELECT ACCOUNT_REF, DETAILS

FROM AUDIT_HEADER

WHERE DETAILS <> 'deleted'
 
Still the same error message, I entered <> "deleted" into the Access query builder and also copy & pasted the satement you supplied int the SQL view but both returned the error. I am starting to think the ODBC driver for my DB just wont accept a not statement, weird though it sounds.
 
Possible I suppose. Try a work-around
Code:
SELECT ACCOUNT_REF, DETAILS

FROM AUDIT_HEADER

WHERE DETAILS < 'deleted' OR DETAILS > 'deleted'
 
Half way there!, this works great if I want to exclude entries with only the word 'deleted' but my original statement was NOT LIKE, the workaround cant filter these entries.
Thanks for your help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top