Solved

Select using multiple check text boxes

Posted on 2008-10-12
3
160 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

740 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