Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

#Error with MonthName within IIF clause

Status
Not open for further replies.

SWTpaul

Technical User
Nov 11, 2003
27
US
I am a little baffled with this error... here is my code:

Code:
=IIF(
Month(Now)+7 > 12,
MonthName(Month(Now)+7-12),
MonthName(Month(Now)+7)
)

If I change it to...

Code:
=IIF(
Month(Now)+7 > 12,
MonthName(Month(Now)+7-12),
Month(Now)+7
)

... it will return the month name if the condition is true, but obviously an integer value if it is not.

Why is using MonthName in the True and False clauses causing an #Error?

The actual error output is:
[rsRuntimeErrorInExpression] The Value expression for the textbox ‘textbox4’ contains an error: Argument 'Month' is not a valid value.
 
What values do Month(Now) and Month(Now) + 7 return?



Catadmin - MCDBA, MCSA
"No, no. Yes. No, I tried that. Yes, both ways. No, I don't know. No again. Are there any more questions?"
-- Xena, "Been There, Done That"
 
Month(Now) would return 11 for the current month of November.

I am using Month(Now) + <#> because I am using a report format that starts with the current month (currently November), and then lists the next 11 months.

The 4th column would be Month(Now) + 4, returning 15. The IFF clause would change that to 3. MonthName should change that to March.
 
It might be a syntax thing. The Expressions box uses some VBA/Visual Basic .Net mash of terms that doesn't quite make sense to me. Though, I don't know why it would work one way and not the other way....

Is the field pulling into that textbox actually returning an integar value and not a character value?



Catadmin - MCDBA, MCSA
"No, no. Yes. No, I tried that. Yes, both ways. No, I don't know. No again. Are there any more questions?"
-- Xena, "Been There, Done That"
 
Did you manage to get a workaround for this? I am struggling with the exact same thing, when using iif or switch to return the MonthName.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top