Problem with IIF statement

  • Thread starter TonyWilliams via AccessMonster.com
  • Start date
T

TonyWilliams via AccessMonster.com

I have a report that is produced in June and December, as signified by the
value of a control txtmonth. I want to create an IIF statement so that if the
txtmonth is June the label says
"New deals in 6 months ended [txtmonth]" but if the report is printed in
December the label says
"New deals in Year([txtmonth])"

I had created this IIF statement but it doesn't pick up the fact that it
includes controls:
=IIf(Month([txtmonth])=12,"New deals in Year([txtmonth])","New deals in 6
months ended [txtmonth]")
I think it assumes that all the text in between the quotes is text and not a
field.
Can anyone help?
Thanks
Tony
 
M

Marshall Barton

TonyWilliams said:
I have a report that is produced in June and December, as signified by the
value of a control txtmonth. I want to create an IIF statement so that if the
txtmonth is June the label says
"New deals in 6 months ended [txtmonth]" but if the report is printed in
December the label says
"New deals in Year([txtmonth])"

I had created this IIF statement but it doesn't pick up the fact that it
includes controls:
=IIf(Month([txtmonth])=12,"New deals in Year([txtmonth])","New deals in 6
months ended [txtmonth]")
I think it assumes that all the text in between the quotes is text and not a
field.


=IIf(Month(txtmonth)=12,"New deals in " & Year(txtmonth),
"New deals in 6 months ended " & txtmonth)
 
A

Al Campagna

Tony,
Marshall's right... I misunderstood the Year(txtMonth) on the True part.
Thought Year was part of the text...
Al

Al Campagna said:
Tony,
Try...
=IIf(Month([txtmonth])=12,"New deals in Year " & [txtmonth],"New deals in
6
months ended " & [txtmonth])
--
hth
Al Campagna
Microsoft Access MVP 2007-2009
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."

TonyWilliams via AccessMonster.com said:
I have a report that is produced in June and December, as signified by the
value of a control txtmonth. I want to create an IIF statement so that if
the
txtmonth is June the label says
"New deals in 6 months ended [txtmonth]" but if the report is printed in
December the label says
"New deals in Year([txtmonth])"

I had created this IIF statement but it doesn't pick up the fact that it
includes controls:
=IIf(Month([txtmonth])=12,"New deals in Year([txtmonth])","New deals in 6
months ended [txtmonth]")
I think it assumes that all the text in between the quotes is text and
not a
field.
Can anyone help?
Thanks
Tony
 
D

Daryl S

Tony -

You are right. You need to move the calculation of the year or display of
the month outside of the quotes, and then append them to the quoted text.
Here you go:

=IIf(Month([txtmonth])=12,"New deals in " & Year([txtmonth]),"New deals in 6
months ended " & [txtmonth])
 
T

TonyWilliams via AccessMonster.com

Thanks to all three of you worked just fine!
Tony
I have a report that is produced in June and December, as signified by the
value of a control txtmonth. I want to create an IIF statement so that if the
txtmonth is June the label says
"New deals in 6 months ended [txtmonth]" but if the report is printed in
December the label says
"New deals in Year([txtmonth])"

I had created this IIF statement but it doesn't pick up the fact that it
includes controls:
=IIf(Month([txtmonth])=12,"New deals in Year([txtmonth])","New deals in 6
months ended [txtmonth]")
I think it assumes that all the text in between the quotes is text and not a
field.
Can anyone help?
Thanks
Tony
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top