Solved

Select using multiple check text boxes

Posted on 2008-10-12
3
155 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

706 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now