Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / May 2008

Tip: Looking for answers? Try searching our database.

formula

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Srinivas - 26 May 2008 09:05 GMT
i  have designed a form in that there are two fields called actual payment
[AP] and
commission [comm] the scenario is like this if [AP] is from 1 to 25000 - the
bank will charge 25
as commision [comm] (THE FORMULA I WANT TO ENTER IN [COMM] and from 25001 to
50000 - 50 then after 50001 to  55000 - 55 and
55001 to 60000 - 60, 60001 to 75000, 75..........etc i want formula up
100000. But if nothing
there like 0 it should display "0"

Can any one help me please

Signature

srinivas

Wayne-I-M - 26 May 2008 21:02 GMT
Search help for nested IIf's

Something like this

IIf ([AP]=#, [Comm] =#, IIf ([AP]=#,  [Comm] =#, IIf ([AP]=#,  [Comm] =#,
IIf ([AP]=#, ) ) ) ) etc, etc,etc

Note - you can have a maxium of 7 nested IIf's

Signature

Wayne
Manchester, England.

> i  have designed a form in that there are two fields called actual payment
> [AP] and
[quoted text clipped - 7 lines]
>
> Can any one help me please
John W. Vinson - 26 May 2008 21:34 GMT
>i  have designed a form in that there are two fields called actual payment
>[AP] and
[quoted text clipped - 7 lines]
>
>Can any one help me please

Three solutions come to mind, in increasing order of preference:

1. Use nested IIF's as Wayne suggests. Simple to implement, but can be
difficult to maintain and will run out of steam if there are too many ranges.

2. Use the Switch() function. It takes pairs of arguments, and evaluates them
left to right; when it first encounters a pair with TRUE as the value of the
first element of the pair, it returns the second element and quits. So:

Commission: ([AP] <= 25000, 25, [AP] <= 50000, 50, [AP] <= 55000, 55, <etc up
to 100000>, True, 0)

The last pair catches those conditions where none of the stated conditions
apply (such as a NULL value of AP).

3. Best but most laborious solution: create a Commissions table with three
fields, Low, High and Commission. Each row would have the values you need. You
can create a "Non Equi Join" query:

SELECT yourtable.*, Commissions.Commision
FROM yourtable
INNER JOIN Commissions
ON yourtable.AP >= Commissions.Low
AND yourtable.AP <= Commissions.High;

This solution is best in many ways because you can edit the Commissions table
as needed, without having to delve into the complex IIF or Switch() statements
in your code - and without having to remember all of the places such
expressions might be hidden.
Signature


            John W. Vinson [MVP]

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.