nested iif (1 Viewer)

slimjen1

Registered User.
Local time
Today, 10:52
Joined
Jun 13, 2006
Messages
562
I all, using access 2010. I am trying to write this iif statements and I can't figure out how to answer two questions. ex.

Code:
Based on your letter, “&IIf([TotalChg]>=0, “you will have a compound charge”,Null)“& IIf([TotalChg]>=0,”your charge will be denied”,”No Charge”)&”on”&Format([TotalChg]*100,”Standard”)

Code:
Based on your letter, “&IIf([ComplChg]>=0, “you will have a compound charge”,Null)“& IIf([ComplChg]>=0,”your charge will be denied”,”No Charge”)&”on”&Format([ComplChg]*100,”Standard”)
I would like this to read as follows:
Base on your letter you will have a compound charge and your charge will be denied of 20%.
or if the first is null; the second code exist. How do I do this please?
 

pr2-eugin

Super Moderator
Local time
Today, 15:52
Joined
Nov 30, 2011
Messages
8,494
Why not use an If Else code block? Makes it a lot more easier to read. The above code is quiet not unreadable.
 

slimjen1

Registered User.
Local time
Today, 10:52
Joined
Jun 13, 2006
Messages
562
Sorry; this was inherited and i was just trying to do a quick fix until I can redesign. The code is in a paragraph in report design. I was trying to combine the code because it will have two iif statements.
ex. If this is true, do something, if not, do nothing and if the same is true do something, if not, do something else.
Right now there are two different statements which is the same "IIF([TotalChg]>=0". I hope I am making since in order for you to help. Thanks
 

pr2-eugin

Super Moderator
Local time
Today, 15:52
Joined
Nov 30, 2011
Messages
8,494
I still do not get your logic, give an example with data, and the result you hope to see.
 

willknapp

Registered User.
Local time
Today, 10:52
Joined
Aug 16, 2012
Messages
93
It appears you're looking to have a single nested iif statement. Generally, you can format it as follows:

Code:
Iif(Comparison1, Returns if Comparison1 is true, _
    Iif(Comparison2, Returns if Comprison1 is false and Comparison2 is true, & _
    returns if both comparison1 and comparison2 are false))

As an example:

Code:
myResultString = Iif(myVariable = 1, "My Variable = 1", _
    Iif(myVariable = 2), "My Variable = 2", _
    "My variable does not equal 1 or 2"))

would yield the following results, depending on the value of myVariable:

• myVariable = 1, then myResultString = "My Variable = 1"
• myVariable = 2, then myResultString = "My Variable = 2"
• myVariable = 3, then myResultString = "My variable does not equal 1 or 2"
 

slimjen1

Registered User.
Local time
Today, 10:52
Joined
Jun 13, 2006
Messages
562
I hope you can understand the following and what I am trying to accomplish. Code

Code:
"You have been informed that your account is set up on quarterly payments.  As a review of  your 2014 assets, " & IIf([TotalChg]>=0,"an increase","a  decrease") & " of " & Format([TotalChg]*100,"Standard") & " or you quarterly rates " & IIf([MidChg]>=0," increase"," decrease" in your taxable  income.
I am trying to say: If the field ([TotalChg] is greater than zero; an increase in your taxable income. If it’s less than zero; a decrease in your taxable income. And If the MidChg is greater than zero; an increase in your taxes, else a decrease in your taxes My query has the fields; TotalChg and MidChg with positive(10) and negative(-20) numbers needed formatted in the paragraph as %.
Further ex:
You have been informed that your account is set up on quarterly payments. As a review of your 2014 assess; an increase of 10% is necessary and taxable income is a decrease of -20%.
Also, if the field [TotalChg] is blank; I just want the code for [MidChg] to apply. Please help.
 

Users who are viewing this thread

Top Bottom