zgrrl
asked on
How can I add a wildcard text element to a nested IIF in text box form
Hi, this is probably simple for someone who does a lot of formulas. Here is my formulas that works great in my ms access 2007 text box.
=IIf([YrsofSvc]>=25,"25",I If([YrsofS vc]>=15,"2 0",IIf([Yr sofSvc]>=5 ,"15",IIf( [YrsofSvc] >=1,"10"," "))))
The [YrsofSvc] is returning a number so this is working fine. It is getting this number from another formula that returns the number + either Years or Months. So, some people return 2 Years, (or whatever), but others return "4 months" Here's the formula for that, if it matters:
=IIf((DateDiff("m",[Date 1],Date()))>12,(Round(Date Diff("m",[ Date 1],Date())/12)) & " " & "Years",(DateDiff("m",[Dat e 1],Date()) & " " & "months"))
So, what I am trying to do is get the first IIF statement to return "5" IF the 2nd statement is producing the word "months" . Some people have 7 years of service and that currently is resulting in a return of 15 days of vacation. However, for those that have 7 months only, NOT years, I want it to return a "5" (5 days of vacation).
So how do I get my if statement to evaluate whether it is showing months or years? I tried to do a wildcard in the IIF statement if it saw the text "months" but can't figure out how - not sure if that is right avenue.
Any help appreciated!
Diane
=IIf([YrsofSvc]>=25,"25",I
The [YrsofSvc] is returning a number so this is working fine. It is getting this number from another formula that returns the number + either Years or Months. So, some people return 2 Years, (or whatever), but others return "4 months" Here's the formula for that, if it matters:
=IIf((DateDiff("m",[Date 1],Date()))>12,(Round(Date
So, what I am trying to do is get the first IIF statement to return "5" IF the 2nd statement is producing the word "months" . Some people have 7 years of service and that currently is resulting in a return of 15 days of vacation. However, for those that have 7 months only, NOT years, I want it to return a "5" (5 days of vacation).
So how do I get my if statement to evaluate whether it is showing months or years? I tried to do a wildcard in the IIF statement if it saw the text "months" but can't figure out how - not sure if that is right avenue.
Any help appreciated!
Diane
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you!
ASKER
Doh! Why didn't I think of that? I did this and now it's working fine. For those who may be reading this, here is my final formula after I calculated for months instead of years.
=IIf([TotalMonths]>=300,"2
I did use my original formula still to show the "5 months" or "2 years" etc. But doing the months calculation is what worked for me to get the awarded vacation allotment to show properly, so thank you!.