×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

MSAccess ODBC

MSAccess ODBC

MSAccess ODBC

(OP)
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

RE: MSAccess ODBC

Quote:


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."
 

RE: MSAccess ODBC

(OP)
I tried using iif and it still gives me an access violation when i try to run the query in Delphi.

RE: MSAccess ODBC

(OP)
According to this:

http://support.microsoft.com/kb/321266

Neither the if(f) nor the case statements are valid. Does anyone know how to achieve the same goal using only these keywords?  

Thanks in advance.

RE: MSAccess ODBC

(OP)
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.

RE: MSAccess ODBC

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."
 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close