Results 1 to 3 of 3
  1. #1
    krufruf is offline Novice
    Windows XP Access 2003
    Join Date
    Sep 2011
    Posts
    3

    Case when

    Hi. Hoping for some help. I'm used to doing all my querying in DB2 QMF/SQL and the language is slightly different than SQL in Access. Can anyone please tell me how to use CASE WHEN statements in Access? Below is a case statement from QMF SQL that I need to replicate in Access. ANY help would be appreciated. I tried copying this to Access SQL and it won't work. THanks!

    SELECT LAST_NAME,COUNT(DISTINCT CLAIMS) AS CLAIMCTS,
    (CASE WHEN STATE IN ('IN','OH') THEN 'CENTRAL'
    ELSE 'OTHER' END) AS REGION
    (CASE WHEN METH_CODE='T' THEN 'PHONE'
    WHEN METH_CODE='E' THEN 'EMAIL'
    ELSE 'OTHER' END) AS METH
    FROM TABLE 1


    WHERE DATE BETWEEN '2012-07-01' AND '2012-07-14'
    GROUP BY LAST_NAME,STATEK_METH_CODE

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    I believe that you can only use CASE statements in VBA in Access, not directly in the queries.
    You will either need to use something else, like Immediate IF statements (IIF), or create a User Defined Function (UDF) to use.
    Your statements look pretty basic, and you should be able to use IIF (hor help of IIF: http://www.techonthenet.com/access/f...vanced/iif.php).

  3. #3
    krufruf is offline Novice
    Windows XP Access 2003
    Join Date
    Sep 2011
    Posts
    3
    Thank you much!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. CASE STATEMENT or IF-ELSE-THEN? HELP
    By Shakenaw in forum Access
    Replies: 9
    Last Post: 06-08-2015, 11:24 AM
  2. Case Else
    By FinChase in forum Programming
    Replies: 3
    Last Post: 02-01-2012, 10:45 PM
  3. if or case statement and how
    By Dannat in forum Queries
    Replies: 1
    Last Post: 01-31-2012, 10:35 AM
  4. Print ONE particular case
    By lyndon.pace in forum Programming
    Replies: 2
    Last Post: 04-11-2011, 07:53 AM
  5. Use Case Scenarios
    By scott.weppler in forum Access
    Replies: 0
    Last Post: 05-31-2009, 12:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums