Odd and even

PG2015

Registered User.
Local time
Today, 11:13
Joined
Feb 16, 2015
Messages
21
Hi scratching my head to get an IIF for odds or even in numbers. Ie if its an even number state "EVEN" in column. Obviously if odd state "ODD".:confused:

Any ideas please.

Thanks

PG
 
Check out the Mod operator.
 
Thanks - afraid I am a bit of a numpty with access and cannot see how to construct MOD in a query string. Any example would be a great help.
 
IIf (YourField Mod 2 ,"Odd", "Even" )
 
That's got it! Thanks very much for your help.:)
 
I would think
.evenly divisible by 2..if true,..if false
IIf (YourField Mod 2 , "Even","Odd" )
 
I would think
.evenly divisible by 2..if true,..if false
IIf (YourField Mod 2 , "Even","Odd" )

Yeah if it were

IIf (YourField Mod 2 = 0 , "Even","Odd" )

Which I think is better since YourField Mod 2 by itself isn't really a boolean expression and just relies on the fact that any non zero values is considered true.
 
Agreed. My issue was with the placement of Odd/Even (should be reversed)
in Minty's post.

Code:
IIf (YourField Mod 2 ,"Odd", "Even" )
 
Last edited:
I actually borrowed it from an excel forum and it seemed to be correct, but as you say it doesn't account for non 0 null values. It's too hot and Monday, that's my excuse...
 
Agreed. My issue was with the placement of Odd/Even
in Minty's post.

Code:
IIf (YourField Mod 2 ,"Odd", "Even" )

But that placement is correct with the condition being YourField Mod 2 which is true when the YourNumber is odd. YourField Mod 2 = 0 is true when YourNumber is even.
 
Yes

IIf (YourField Mod 2 = 0 , "Even","Odd" )
 

Users who are viewing this thread

Back
Top Bottom