check mark to filter data or not

G

Guest

Hello, how can I modify the code below to allow all the records to be
displayed if the check mark is off? In other words, I have a table with
records with checkmarks (Yes/No field) and records without. I am using a
query looking up a form which has a checkbox unbounded field. What I want is,
if checkbox in the form is selected then only records with the check mark
from the table should be retrieved. However, if the checkmark is off, then
all the records should be retrieved including these with a checkmark from the
table.) Thank you for your help.

SELECT Table1.test, Table1.yesno
FROM Table1
WHERE (((Table1.yesno)=[Forms]![Form1]![Check0]));
 
J

John Spencer

SELECT Table1.test, Table1.yesno
FROM Table1
WHERE (Table1.yesno=[Forms]![Form1]![Check0]
Or Table1.YesNo = True)

If check0 is true then return records where yesno fields are True or yesno
fields are ture
If check0 is false then return records where yesno fields are false or yesno
fields are true

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
G

Guest

Have you tested that John?
It looks to me like if check0 is not checked, it will return all records.
So, it will return all records regardless of whether check0 is checked. That
is because if it is not checked, it will return all the records where
Table1.yesno is false and the OR will return all the records where it is true.

--
Dave Hargis, Microsoft Access MVP


John Spencer said:
SELECT Table1.test, Table1.yesno
FROM Table1
WHERE (Table1.yesno=[Forms]![Form1]![Check0]
Or Table1.YesNo = True)

If check0 is true then return records where yesno fields are True or yesno
fields are ture
If check0 is false then return records where yesno fields are false or yesno
fields are true

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

Silvio said:
Hello, how can I modify the code below to allow all the records to be
displayed if the check mark is off? In other words, I have a table with
records with checkmarks (Yes/No field) and records without. I am using a
query looking up a form which has a checkbox unbounded field. What I want
is,
if checkbox in the form is selected then only records with the check mark
from the table should be retrieved. However, if the checkmark is off, then
all the records should be retrieved including these with a checkmark from
the
table.) Thank you for your help.

SELECT Table1.test, Table1.yesno
FROM Table1
WHERE (((Table1.yesno)=[Forms]![Form1]![Check0]));
 
J

John Spencer

If I understood the OP (original poster), the desired result was to return
ALL records when the checkbox on the form was false and only the true
records when the checkbox on the form was true.

So, if my logic is correct when evaluating
(Table1.yesno=[Forms]![Form1]![Check0] Or Table1.YesNo = True)


Checkbox = true the statement evaluates as
Field = True Or Field = True
So return records where the field is true

Checkbox = False the statement evaluates as
Field = False Or Field = True
So return records where the field is false or where the field is true (all
records).

If I have misread the OP's intent, then hopefully the OP will post back.
--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

Klatuu said:
Have you tested that John?
It looks to me like if check0 is not checked, it will return all records.
So, it will return all records regardless of whether check0 is checked.
That
is because if it is not checked, it will return all the records where
Table1.yesno is false and the OR will return all the records where it is
true.

--
Dave Hargis, Microsoft Access MVP


John Spencer said:
SELECT Table1.test, Table1.yesno
FROM Table1
WHERE (Table1.yesno=[Forms]![Form1]![Check0]
Or Table1.YesNo = True)

If check0 is true then return records where yesno fields are True or
yesno
fields are ture
If check0 is false then return records where yesno fields are false or
yesno
fields are true

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

Silvio said:
Hello, how can I modify the code below to allow all the records to be
displayed if the check mark is off? In other words, I have a table with
records with checkmarks (Yes/No field) and records without. I am using
a
query looking up a form which has a checkbox unbounded field. What I
want
is,
if checkbox in the form is selected then only records with the check
mark
from the table should be retrieved. However, if the checkmark is off,
then
all the records should be retrieved including these with a checkmark
from
the
table.) Thank you for your help.

SELECT Table1.test, Table1.yesno
FROM Table1
WHERE (((Table1.yesno)=[Forms]![Form1]![Check0]));
 
G

Guest

You are correct. My apologies, I misread the post.
--
Dave Hargis, Microsoft Access MVP


John Spencer said:
If I understood the OP (original poster), the desired result was to return
ALL records when the checkbox on the form was false and only the true
records when the checkbox on the form was true.

So, if my logic is correct when evaluating
(Table1.yesno=[Forms]![Form1]![Check0] Or Table1.YesNo = True)


Checkbox = true the statement evaluates as
Field = True Or Field = True
So return records where the field is true

Checkbox = False the statement evaluates as
Field = False Or Field = True
So return records where the field is false or where the field is true (all
records).

If I have misread the OP's intent, then hopefully the OP will post back.
--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

Klatuu said:
Have you tested that John?
It looks to me like if check0 is not checked, it will return all records.
So, it will return all records regardless of whether check0 is checked.
That
is because if it is not checked, it will return all the records where
Table1.yesno is false and the OR will return all the records where it is
true.

--
Dave Hargis, Microsoft Access MVP


John Spencer said:
SELECT Table1.test, Table1.yesno
FROM Table1
WHERE (Table1.yesno=[Forms]![Form1]![Check0]
Or Table1.YesNo = True)

If check0 is true then return records where yesno fields are True or
yesno
fields are ture
If check0 is false then return records where yesno fields are false or
yesno
fields are true

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

Hello, how can I modify the code below to allow all the records to be
displayed if the check mark is off? In other words, I have a table with
records with checkmarks (Yes/No field) and records without. I am using
a
query looking up a form which has a checkbox unbounded field. What I
want
is,
if checkbox in the form is selected then only records with the check
mark
from the table should be retrieved. However, if the checkmark is off,
then
all the records should be retrieved including these with a checkmark
from
the
table.) Thank you for your help.

SELECT Table1.test, Table1.yesno
FROM Table1
WHERE (((Table1.yesno)=[Forms]![Form1]![Check0]));
 
J

John Spencer

Dave,

No apology needed.

We all make errors and it is nice that peer review catches the errors when
we do.

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

Klatuu said:
You are correct. My apologies, I misread the post.
--
Dave Hargis, Microsoft Access MVP


John Spencer said:
If I understood the OP (original poster), the desired result was to
return
ALL records when the checkbox on the form was false and only the true
records when the checkbox on the form was true.

So, if my logic is correct when evaluating
(Table1.yesno=[Forms]![Form1]![Check0] Or Table1.YesNo = True)


Checkbox = true the statement evaluates as
Field = True Or Field = True
So return records where the field is true

Checkbox = False the statement evaluates as
Field = False Or Field = True
So return records where the field is false or where the field is true
(all
records).

If I have misread the OP's intent, then hopefully the OP will post back.
--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

Klatuu said:
Have you tested that John?
It looks to me like if check0 is not checked, it will return all
records.
So, it will return all records regardless of whether check0 is checked.
That
is because if it is not checked, it will return all the records where
Table1.yesno is false and the OR will return all the records where it
is
true.

--
Dave Hargis, Microsoft Access MVP


:

SELECT Table1.test, Table1.yesno
FROM Table1
WHERE (Table1.yesno=[Forms]![Form1]![Check0]
Or Table1.YesNo = True)

If check0 is true then return records where yesno fields are True or
yesno
fields are ture
If check0 is false then return records where yesno fields are false or
yesno
fields are true

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

Hello, how can I modify the code below to allow all the records to
be
displayed if the check mark is off? In other words, I have a table
with
records with checkmarks (Yes/No field) and records without. I am
using
a
query looking up a form which has a checkbox unbounded field. What I
want
is,
if checkbox in the form is selected then only records with the check
mark
from the table should be retrieved. However, if the checkmark is
off,
then
all the records should be retrieved including these with a checkmark
from
the
table.) Thank you for your help.

SELECT Table1.test, Table1.yesno
FROM Table1
WHERE (((Table1.yesno)=[Forms]![Form1]![Check0]));
 
G

Guest

Thank you so much guys. John you are correct. I am glad to see that at least
2 people know what are doing! A+; Silvio <=== NOT included :)

John Spencer said:
Dave,

No apology needed.

We all make errors and it is nice that peer review catches the errors when
we do.

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

Klatuu said:
You are correct. My apologies, I misread the post.
--
Dave Hargis, Microsoft Access MVP


John Spencer said:
If I understood the OP (original poster), the desired result was to
return
ALL records when the checkbox on the form was false and only the true
records when the checkbox on the form was true.

So, if my logic is correct when evaluating
(Table1.yesno=[Forms]![Form1]![Check0] Or Table1.YesNo = True)


Checkbox = true the statement evaluates as
Field = True Or Field = True
So return records where the field is true

Checkbox = False the statement evaluates as
Field = False Or Field = True
So return records where the field is false or where the field is true
(all
records).

If I have misread the OP's intent, then hopefully the OP will post back.
--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

Have you tested that John?
It looks to me like if check0 is not checked, it will return all
records.
So, it will return all records regardless of whether check0 is checked.
That
is because if it is not checked, it will return all the records where
Table1.yesno is false and the OR will return all the records where it
is
true.

--
Dave Hargis, Microsoft Access MVP


:

SELECT Table1.test, Table1.yesno
FROM Table1
WHERE (Table1.yesno=[Forms]![Form1]![Check0]
Or Table1.YesNo = True)

If check0 is true then return records where yesno fields are True or
yesno
fields are ture
If check0 is false then return records where yesno fields are false or
yesno
fields are true

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

Hello, how can I modify the code below to allow all the records to
be
displayed if the check mark is off? In other words, I have a table
with
records with checkmarks (Yes/No field) and records without. I am
using
a
query looking up a form which has a checkbox unbounded field. What I
want
is,
if checkbox in the form is selected then only records with the check
mark
from the table should be retrieved. However, if the checkmark is
off,
then
all the records should be retrieved including these with a checkmark
from
the
table.) Thank you for your help.

SELECT Table1.test, Table1.yesno
FROM Table1
WHERE (((Table1.yesno)=[Forms]![Form1]![Check0]));
 

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