473,395 Members | 1,554 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to use IIF in MSAccess / VBA with 5 conditions?

2
Hi guys, need help with the iif in query, i need to display these adjectival rating using the equivalents from a different query, i would like to use iif:

100-90 = Outstanding
89-80 = Very Satisfactory
79-50 = satisfactory
49-30 = unsatisfactory
29 below = poor

I've actually tried this:

Expand|Select|Wrap|Line Numbers
  1. Adjectival_Rating:IIF([eval]<=100 And [eval]>=90,“Outstanding”, (IIF([eval]<=89 And [eval]>=80, “Very Satisfactory” , (IIF([eval]<=79 And [eval]>=50, “Satisfactory”, (IIF([eval]<=49 And [eval]>=30, “Unsatisfactory”, (IIF([eval]<=29, “Poor”,”Out of Range”)))))))))
But I can't seem to find what's wrong :| please help
Jun 5 '12 #1
4 2286
Wreckx
2
haha, finally got it :)
Just have to use the value "eval" and drag it in the FIELD to identify where the value will be coming from.
Expand|Select|Wrap|Line Numbers
  1. AdjectivalRating: IIf([eval]<=100 And [eval]>=90,"Outstanding",(IIf([eval]<=89 And [eval]>=80,"Very Satisfactory",(IIf([eval]<=79 And [eval]>=50,"Satisfactory",(IIf([eval]<=49 And [eval]>=30,"Unsatisfactory",(IIf([eval]<=29,"Poor","Out of Range")))))))))
Jun 5 '12 #2
NeoPa
32,556 Expert Mod 16PB
Using IIf() can be less involved than that, but frankly an even better solution, as it's available, would be to use Switch() :
Expand|Select|Wrap|Line Numbers
  1. AdjectivalRating: Switch([Eval] Between 90 And 100,'Outstanding',
  2.                          [Eval]>=80,'Very Satisfactory',
  3.                          [Eval]>=50,'Satisfactory',
  4.                          [Eval]>=30,'Unsatisfactory',
  5.                          [Eval] Between 0 And 29,'Poor',
  6.                          True,'Out of Range')
NB. This is laid out to view. You would enter it into your query as a single item.
Jun 5 '12 #3
Mihail
759 512MB
Or, based on your data:
Expand|Select|Wrap|Line Numbers
  1. IIf([eval] <= 29, "Poor", _
  2.     IIf([eval] <= 49, "unsatisfactory", _
  3.         IIf([eval] <= 79, "satisfactory", _
  4.             IIf([eval] <= 89, "Very Satisfactory", _
  5.                 "Outstanding"))))
See NeoPa's NB too.

NeoPa
I think that you must use the Between() function also in lines 2-4.

Wreckx
Note that NeoPa's solution is very general for problems like yours.
My solution is specific based on your data ranges (no gaps between ranges)
Jun 6 '12 #4
NeoPa
32,556 Expert Mod 16PB
NeoPa:
Using IIf() can be less involved than that, but frankly an even better solution, as it's available, would be to use Switch()
I did say that it's possible to create a better version using IIf(), but I wouldn't recommend it as Switch() is better in all respects. Your suggestion is not a match for the question as it assumes (as the original question does not) that values outside of the range 0 <= X <= 100 are not possible. They need to be catered for in the scenario described by the question.

Mihail:
NeoPa
I think that you must use the Between() function also in lines 2-4.
No. That wouldn't be a solution I could recommend, but it does draw my attention to a very real flaw in my logic. With that in mind here's a new version which (hopefully) reflects the logic correctly :
Expand|Select|Wrap|Line Numbers
  1. AdjectivalRating: Switch([Eval] Not Between 0 And 100,'Out of Range',
  2.                          [Eval]<30,'Poor',
  3.                          [Eval]<50,'Unsatisfactory',
  4.                          [Eval]<80,'Satisfactory',
  5.                          [Eval]<90,'Very Satisfactory',
  6.                          True,'Outstanding')
Jun 6 '12 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Brad Burke | last post by:
From a windows .Net app, I need to 1) check if MSAccess is already open to a certain Access application. If so, then open a form and find a certain record. 2) If not open, then open MSAccess and...
15
by: (Pete Cresswell) | last post by:
I've got a .BAT file that I use for executing various MS Access apps that I wrote way back in the days of 2.0. It's evolved over time, but it still contains a number of possible paths to...
0
by: Richard Beacroft | last post by:
Trying to write a C# Windows App to export all objects and content from 2 MSAccess 97 databases for comparison analysis. very little documentation found. Have managed to instantiate MSAccess,...
4
by: Annick Van Hoof | last post by:
Hi, I'm having my ASP.NET application hosted at a Windows 2003 server (IIS6). This works almost all the time (I have uptimes of 100% on most days), but then all of a sudden a few days in a row I...
4
by: Keith H. | last post by:
I found a post on this problem from 2004, but no one at that time replied to it- I'm hoping to have better luck than the original author! As the subject states, I'm running into a problem where...
0
by: MLH | last post by:
I've been unable to determine the correct setting to force a copy of msaccess.exe to be written to target disk during runtime installation process. It may be that the runtime installation...
2
by: reidarT | last post by:
I am making an installation program for an Access application. The application is run on both Office 2000, 2002, 2003 and soon 2007 versions of Office, When I install the application I need a...
1
by: rolandsk | last post by:
I need help to schedule a MsAccess procedure I want the procedure to run in backgrund and not the MsAccess file to be open during the time when the procedure runs. The procedure in MsAccess picks...
4
by: dsdevonsomer | last post by:
Hello, I have one simple query joining two tables with left outer join on 3 fields and using MIN on two fields. These two tables have lot of data about 3 mil in total. I am trying to migrate db...
0
by: bbrewder | last post by:
I am struggling with some MSAccess automation issues. Basically, we have a .Net application that uses MSAccess for reporting (legacy code). We are able to launch MSAccess fine and even work with...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.