IIf Statement in a form field using multiple criteria

B

bwhite

I have two fields, Taxable (a checkbox) and Tax Amount (currency field). In
a third field, I want to display a message based on how the previous two
fields were used.

If Taxable is checked and Tax Amount is 0, then display System Calculated
If Taxable is checked and Tax Amount is >0, then display Specific Amount
If Taxable is not checked, then display Not Taxable

I have this so far and have tried multiple things, but nothing seems to work.
I don't have any experience writing VB code.
IIf([Taxable = -1 and [Tax Amount] = 0), "System Calculated", (IIf ([Taxable]
= -1 and [Tax Amount] > 0),"Specific Amount, (IIf ([Taxable] = 0, "Not
Taxable," ")" ")
 
F

fredg

I have two fields, Taxable (a checkbox) and Tax Amount (currency field). In
a third field, I want to display a message based on how the previous two
fields were used.

If Taxable is checked and Tax Amount is 0, then display System Calculated
If Taxable is checked and Tax Amount is >0, then display Specific Amount
If Taxable is not checked, then display Not Taxable

I have this so far and have tried multiple things, but nothing seems to work.
I don't have any experience writing VB code.
IIf([Taxable = -1 and [Tax Amount] = 0), "System Calculated", (IIf ([Taxable]
= -1 and [Tax Amount] > 0),"Specific Amount, (IIf ([Taxable] = 0, "Not
Taxable," ")" ")

Your parenthesis groupings were incorrect, you left off a closing "
around Specific Amount, and I have no idea what you are doing with the
final " ")" ").

You can use:
= IIf([Taxable = -1 and [Tax Amount] = 0, "System Calculated",IIf
([Taxable] = -1 and [Tax Amount] > 0,"Specific Amount",IIf([Taxable] =
0, "Not Taxable","")))

However, aren't there just 3 possibilities (I don't think you are
going to get [Taxable] = -1 and a Tax Amount <0)? If so you don't need
that third IIf.

Try this:

= IIf([Taxable = -1 and [Tax Amount] = 0, "System Calculated",IIf
([Taxable] = -1 and [Tax Amount] > 0,"Specific Amount","Not Taxable"))
 
B

bwhite

I now get the #Name? error...Thoughts?
I have two fields, Taxable (a checkbox) and Tax Amount (currency field). In
a third field, I want to display a message based on how the previous two
[quoted text clipped - 9 lines]
= -1 and [Tax Amount] > 0),"Specific Amount, (IIf ([Taxable] = 0, "Not
Taxable," ")" ")

Your parenthesis groupings were incorrect, you left off a closing "
around Specific Amount, and I have no idea what you are doing with the
final " ")" ").

You can use:
= IIf([Taxable = -1 and [Tax Amount] = 0, "System Calculated",IIf
([Taxable] = -1 and [Tax Amount] > 0,"Specific Amount",IIf([Taxable] =
0, "Not Taxable","")))

However, aren't there just 3 possibilities (I don't think you are
going to get [Taxable] = -1 and a Tax Amount <0)? If so you don't need
that third IIf.

Try this:

= IIf([Taxable = -1 and [Tax Amount] = 0, "System Calculated",IIf
([Taxable] = -1 and [Tax Amount] > 0,"Specific Amount","Not Taxable"))
 
B

bwhite

Nevermind...i found it
I now get the #Name? error...Thoughts?
[quoted text clipped - 19 lines]
= IIf([Taxable = -1 and [Tax Amount] = 0, "System Calculated",IIf
([Taxable] = -1 and [Tax Amount] > 0,"Specific Amount","Not Taxable"))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top