Solved

How can I add a wildcard text element to a nested IIF in text box form

Posted on 2011-02-11
3
443 Views
Last Modified: 2012-05-11
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",IIf([YrsofSvc]>=15,"20",IIf([YrsofSvc]>=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(DateDiff("m",[Date 1],Date())/12)) & " " & "Years",(DateDiff("m",[Date 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
0
Comment
Question by:zgrrl
  • 2
3 Comments
 
LVL 31

Accepted Solution

by:
Helen_Feddema earned 500 total points
ID: 34874322
I would do the calculated expressions in a query, not in a textbox's control source -- much easier to work with!  I would redo the 2nd formula to always yield months (no text, just a number), and then it could be used in the 1st formula.
0
 

Author Comment

by:zgrrl
ID: 34874971
Helen,

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,"25",IIf([TotalMonths]>=180,"20",IIf([TotalMonths]>=60,"15",IIf([TotalMonths]>=12,"10",IIf([TotalMonths]>=6,"5","0")))))

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!.
0
 

Author Closing Comment

by:zgrrl
ID: 34874975
Thank you!
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question