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"))
 
Joined
Nov 9, 2005
Messages
17
Reaction score
0
Instead of a jillion IIF statements, have you considered using embedded case statements .. it makes your code much more user friendly if someone else decides to come in and look at it and it a whole lot easire for troubleshooting ... and for syntax things like that
 

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

If Statement in Subform 4
Tax Box Problems 3
#Error on form 2
Invoice Form Setup Help 1
Iff statement 9
Cash register 11
"What-if" formula for either a manual entry and automated entry 3
Fields with zero values 2

Top