Go Back   Access World Forums > Microsoft Access Discussion > Tables

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 07-16-2019, 12:27 PM   #1
Mackbear
Newly Registered User
 
Join Date: Apr 2019
Posts: 144
Thanks: 72
Thanked 0 Times in 0 Posts
Mackbear is on a distinguished road
Smile Caculated Field Expression not working

Hello, good day! Reaching out again for help. I can't seem to make this expression work properly. What I need is if the value of the field is:

<-2 "Emergency"
-1 or 0 "Critical"
1 "High"
2 or 3 "Medium"
>3 "Low"

The expression I have is:
IIf([Age]<=-2,"Emergency",IIf([Age]=-1<=0,"Critical",IIf([Age]=1,"High",IIf([Age]>=2<=3,"Medium",IIf([Age]>3,"Low","No Date")))))

The results only show emergency and critical even with values 1 and above.

What am I missing here?

Mackbear is offline   Reply With Quote
Old 07-16-2019, 12:35 PM   #2
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 5,783
Thanks: 57
Thanked 1,267 Times in 1,248 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: Caculated Field Expression not working

Hi. When you have two criteria to apply against the same field, you'll have to check each one. For example:
Code:
IIf([Age]=-1 OR [Age]=0,...
You could try it this way:
Code:
IIf([Age]<=-1,"Emergency",IIf([Age]<=0,"Critical",IIf([Age]=1,"High",IIf([Age]<=3,"Medium","High"))))
(untested)
Hope it helps...
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is offline   Reply With Quote
The Following User Says Thank You to theDBguy For This Useful Post:
Mackbear (07-16-2019)
Old 07-16-2019, 12:47 PM   #3
Cronk
Newly Registered User
 
Join Date: Jul 2013
Posts: 2,152
Thanks: 3
Thanked 470 Times in 463 Posts
Cronk will become famous soon enough Cronk will become famous soon enough
Re: Caculated Field Expression not working

Code:
IIf([Age]<=-2,"Emergency",IIf([Age]=-1<=0,"Critical",IIf([Age]=1,"High",IIf([Age]>=2<=3,"Medium",IIf([Age]>3,"Low","No  Date")))))

The problem is with the bits in red. They will give a true value. Change line to

Code:
IIf([Age]<=-2,"Emergency",IIf([Age]<=0,"Critical",IIf([Age]=1,"High",IIf([Age]<=3,"Medium",IIf([Age]>3,"Low","No  Date")))))

Cronk is offline   Reply With Quote
The Following User Says Thank You to Cronk For This Useful Post:
Mackbear (07-16-2019)
Old 07-16-2019, 03:17 PM   #4
Mackbear
Newly Registered User
 
Join Date: Apr 2019
Posts: 144
Thanks: 72
Thanked 0 Times in 0 Posts
Mackbear is on a distinguished road
Re: Caculated Field Expression not working

I thank you everyone for the help! It is working now. You guys are great!

Mackbear is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Rounding in caculated field cpberg1 Queries 11 02-22-2015 12:23 AM
Form not working - valid field name or expression? tezread Forms 6 10-12-2010 07:11 AM
How to caculated a semester end date madabang Forms 3 12-19-2009 10:58 AM
Exported data is not caculated in Excel George Too Modules & VBA 3 06-27-2003 03:35 AM
Formatting a caculated field srm7028 Queries 3 08-18-2002 12:40 PM




All times are GMT -8. The time now is 05:01 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World