March 25th, 2011, 05:07 AM
Multiple Check box
I have a search page with multiple fields...
One of them is Category field.
I have 2 check box(with different names) with 2 values . 1)ExternalTask 2)InternalTask.
I don't know what sql code to write if user has checked
more than one choice.
Actually i want to show only ExternalTask or InternalTask only if user has checked ExternalTask or InternalTask check box. Or both if user checked both check boxes.
For example the code below,if i write the "and" between the two
"Category" it works only if i choose one check box, if i choose
both check boxes it doesn't work(Display No Records...)
But if i replace the "and" between the two "Category" in the code with "OR" it works only if i choose both check boxes.
*The rest of code it works properly
strsql="select * from [QryTask1] where NotesID like '" & replace(request("txtid"),"'","''") & "' and Priority like '%" & replace(request("txtpriority"),"'","''") & "%' and Description like '%" & replace(request("txtDesc"),"'","''") & "%' and Category
like '%" & request("txtCategory") & "%' and Category like
'%" & request("txtCategory1") & "%'
March 26th, 2011, 11:24 AM
and (txtbox1 OR txtbox2) might work (use actual names for txtboxN)
It is a truism of American politics that no man who can win an election deserves to. --Trevanian, from the novel Shibumi
March 26th, 2011, 01:07 PM
Thanks for your response..
Originally Posted by Doug G
I have tried this but it doesn't works
March 26th, 2011, 03:01 PM
looks like a logic problem in your SQL.
You are trying to test for two parameters 'internal' and 'external' but are only looking at one field 'Category' .
problem could also be a flaw in your database design. it's not clear how you distinguish between internal and external in your database structure.
March 30th, 2011, 08:34 AM
oK i HAVE WRITE THIS AND IT WORKS
Category like request("txtCategory") or Category like
March 30th, 2011, 06:52 PM
assign a value to your checkboxes when you design the search form. Then when the search was submitted, have a condition that evaluates the value of the checkboxes. Then your sql statement would differ depending on the result of the condition.
Rey G. Calanta-ol