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!

MSAccess ODBC

Status
Not open for further replies.

tonyweis138

Programmer
Jul 27, 2007
8
US
I am writing trying to access data in an Access database via a Delphi 7 program. I have a DSN setup using the Microsoft Access driver which i am using to connect to the Access database.

I am attempting to use a query like the following and it keeps giving me read access errors. It has to do with the case statement (i have tried rewriting it etc.) because if i take it out it works fine. Any ideas

select *, case when codamount > 100 then 'high' else 'low' end as CODTYPE from UPS_MAIN_EXPORT_COPY_TBL where SalesOrderNo = user input
 
case when codamount > 100 then 'high' else 'low' end

Not completely certain, but while this will work with T-SQL, it may not be Jet SQL compliant. You may want to take a look in Access help, and see if you can code an Immediate If (IIf) statement.

"Don't be irreplaceable. If you can't be replaced, you can't be promoted."
 
I tried using iif and it still gives me an access violation when i try to run the query in Delphi.
 
Haha, i'm a doofus. I had IFF in my brain for if and only if and kept using that instead of iif.

Also, because i was using version 12 of the Microsoft Access Driver, i don't think the BDE was able to interpret the error messages correctly so it was just giving me read access violations instead of useful info.

Thanks for the help.
 
Code:
select *, IIf([codamount] > 100,"high","low")  as CODTYPE from UPS_MAIN_EXPORT_COPY_TBL.....

Works fine for me in Access. [cheers]

"Don't be irreplaceable. If you can't be replaced, you can't be promoted."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top