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

    case statement - multiple columns

    Hello Folks,

    I want to write a case statement which is conditional on a number of fields, so that if the value of any of the fields is zero then the result is FALSE.

    I am trying this;
    SELECT stuff....
    (CASE WHEN (UNIT = '0' or NUM = '0' or STREET = '0' or POBOX= '0' or SUBURB= '0'
    or POSTCODE= '0' or STATE= '0')
    THEN 'FALSE'
    ELSE 'TRUE'


    END) match,
    FROM tables...

    But I get this error;
    [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression '(CASE WHEN (UNIT = '0' or NUM = '0' or STREET = '0' or POBOX= '0' or SUBURB= '0'
    or POSTCODE= '0' or STATE= '0')
    THEN 'FALSE'
    ELSE 'TRUE'
    END) match'.

    Help!

    eddiec :-)

  2. #2
    Rod is offline Expert
    Windows Vista Access 2007
    Join Date
    Jun 2011
    Location
    Metro Manila, Philippines
    Posts
    679
    Don't do much Transact-SQL but I think the CASE statement should be:

    CASE (UNIT = '0' or NUM = '0' or STREET = '0' or POBOX= '0' or SUBURB= '0' or POSTCODE= '0' or STATE= '0')
    WHEN True
    THEN 'FALSE'
    ELSE 'TRUE'
    END

    Are you sure you're testing for string zero?

  3. #3
    Rod is offline Expert
    Windows Vista Access 2007
    Join Date
    Jun 2011
    Location
    Metro Manila, Philippines
    Posts
    679
    No on second thoughts yours should work but perhaps you should be coding:

    ...
    'Match' = CASE
    WHEN (.......)
    THEN 'FALSE'
    ELSE 'TRUE'
    END

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 or Switch in an update statement
    By allenjasonbrown@gmail.com in forum Queries
    Replies: 7
    Last Post: 11-17-2010, 01:49 AM
  3. Case Statement Syntax
    By allenjasonbrown@gmail.com in forum Programming
    Replies: 1
    Last Post: 11-16-2010, 07:18 PM
  4. Combo Box with multiple columns
    By desireemm1 in forum Access
    Replies: 1
    Last Post: 08-17-2009, 02:36 AM
  5. Multiple Price Columns
    By kmwhitt in forum Access
    Replies: 0
    Last Post: 04-04-2009, 09:48 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