Check box in a query

  • Thread starter Christopher W via AccessMonster.com
  • Start date
C

Christopher W via AccessMonster.com

am trying to put a parameter in the SQL of a query to allow criteria from a
check box. Where the check box is selected it should only return data from
the query where the field = Yes. BUT when the check box is not selected i.e.
it is “no” the query should return all records whether the record is yes or
no. I initially though that I could do this by treating the blank check box
as though it was a Null variable. However clearly this is incorrect.

I have been trying the code like this;

AND ((([forms]![multi query]![checkbasket]= “yes”)=(select.([basket]) from
transaction where transaction.[Basket]= “yes”)) AND ((([forms]![multi query]!
[checkbasket] = “no”)=(select.([basket]) from transaction where transaction.
[Basket] = “no”or “yes”))

Any suggestions would be greatly appreciated, thanks in advance
 
A

Allan Murphy

A check box has a value of -1 for True meaning YES and 0 for false meaning
NO so change your query to True or False
 
C

Christopher W via AccessMonster.com

Thanks Allan for your Reply

I have tried you suggestions and altered my SQL to the following;

AND ((([forms]![multi query]![check60])= “True”)=(select([basket]) from
transaction where transaction.[Basket]=“True”) AND ((([forms]![multi query]!
[check60] = “False”)=(select([basket]) from transaction where transaction.
[Basket] = “False” or “True”))

Unfortunately I still get a SYNTAX error. I am not very failure with SQL and
wrote this by looking at other queries SQL where it was SQL was generated
automatically and went by feel. Therefore I’m not at all surprised that I’m
receiving errors. Can you see anything else that may be wrong with this code
or if it could be rewritten more simply altogether.

Thanks mate I really appreciate it.


Allan said:
A check box has a value of -1 for True meaning YES and 0 for false meaning
NO so change your query to True or False

--
Allan Murphy
Email: [email protected]
am trying to put a parameter in the SQL of a query to allow criteria from a
check box. Where the check box is selected it should only return data from
the query where the field = Yes. BUT when the check box is not selected i.e.
it is "no" the query should return all records whether the record is yes or
no. I initially though that I could do this by treating the blank check box
as though it was a Null variable. However clearly this is incorrect.
[quoted text clipped - 3 lines]
AND ((([forms]![multi query]![checkbasket]= "yes")=(select.([basket]) from
transaction where transaction.[Basket]= "yes")) AND ((([forms]![multi query]!
[checkbasket] = "no")=(select.([basket]) from transaction where transaction.
[Basket] = "no"or "yes"))

Any suggestions would be greatly appreciated, thanks in advance
 
Top