Question multiple check boxes to select records

nayaz

Registered User.
Local time
Today, 08:02
Joined
Jun 23, 2009
Messages
12
Hi

I have about dozen or so check boxes in a form, check0, check2, check4, .. and so on.
i need to run query that will give records that meet the creteria, i.e return data that have check boxes that were checked (true) only along with Id, name and perhaps some other data.
thanks for your help
 
I'm assuming the check boxs mean something rather than that field is true/false.
When I have done something similar, I used code to build a SQL statement that used the fields that had been selected.

I can't find the actual code so here's some psuedo code (not correct syntax, assumes checkboxes mean actual values for specific fields) describing the technique.

MySQL = "SELECT fields FROM recordset"

if check1 then
MySQL = MySQL + " WHERE colour = 'red'"
endif

if check2 then
MySQL = MySQL + " OR size = 'large'"
endif

When doing this you need to make sure you cater for if no check boxes are selected (don't want the WHERE clause), be careful where spaces get added and you finish your SQL statement correctly (add a semi-colon). Be assured, without them syntax correct, it won't work ;)
 
Thank you for your response. I am bit confused as where the sql string that I have to create will go, should I create it on the command button and then how to execute it. Thank you.
 
yes, add a command button and attach your code to it.
 

Users who are viewing this thread

Back
Top Bottom