From: Mansoor on
How should I write the following:

IIf([Number] is even,0,1)
Thanks in advance mansoor
From: Stefan Hoffmann on
hi,

On 13.02.2010 09:55, Mansoor wrote:
> How should I write the following:
>
> IIf([Number] is even,0,1)
Either use bit-masking or modulo-division:

CLng([Number]) And 1 = 1

CLng([Number]) Mod 2 = 1

Both are testing for odd numbers. Depending of you numbers data type you
don't need the CLng() conversion.


mfG
--> stefan <--
From: John Spencer on
I think you will have to include parentheses to ensure the proper order of
evaluation in the statement.
(CLng([Number]) And 1) = 1

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

Stefan Hoffmann wrote:
> hi,
>
> On 13.02.2010 09:55, Mansoor wrote:
>> How should I write the following:
>>
>> IIf([Number] is even,0,1)
> Either use bit-masking or modulo-division:
>
> CLng([Number]) And 1 = 1
>
> CLng([Number]) Mod 2 = 1
>
> Both are testing for odd numbers. Depending of you numbers data type you
> don't need the CLng() conversion.
>
>
> mfG
> --> stefan <--
From: John W. Vinson on
On Sat, 13 Feb 2010 00:55:01 -0800, Mansoor
<Mansoor(a)discussions.microsoft.com> wrote:

>How should I write the following:
>
>IIf([Number] is even,0,1)
>Thanks in advance mansoor

You don't need an IIF at all: just use the MOD operator, which returns the
remainder after a divison. [Number] MOD 2 will be equal to 0 if Number is
even, 1 if it is odd.
--

John W. Vinson [MVP]
From: Mansoor on
Thank you Mr Spencer
but I need this condition

IIf([Number] is even,0,1)
as a criteria to the following column
[FromNo] Mod 2

"John Spencer" wrote:

> I think you will have to include parentheses to ensure the proper order of
> evaluation in the statement.
> (CLng([Number]) And 1) = 1
>
> John Spencer
> Access MVP 2002-2005, 2007-2010
> The Hilltop Institute
> University of Maryland Baltimore County
>
> Stefan Hoffmann wrote:
> > hi,
> >
> > On 13.02.2010 09:55, Mansoor wrote:
> >> How should I write the following:
> >>
> >> IIf([Number] is even,0,1)
> > Either use bit-masking or modulo-division:
> >
> > CLng([Number]) And 1 = 1
> >
> > CLng([Number]) Mod 2 = 1
> >
> > Both are testing for odd numbers. Depending of you numbers data type you
> > don't need the CLng() conversion.
> >
> >
> > mfG
> > --> stefan <--
> .
>