Solved

Select using multiple check text boxes

Posted on 2008-10-12
3
157 Views
Last Modified: 2012-05-05
Hi,

I am using access and asp.

I want to use 4 check boxes to allow users to choose what to view.  What should my sql be to allow for all combinations?

The check boxes are called L1, L2, L3, L4.

This is my SQL at the moment

SELECT TOP " & Request("myNumber") & " tblPupil.PupilID, Count(tblBehaviour.ID) AS mytotal, tblPupil.Surname, tblPupil.FirstName FROM tblPupil INNER JOIN tblBehaviour ON tblPupil.PupilID = tblBehaviour.PupilID WHERE (([Level] = 'L1' OR [Level] = 'L2' OR [Level] = 'L3' OR [Level] = 'L4') AND tblPupil.TutorGroup LIKE '" & Request("myYear") & "%') GROUP BY tblPupil.PupilID, tblPupil.Surname, tblPupil.FirstName ORDER BY Count(tblBehaviour.ID) DESC

This shows all Levels.  I want to display L1, L2, L3 and L4 based on the user choice of checking the check boxes.

Thanks,

Desi
0
Comment
Question by:DesiMck
  • 2
3 Comments
 
LVL 5

Expert Comment

by:Cvijo123
ID: 22698313
something like this in your where clausule:


 WHERE (([Level] = '& Request("myL1")  &' OR [Level] = '& Request("myL2")  &' OR [Level] = '& Request("myL3")  &' OR [Level] = '& Request("myL4")  &')
0
 
LVL 1

Author Comment

by:DesiMck
ID: 22698432
Yep but what if they don't check one of the boxes. If they didn't check L1 wouldn't the SQL be:

WHERE (([Level] = '' OR [Level] = '& Request("myL2") &' OR [Level] = '& Request("myL3") &' OR [Level] = '& Request("myL4") &')
 
??
0
 
LVL 1

Accepted Solution

by:
DesiMck earned 0 total points
ID: 22698576
Thanks,
 
I found the answer here - http://bytes.com/forum/thread611445.html
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question