By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,872 Members | 2,392 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,872 IT Pros & Developers. It's quick & easy.

testing for boolean

P: n/a
I have entered the following code, but it complains that my syntax is wrong.

=IIf( [Tax_Exempt] = -1, (Sum [Net Amount]), (Sum [Net Amount] * 1.06)

I will really, really appreciate a solution.

Thanks very much,
Chuck
Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Try This

IIf([Tax_Exempt] = -1, Sum([Net Amount]), Sum([Net Amount] * 1.06))

Hope it works.

--
Message posted via http://www.accessmonster.com
Nov 13 '05 #2

P: n/a
Believe it or not, in both VBA and (miscrosoft) SQL (including Access),
it works better to test for FALSE rather then TRUE.

So, in your query, use:
=IIf( [Tax_Exempt] = FALSE, (Sum [Net Amount] * 1.06),(Sum [Net
Amount]))
and you'll get more consistant results.

Nov 13 '05 #3

P: n/a
"Chuck Grimsby" <c.*******@worldnet.att.net> wrote in
news:11*********************@g49g2000cwa.googlegro ups.com:
Believe it or not, in both VBA and (miscrosoft) SQL (including
Access), it works better to test for FALSE rather then TRUE.

So, in your query, use:
=IIf( [Tax_Exempt] = FALSE, (Sum [Net Amount] * 1.06),(Sum [Net
Amount]))
and you'll get more consistant results.


There are several reasons for this:

1. different database engines use different actual values for TRUE
(1 or -1), but all of them use the same value for FALSE (0).

2. in certain Access functions, Boolean conditionals statements
evalate data in that fashion, so that any value other than 0 is
treated as True. Try this in the Debug window:

IIf(Instr("This is a test","test") ,"'Tis True","'Tis Not")

The value returned by the InStr() is treated as a True result,
because IIf() is internally wired to test NOT FALSE, instead of IS
TRUE.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.