Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| 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 May 4th, 2007, 04:50 AM
Authorized User
 
Join Date: May 2007
Location: , , .
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Default Nested IIF

Is it possible to incluse multiple arguments with IIF and Or...I am trying to do it but I am getting an error which says...The expression you have entered has a function containing the wrong number of arguments....can some body let me know how to combine IIf with Or for multiple arguments....

Reply With Quote
  #2 (permalink)  
Old May 4th, 2007, 06:41 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Yes. You would have to post your code.

The format is roughly:

IFF Condition 1, If Condition 1 is True, If Condition 1 is False IFF Condition2, If Condition 2 is True, If Condition 2 is False

Example:

IIF([HireDate]<#1/1/2000#,"$500", IIF([HireDate]<#1/1/2006#,"$100","Free Lunch"))

Did any of that help?

mmcdonal
Reply With Quote
  #3 (permalink)  
Old May 4th, 2007, 08:42 AM
Authorized User
 
Join Date: May 2007
Location: , , .
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry here is the Query...

MonthNew: IIf([Calendar]![Month] ="January", "Q1","February","Q1","March","Q1",
IIf([Calendar]![Month]="April","Q2","May","Q2","June","Q2",
IIf([Calendar]![Month] ="July","Q3","August","Q3","September","Q3",
IIf([Calendar]![Month] ="October","Q4","November","Q4","December","Q4"))) )

but this is not working....The error says there are too many arguments...Also there is no False value...

Reply With Quote
  #4 (permalink)  
Old May 4th, 2007, 08:49 AM
Friend of Wrox
Points: 4,007, Level: 26
Points: 4,007, Level: 26 Points: 4,007, Level: 26 Points: 4,007, Level: 26
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Lansing, Michigan, USA.
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Ah, IIF works with True/False pairs, it doesn't work the same as a SELECT CASE statment in VBA code. Also, don't name the field MONTH. MONTH is a function that returns the month of a given date. It may cause the computer to glitch.

You need something like (using MonthQtr instead of Month):

MonthNew: Iif(Month([Calendar].[MonthQtr]) > 10, "Q4", Iif(Month([Calendar].[MonthQtr]) > 7, "Q3", Iif(Month([Calendar].[MonthQtr]) > 4, "Q2", "Q1")))


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
Reply With Quote
  #5 (permalink)  
Old May 4th, 2007, 08:50 AM
Friend of Wrox
Points: 4,007, Level: 26
Points: 4,007, Level: 26 Points: 4,007, Level: 26 Points: 4,007, Level: 26
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Lansing, Michigan, USA.
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Oops... I meant

MonthNew: Iif(Month([Calendar].[MonthQtr]) > 9, "Q4", Iif(Month([Calendar].[MonthQtr]) > 6, "Q3", Iif(Month([Calendar].[MonthQtr]) > 3, "Q2", "Q1")))


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
Reply With Quote
  #6 (permalink)  
Old May 4th, 2007, 09:29 AM
Authorized User
 
Join Date: May 2007
Location: , , .
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Greg!!!

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
Mulitiple/Nested IIF statements rohit_ghosh Access VBA 3 June 1st, 2007 10:44 AM
Logic builiding with Nested/Multiple IIF rohit_ghosh Access 4 May 4th, 2007 09:52 AM
Nested IIF Statement Help Needed Corey Access 4 November 17th, 2005 10:19 AM
Nested Query with an iif statment Corey Access 7 October 17th, 2005 04:40 PM
Nested Query with an iif statment part 2 Corey Access 1 October 17th, 2005 12:47 PM



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


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