Results 1 to 6 of 6
  1. #1
    hellfire45 is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    Mar 2015
    Posts
    24

    Trouble with CASE Statement Syntax

    Microsoft Access doesn't like this CASE statement syntax. It is fitted for SQL Server but I'm not quite sure how to modify it to fit in Access. Can anybody lend a hand? Thank you!



    Code:
    SELECT dbo_FCLIT.EntityID as 'File#', dbo_FCLIT.GroupNumNum as 'Numer of Actions', dbo_FCLIT.ActionType as 'Action Type', dbo_FCLIT.StartAction as 'Action StartDate', dbo_FCLIT.[End], dbo_Entities.Party3IDText as 'Client ID', 'Client Name' = 
    
    CASE
    WHEN dbo_Entities.Party3IDText ='245204' THEN 'SN SERVICING CORPORATION'
    WHEN dbo_Entities.Party3IDText ='327599' THEN 'STATEBRIDGE'
    ELSE 'Not Found'
    END
    
    
    FROM dbo_FCLIT
    LEFT OUTER JOIN dbo_Entities ON dbo_FCLIT.EntityNum = dbo_Entities.EntityNum
    Where (dbo_FCLIT.ActionType = 'Answer Affir Defense') AND ((dbo_Entities.Party3IDText ='245204') OR (dbo_Entities.Party3IDText = '327599'));

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Try nested IIf()

    IIf(dbo_Entities.Party3IDText ='245204', 'SN SERVICING CORPORATION', IIf(dbo_Entities.Party3IDText ='327599', 'STATEBRIDGE', 'Not Found'))
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    hellfire45 is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    Mar 2015
    Posts
    24
    Well it didn't error! But its not giving me what I want. That Calculated column is being titled "EXPR1" and its giving me nothing but zeros. Getting closer!

    Code:
    SELECT dbo_FCLIT.EntityID AS ['File#'], dbo_FCLIT.GroupNumNum AS ['Numer of Actions'], dbo_FCLIT.ActionType AS ['Action Type'], dbo_FCLIT.StartAction AS ['Action StartDate'], dbo_FCLIT.End, dbo_Entities.Party3IDText AS ['Client ID'], 'Client Name'=IIf(dbo_Entities.Party3IDText='245204','SN SERVICING CORPORATION',IIf(dbo_Entities.Party3IDText='327599','STATEBRIDGE','Not Found')) AS Expr1FROM dbo_FCLIT LEFT JOIN dbo_Entities ON dbo_FCLIT.EntityNum = dbo_Entities.EntityNum
    WHERE (((dbo_FCLIT.ActionType)='Answer Affir Defense') AND ((dbo_Entities.Party3IDText)='245204' Or (dbo_Entities.Party3IDText)='327599'));

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I think you have 'Client Name' in the wrong place. Try:
    Code:
    SELECT dbo_FCLIT.EntityID AS ['File#'], 
    dbo_FCLIT.GroupNumNum AS ['Numer of Actions'], 
    dbo_FCLIT.ActionType AS ['Action Type'], 
    dbo_FCLIT.StartAction AS ['Action StartDate'], 
    dbo_FCLIT.End, 
    dbo_Entities.Party3IDText AS ['Client ID'], 
    IIf(dbo_Entities.Party3IDText='245204','SN SERVICING CORPORATION',IIf(dbo_Entities.Party3IDText='327599','STATEBRIDGE','Not Found')) AS ['Client Name']
    
    FROM dbo_FCLIT LEFT JOIN dbo_Entities ON dbo_FCLIT.EntityNum = dbo_Entities.EntityNum
    
    WHERE (((dbo_FCLIT.ActionType)='Answer Affir Defense') AND ((dbo_Entities.Party3IDText)='245204' Or (dbo_Entities.Party3IDText)='327599'));

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Cannot set 'Client Name' = to anything.

    You can put whatever you want for a name in place of EXPR1. Perhaps that's what you want Client Name to be? Do not include apostrophes in the alias field names. Should not use spaces and special characters/punctuation (underscore is exception) in any naming convention.

    SELECT dbo_FCLIT.EntityID AS [FileNum], dbo_FCLIT.GroupNumNum AS [NumberOfActions], dbo_FCLIT.ActionType AS [ActionType], dbo_FCLIT.StartAction AS [ActionStartDate], dbo_FCLIT.End, dbo_Entities.Party3IDText AS [ClientID], IIf(dbo_Entities.Party3IDText='245204','SN SERVICING CORPORATION',IIf(dbo_Entities.Party3IDText='327599 ','STATEBRIDGE','Not Found')) AS ClientName FROM dbo_FCLIT LEFT JOIN dbo_Entities ON dbo_FCLIT.EntityNum = dbo_Entities.EntityNum
    WHERE (((dbo_FCLIT.ActionType)='Answer Affir Defense') AND ((dbo_Entities.Party3IDText)='245204' Or (dbo_Entities.Party3IDText)='327599'));
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    hellfire45 is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    Mar 2015
    Posts
    24
    You did it! Thanks! Very helpful indeed.

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. Should I /can I use a Select Case statement?
    By Gina Maylone in forum Access
    Replies: 1
    Last Post: 12-13-2014, 12:08 PM
  3. Case Statement
    By RussH in forum Programming
    Replies: 1
    Last Post: 08-12-2013, 02:50 PM
  4. if or case statement and how
    By Dannat in forum Queries
    Replies: 1
    Last Post: 01-31-2012, 10:35 AM
  5. Case Statement Syntax
    By allenjasonbrown@gmail.com in forum Programming
    Replies: 1
    Last Post: 11-16-2010, 07:18 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