Solved

Select using multiple check text boxes

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Filtering characters in an SQL field 2 16
SQL Stored Proc - Performance Enhancement 15 54
Syntax Issue with SSIS module 26 102
Time comparison asp 1 9
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

840 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