I want to build an expression for House Rent (HR) in MS Access.
If Basic Salary (BS) is =>5000, HR is 50% of BS but not less than 2250,
if BS is between 5001 and 10800, HR is 45% of BS but not less than 2500 and
if BS is between 10801 and 21600, HR is 40% of BS but not less than 4800
I assume that calculation is done on a query. (In query Design View)
After a analysis (go through). I think this will work try it out:
copy&paste - HRent: IIf([BS]<=5000,IIf([BS]*0.5<2250,2250,[BS]*0.5),
-
IIf([BS]<=10800,IIf([BS]*0.45<2500,2500,[BS]*0.45),
-
IIf([BS]<=21600,IIf([BS]*0.4<4800,4800,[BS]*0.4))))
Sampe Output - BS HRent
-
4000 2250
-
5000 2500
-
6000 2700
-
7000 3150
-
8000 3600
-
9000 4050
-
10000 4500
-
11000 4800
-
12000 4800
-
13000 5200
-
14000 5600
-
15000 6000
-
16000 6400
-
.............
NB:You can change column Name HR and give your own name. Hope it helps:
Jerry
14 2846
Is this appearing in a query, or in code on a form?
It appears you made a mistake in your criteria, I think you mean if BS is less than or = 5000 then HR is 50%
On a form you could build a series of if tests - if BS >21600 then
-
' something happens here?
-
elseif BS >= 10801 then
-
HR = BS *.4
-
if HR < 4800 then HR=4800
-
Elseif BS >=5001 then
-
HR=BS*.45
-
if HR<2500 then HR=2500
-
elseif BS <=5000 then
-
HR=BS * .5
-
if HR<2250 then HR=2250
-
endif
-
You might want to add some rounding, like this - HR=Round(BS*.45,0) ' whole dollars only
Jim
Sorry, my knowledge is quite basic, I want to build expression for HR in design view something like:
HR:
IIf([BS]<=5000,[BS]*0.5,But if[BS]*0.5<2250,"2250",
IIf([BS]>5000 And [BS]<=10800,[BS]*0.45,But if[BS]*0.45<2500,"2500",
IIf([BS]>10800 And [BS]<=21600,[BS]*0.4,But if[BS]*0.4<4800,"4800")))
Here, I do not know what may be correct expression for 'But if'... pl help. thanks.
I assume that calculation is done on a query. (In query Design View)
After a analysis (go through). I think this will work try it out:
copy&paste - HRent: IIf([BS]<=5000,IIf([BS]*0.5<2250,2250,[BS]*0.5),
-
IIf([BS]<=10800,IIf([BS]*0.45<2500,2500,[BS]*0.45),
-
IIf([BS]<=21600,IIf([BS]*0.4<4800,4800,[BS]*0.4))))
Sampe Output - BS HRent
-
4000 2250
-
5000 2500
-
6000 2700
-
7000 3150
-
8000 3600
-
9000 4050
-
10000 4500
-
11000 4800
-
12000 4800
-
13000 5200
-
14000 5600
-
15000 6000
-
16000 6400
-
.............
NB:You can change column Name HR and give your own name. Hope it helps:
Jerry
dear jerry
thank u very much for your prompt reply, it worked greatly!
AbbasBD
Please select as best Answer.
Glad I could help
I want to build an expression in MS Access Design View for ‘Personal Basic’ [PB] where [PB] is equal or immediate greater than ‘New Basic Minimum’ [NBM] by adding one or more ‘Increment Rate’ [IR] to ‘Basic Start’ [BS] ie,
[PB]=[BS]+([IR]*x) {where [BS]+([IR]*x)>=[NBM]}
For example:
[PB]=4500+(240*2) {here [NBM]=4890<4500+(240*2) ie, x=2 but Not x=1 or x=3}
[PB]=4980 {where 4980>=4890}
Thanks
Hi AbbasBD, before I post suggestions to your question, please write a new question for this threat.
Your Question Title would be something like: Query Criteria not Working.
Thanks
Jerry Maiapu
Thanks for your concern. Sorry for not being able to make you understand... however, just few hours back i’ve found out a solution that works for me:
PB:
(((([NBM]-[BS])\[IR])+1)*[IR])+[BS]
However, i welcome you, should you have anything better.
Thanks.
If the calculation of PB is based on a condition, then you should have a IIF clause.
For example: - If NB>=NBM then BS+IR
-
else
-
something else';;;This part is missing
Though the syntax of IIF is - IIF (condition,True Part,False Part)
the latter is an example.
According to your solution: - (((([NBM]-[BS])\[IR])+1)*[IR])+[BS]
You're simply doing some straight forward calculation.
It is not doing what you expected it to do. ie. it is NOT checking if [PB] is equal or immediate greater than ‘New Basic Minimum’ [NBM] by adding one or more ‘Increment Rate’ [IR] to ‘Basic Start’ [BS].
If it follows a sequence then hope your solution is a sequence formula
like 2n + 1 where n is the term in the sequence. (Maths you know)
Hope am clear.
Dear Maiapu
I failed to apply iif function, i've no idea about 2n+1 sequence formula... however, i tried the following that didn't work:
PB:
IIf([NBM]>=(1*[IR])+[BS],(1*[IR])+[BS],
IIf([NBM]>=(2*[IR])+[BS],(2*[IR])+[BS],
IIf([NBM]>=(3*[IR])+[BS],(3*[IR])+[BS],
IIf([NBM]>=(4*[IR])+[BS],(4*[IR])+[BS],
IIf([NBM]>=(5*[IR])+[BS],(5*[IR])+[BS]
)))))
Sure i've something wrong with the formula that i cannot sovle... waiting ur suggestion.
thanks
AbbasBD,
Can u explain a bit more on on what you are trying to achieve. I might by then help you.
From what you posted, the query expression is confusing itself in terms of evaluating the parts in the IIF clause.
Try and change all the > to < like this; run it and see if it meet your expectations: -
PB:
-
IIf([NBM]<=(1*[IR])+[BS],(1*[IR])+[BS],
-
IIf([NBM]<=(2*[IR])+[BS],(2*[IR])+[BS],
-
IIf([NBM]<=(3*[IR])+[BS],(3*[IR])+[BS],
-
IIf([NBM]<=(4*[IR])+[BS],(4*[IR])+[BS],
-
IIf([NBM]<=(5*[IR])+[BS],(5*[IR])+[BS]
-
)))))
Looks like numbers 1 to 5 are not constant ie will not stop to increment by one. Is that correct.?
What is that you are really trying to do?
Tell me.
Try the above and post back any query.
Cheers
NeoPa 32,556
Expert Mod 16PB AbbasBD:
If Basic Salary (BS) is =>5000, HR is 50% of BS but not less than 2250,
This is a strange question considering 50% of the lowest qualifying value (5,000) is 2,500 anyway. If the lowest possible value is 2,500 why would you want to check that it's greater than 2,250?
** Edit **
Forget that. I see it's been covered already, but the same is true of the next one down. These simple details should be checked and corrected before posting the question, otherwise it just wastes people's time.
@Jerry Maiapu
Yes right you are! 1, 2, 3, 4, 5 are not constant.
I want to find expression for Personal Basic [PB] that will be equal or greater than New Basic Min [NBM] by adding Increments [IR] to Basic Start [BS] (Here, always BS<NBM).
If [NBM]>=[BS]+1*[IR], its OK, but if by adding one IR doesn't make it, than should add two IR, ie, [NBM]>=[BS]+2*[IR]... Here, IR is incremental, may be nine IR need to be added... something like this.
Well, changing all > to < is not helping. May be I could clear... waiting for your reply.
Thanks.
NeoPa
Thanks for your observation. I'll be careful... next time. However, correct one should be: If BS<=5000, HR=BS*50% but not less than 2250,
Stay fine.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: crispy |
last post by:
This is something that I am never completely sure about:
When building an Access db to be accessed by ASP, do I need to worry
about setting the Relationships between the tables and the Join Types...
|
by: bissatch |
last post by:
I am trying to compare two variable but using regular expression:
$access = "glasgow"
$areaid = "glasgow-westend-byers_rd"
using the two variables, I would like the areaid variable to be...
|
by: Rolan |
last post by:
I'm using Access 97 and need some assistance in sorting out a proper
DSum expression, or maybe even DCount might be an alternative. I have
tried numerous combinations, but with no apparent success....
|
by: Jimi Ffondu |
last post by:
Hi there - it's pretty simple, and I'm an idiot. I'm not a developer,
I just seem to have landed in this job building this Access database -
I've got two days to make it work... aaahh!
1) ...
|
by: Bec |
last post by:
I'm in desperate need of your help..
I need to build an access database and have NO idea how to do this..
Not even where to start..
It IS for school, and am not asking anyone to do my...
|
by: Cheryl Langdon |
last post by:
Hello everyone,
This is my first attempt at getting help in this manner. Please
forgive me if this is an inappropriate request.
I suddenly find myself in urgent need of instruction on how to...
|
by: nmeyer |
last post by:
Hi, I'm trying to scope a MS Access project and was looking for some
advise. Will VB programming/ experience be required to build out
something like the Northwinds sample database?
We'd like a...
|
by: dafinder |
last post by:
Hello all,
I am a new user of Access and have run into some problems. I am building an access form that uses multiple tables. This is what I want to do in lay mans terms. I have a form with...
|
by: JamieWilks |
last post by:
Hi I'm currently building an access db in MS Access 2000, having not touched acces for about 10 years. I need to conditionally hide / display a combobox (specfically a pop up calendar) depending on...
|
by: melodyrae |
last post by:
Initial disclosure: I took 1 accounting with access class in undergrad 6 yrs ago, where we were offered step-by-step instructions to follow. Currently, I am interning (grad-school) for a small...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |