Select only even or odd number records

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.
 
D

Duane Hookom

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.
 
P

Phillip

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.
 
D

Duane Hookom

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top