select odd or even records

manu

Registered User.
Local time
Yesterday, 21:30
Joined
Jun 28, 2001
Messages
51
Can someone guide me in writing a query so I can select either all Odd (1,3,5,7..) or even(2,4,6,8...) records from my table. I have a Sr# field with "Autonumber" format.

All help is appreciated.

Manu
 
Setting a criteria for the AutoNumberField

[Table1]![AutoNumberField]/2=int([Table1]![AutoNumberField]/2)

will select all those exactly divisible by 2 i.e. evens

<> rather than = will select non evens
 
Also with the MOD function:

If [Table1]![AutoNumberField] MOD 2 = 1 then 'the Autonumber is odd...

Alex
 
there is a simpler way in design view of the query.
you can add criteria for tableId as
[tableid]/2 equals 'Like "*.5*"
this returns odd numbers
the logic is odd number/2 is always not an integer.

for even numbers
[tableid]/2 equals 'Not Like ".5"
 
Over a 20 year old thread? :)
 

Users who are viewing this thread

Back
Top Bottom