 |
| 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
|
|
|
|

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

May 4th, 2007, 06:41 AM
|
|
Friend of Wrox
|
|
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
|
|
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
|
|

May 4th, 2007, 08:42 AM
|
|
Authorized User
|
|
Join Date: May 2007
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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...
|
|

May 4th, 2007, 08:49 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
|
|
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
|
|

May 4th, 2007, 08:50 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
|
|
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
|
|

May 4th, 2007, 09:29 AM
|
|
Authorized User
|
|
Join Date: May 2007
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks Greg!!!
|
|
 |