473,402 Members | 2,072 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Processing Multiple Check Boxes in SQL Query

I'm having dificulty figuring out how to process multiple check boxes on a
web form.

Let's say I have three check boxes:
cbox1
cbox2
cbox3

The only way I can think of to code the possibilities is something like:

If cbox1.checked = true then
..........
End if

If cbox2.checked = true then
.......
End If

If cbox3.checked = true then
.......
End if

If cbox1.checked = true and cbox2.checked = true then
.......
end if

If cbox1.checked = true and cbox3.checked = true then
.......
end if

And the If/End IFs go on forever!

As you can see, if I have around 8 check boxes, doing it this way could lead
to tremendous amounts of coding. I'm sure there's a better, easier way,
right? I thought of using a select case but that wouldn't be much better I
don't think.

Terry in the dotnet.vb newsgroup gave this suggestion:

dim c as integer = 0
if cbox3.Checked = True then c = 1
if cbox2.Checked = True then c += 2
if cbox1.Checked = True then c+=4

Select Case c
Case 0 'No checks
Case 1 'cbox 3
Case 2 'cbox 2
Case 3 'cbox 2 & 3
Case 4 'cbox 1
Case 5 'cbox 1 & 3
Case 6 'cbox 1 & 2
Case 7 'cbox 1,2, & 3
End Select

I thought this was a great idea, but when you have 7 checkboxes, that still
leaves 128 Cases within a select case statement to program.

Is there a dynamic way to code this scenario that works with web forms?

The application is a query that runs against a single table in an access
database. Each check box represents each field they could chose from to show
up in a table or other style report.

TIA,
Jim


Nov 19 '05 #1
1 3075
Hi Jim.
Try loop thru controls array or search this controls by specifc name:

for (int i = 0; i < page.Controls.Count; i ++)
((Checkbox)Page.FindContol("chb" + i.ToString())).Checked
or
((Checkbox)Page.Controls[i]).Checked

Of course this is just a tip ;)

Regards from Poland.

--
C# Dev
"Jim in Arizona" wrote:
I'm having dificulty figuring out how to process multiple check boxes on a
web form.

Let's say I have three check boxes:
cbox1
cbox2
cbox3

The only way I can think of to code the possibilities is something like:

If cbox1.checked = true then
..........
End if

If cbox2.checked = true then
.......
End If

If cbox3.checked = true then
.......
End if

If cbox1.checked = true and cbox2.checked = true then
.......
end if

If cbox1.checked = true and cbox3.checked = true then
.......
end if

And the If/End IFs go on forever!

As you can see, if I have around 8 check boxes, doing it this way could lead
to tremendous amounts of coding. I'm sure there's a better, easier way,
right? I thought of using a select case but that wouldn't be much better I
don't think.

Terry in the dotnet.vb newsgroup gave this suggestion:

dim c as integer = 0
if cbox3.Checked = True then c = 1
if cbox2.Checked = True then c += 2
if cbox1.Checked = True then c+=4

Select Case c
Case 0 'No checks
Case 1 'cbox 3
Case 2 'cbox 2
Case 3 'cbox 2 & 3
Case 4 'cbox 1
Case 5 'cbox 1 & 3
Case 6 'cbox 1 & 2
Case 7 'cbox 1,2, & 3
End Select

I thought this was a great idea, but when you have 7 checkboxes, that still
leaves 128 Cases within a select case statement to program.

Is there a dynamic way to code this scenario that works with web forms?

The application is a query that runs against a single table in an access
database. Each check box represents each field they could chose from to show
up in a table or other style report.

TIA,
Jim


Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Pax S | last post by:
I need a button that will check (make true) two check boxes (fields) For the record that has the focus (the record on the form that I am presently looking at). The two check boxes would be like a...
2
by: Craig M | last post by:
Hi, I have a form, frmInvoices and a subform, frmInvoicesSub. On the parent form, i have a "print report" button, that prints a report depending on an ID on the parent form. Each record in...
11
by: dskillingstad | last post by:
I've been struggling with this problem for some time and have tried multiple solutions with no luck. Let me start with, I'm a novice at Access and I'm not looking for someones help to design my...
6
by: James Radke | last post by:
Hello, I have a multithreaded windows NT service application (vb.net 2003) that I am working on (my first one), which reads a message queue and creates multiple threads to perform the processing...
10
by: Jim in Arizona | last post by:
I'm having dificulty figuring out how to process multiple check boxes on a web form. Let's say I have three check boxes: cbox1 cbox2 cbox3 The only way I can think of to code the...
6
by: Dave | last post by:
On my form I have combo boxes. These combo boxes, after updating them, populate respective listboxes that are located below the combo boxes on the same form. I am trying to use a "generate...
1
by: Euge | last post by:
Hi, I really hope someone will be able to help me with this one as I am sure im just missing something simple. I have an unbound form which has 20 yes/no unbound check boxes. The purpose of...
2
by: hollinshead | last post by:
hi there, i have been having this issue for quite some time now and i cant seem to get my head around it. I am trying to create a database for candidates CV's and covering letters. basically the data...
2
by: Ru55ell | last post by:
Hi I have written a form that has 4 drop down selection boxes on it, with check boxes next to them. When a user selects something from the drop down box the check box is automatically selected. I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.