1 (edited by identity 2016-01-24 09:06:09)

Topic: searching the checkboxes

Hi

In my project there are 4 check-boxes:
1- Yes
2- No
3- Almost
4- Maybe

this project has 100 records and in each record I should choose only one of the checkboxes.

when In the form1 I want to search the records, for example when I choose the "Yes" chockbox or "No"checkbox  the records are shown.

But when I choose both of the checkboxes together or sometimes all the checkboxes at the same time, no record is shown.

What is the script that whenever I need to search the records if I click all 4 of these checkboxes or 2 of them, all of the records are shown in the table grid

thank you

Re: searching the checkboxes

Hello,


In your case I recommend to use ComboBox and separate database table for these values (Yes, No, Almost, Maybe)
ComboBox have property MultiSelect allow you select severals values for filtering records.



Otherwise you should use SQL query for search.

Dmitry.

Re: searching the checkboxes

Thanks for your reply
In the version i use which is 1.45 combobox does not have multiselect value.
Could you please tell how can I use SQL query for search?
Thank you so much

Re: searching the checkboxes

SQL

SELECT
employees.lastname,
employees.firstname,
employees.id

FROM

employees

WHERE

(CASE WHEN {chbYes} = 1 THEN employees.yes = 1 ELSE 1=1 END) OR
(CASE WHEN {chbNo} = 1 THEN employees.no = 1 ELSE 1=0 END) OR
(CASE WHEN {chbAlmost} = 1 THEN employees.almost = 1 ELSE 1=0 END) OR
(CASE WHEN {chbMaybe} = 1 THEN employees.maybe = 1 ELSE 1=0 END)

Also you can download example project:

Post's attachments

Attachment icon Search using CheckBoxes and SQL.zip 6.11 kb, 494 downloads since 2016-01-24 

Dmitry.

Re: searching the checkboxes

thanks for your help

but this query does not work
it just works for "yes" checkbox and when I choose "no" or "almost" or "maybe" it shows all of the records.

what I want to do is that: for example

                           when I check "yes" the query shows all the "yes" records
                           when I check "no" the query shows all the "no" records
                           when I check "yes" and "no" together,  the query shows all the "yes" and "no" records
                           when I check "yes" and "no"  and "almost" together,  the query shows all the "yes" and "no" and "almost" records

and so on

Re: searching the checkboxes

thank you so much
I have corrected your query myself. it works fine

SELECT
employees.lastname,
employees.firstname,
employees.id

FROM

employees

WHERE

(CASE WHEN {chbYes} = 1 THEN employees.yes = 1 ELSE 1=0 END) OR
(CASE WHEN {chbNo} = 1 THEN employees.no = 1 ELSE 1=0 END) OR
(CASE WHEN {chbAlmost} = 1 THEN employees.almost = 1 ELSE 1=0 END) OR
(CASE WHEN {chbMaybe} = 1 THEN employees.maybe = 1 ELSE 1=0 END)