Access2003 query using IIF in calculated field returns negative

B

Billy

I use this function - Age1920:IIf([Age]>18,1,0) And IIf([Age]<21,1,0) in a
calculated field. It works fine except it returns a -1 for a value of say 19
above in Age. How can I make it return positive number
 
S

Sylvain Lafontaine

-1 is the integer value for True under VBA. The result of the AND is true,
hence the result of -1.

Try something like:
Iif (([Age]>18 and [Age] < 21),1,0)

or:
IIf([Age]>18, iif ([Age] < 21, 1,0), 0)

S. L.
 
Top