Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 15th, 2008, 05:09 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 139
Thanks: 0
Thanked 0 Times in 0 Posts
Default update with case

Hi,

trying to do an update with a case statement... but I can't seem to get the syntax right... when I try the following in Access, I get the error: 'Syntax error (missing operator) in query expression 'CASE WHEN (OrderType = 'NEW') THEN "Slippage" ELSE "Churn" END'


Query:
UPDATE testTable SET CostSplit = CASE
  WHEN (OrderType = 'NEW') THEN "Slippage"
  ELSE "Churn"
END

 
Old February 16th, 2008, 05:36 AM
Friend of Wrox
 
Join Date: Oct 2007
Posts: 130
Thanks: 0
Thanked 3 Times in 3 Posts
Send a message via AIM to urtrivedi
Default


UPDATE testTable SET CostSplit = iif(OrderType = "NEW","Slippage","Churn")

I think in access CASE Is not available, so use IIF function.


urt

Help yourself by helping someone.
 
Old February 19th, 2008, 08:47 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 139
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you for the IIF syntax... but what happens if I need to check more than 1 thing? How do you add more if's? LIke if a AND b AND c = 'option1' ELSE = 'option2'?

 
Old February 20th, 2008, 12:00 AM
Friend of Wrox
 
Join Date: Oct 2007
Posts: 130
Thanks: 0
Thanked 3 Times in 3 Posts
Send a message via AIM to urtrivedi
Default

UPDATE testTable SET CostSplit = iif(OrderType = "NEW" and somefield="somevalue","Slippage","Churn")

urt

Help yourself by helping someone.





Similar Threads
Thread Thread Starter Forum Replies Last Post
update multiple column based on case statement?? vinod_yadav1919 SQL Server 2000 6 July 3rd, 2008 07:29 PM
multiple column update query with Case vinod_yadav1919 SQL Language 4 July 3rd, 2008 06:53 PM
search string either Upper case or lower case rylemer Beginning VB 6 3 March 24th, 2004 04:23 PM
Check Case in a Case-Insensitive DB nbryson SQL Language 1 January 23rd, 2004 07:36 AM
UPDATE trigger won't fire on CASE-only condition _Katka_ SQL Server 2000 1 November 14th, 2003 11:59 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.