Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 15th, 2008, 05:09 PM
Friend of Wrox
 
Join Date: Mar 2004
Location: Ottawa, , Canada.
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

Reply With Quote
  #2 (permalink)  
Old February 16th, 2008, 05:36 AM
Friend of Wrox
 
Join Date: Oct 2007
Location: , , .
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.
Reply With Quote
  #3 (permalink)  
Old February 19th, 2008, 08:47 AM
Friend of Wrox
 
Join Date: Mar 2004
Location: Ottawa, , Canada.
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'?

Reply With Quote
  #4 (permalink)  
Old February 20th, 2008, 12:00 AM
Friend of Wrox
 
Join Date: Oct 2007
Location: , , .
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.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 05:08 AM.


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