Select only even or odd number records

  • Thread starter Thread starter Phillip
  • Start date Start date
P

Phillip

Hi,
I have a table with among other things has on number field. I want two
reports, one that select only records with even number in the number field
and the second report that selects only records with odd numbers in the
number field.
I'm on the query builder screen and can't figure out the correct code to
place in the criteria section for each report.
Your help would be appreciated.
Thanks in advance.
 
You can take you unnamed number field and use /2 or the Mod operator to
create a column in the query/record source:
OddEven: [UnnamedNumericField] Mod 2

In the criteria, enter 1 for odd records or 2 for even.
 
Hi Duane,
Thanks for your response, but I'm not sure how to do what you said. I can't
place an expression in the criteria section of my number field in the query
builder screen?
Thanks,
Phil

Duane Hookom said:
You can take you unnamed number field and use /2 or the Mod operator to
create a column in the query/record source:
OddEven: [UnnamedNumericField] Mod 2

In the criteria, enter 1 for odd records or 2 for even.

--
Duane Hookom
MS Access MVP


Phillip said:
Hi,
I have a table with among other things has on number field. I want two
reports, one that select only records with even number in the number field
and the second report that selects only records with odd numbers in the
number field.
I'm on the query builder screen and can't figure out the correct code to
place in the criteria section for each report.
Your help would be appreciated.
Thanks in advance.
 
Did you try create the OddEven field in your query and then look at the
results in datasheet view? You should see 0s and 1s. There are lots of
solutions for filtering a report based on a field value in the query.

--
Duane Hookom
MS Access MVP


Phillip said:
Hi Duane,
Thanks for your response, but I'm not sure how to do what you said. I
can't
place an expression in the criteria section of my number field in the
query
builder screen?
Thanks,
Phil

Duane Hookom said:
You can take you unnamed number field and use /2 or the Mod operator to
create a column in the query/record source:
OddEven: [UnnamedNumericField] Mod 2

In the criteria, enter 1 for odd records or 2 for even.

--
Duane Hookom
MS Access MVP


Phillip said:
Hi,
I have a table with among other things has on number field. I want two
reports, one that select only records with even number in the number
field
and the second report that selects only records with odd numbers in the
number field.
I'm on the query builder screen and can't figure out the correct code
to
place in the criteria section for each report.
Your help would be appreciated.
Thanks in advance.
 
You can take you unnamed number field and use /2 or the Mod operator to
create a column in the query/record source:
OddEven: [UnnamedNumericField] Mod 2

In the criteria, enter 1 for odd records or 2 for even.
Thank you Duane. Nine years later I found this thread and your solution works perfectly.
 
Back
Top