Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • 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!

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

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I wish I knew about this site years ago. It would have saved me a lot of heartaches..."

Geography

Where in the world do Tek-Tips members come from?
tonyweis138 (Programmer)
19 Aug 08 15:40
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
genomon (Programmer)
19 Aug 08 17:17

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

tonyweis138 (Programmer)
20 Aug 08 8:50
I tried using iif and it still gives me an access violation when i try to run the query in Delphi.
tonyweis138 (Programmer)
20 Aug 08 11:01
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.
tonyweis138 (Programmer)
20 Aug 08 12:01
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.
genomon (Programmer)
20 Aug 08 12:06

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

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!

Back To Forum

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