On Tue, 24 Aug 2010 08:18:24 -0700 (PDT), "(E-Mail Removed)"
<(E-Mail Removed)> wrote:
>i have a query that I'm trying to calculate NULL fields for but am
>having problems.
>
>Sold:[sold] (criteria is set to <>NULL)
>Unsold:[sold] (criteria is set to IS NULL)
>Date:[record date]
>
>i have the same field on the query twice. The idea is the records that
>are sold will have a value in them and the records that are unsold
>will have no value (null). I'm trying to total both these fields to
>show me how many records represent sold and unsold for a particular
>date. The "count" option won't count the null records though. is there
>a better way to do this?
>
>Tks
>STeve
A couple of things here: first off, nothing is equal to NULL, nor is anything
*unequal* to NULL. NULL means "undefined, unknown, unspecified" - so any
comparison (=, <>, >, <, etc.) with NULL doesn't return either true or false,
it returns NULL ("I don't know if it's equal or not, because it's undefined!")
Try two calculated fields (in vacant FIELD cells, not in the criteria line)L
Sold:IIF(IsNull([sold]), 0, 1)
Unsold: IIF(IsNull([sold]), 1, 0)
The VBA function IsNull returns either TRUE or FALSE. The IIF will return a 1
or 0 appropriately, and you can use a totals query to sum (not count!) the
1's.
--
John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/For...-US/accessdev/
http://social.answers.microsoft.com/.../en-US/addbuz/
and see also
http://www.utteraccess.com