Hi chrisryhal,
Use the Value property.
from MSDN:
"The settings for value are:
CheckBox control: 0 is Unchecked (default), 1 is Checked, and 2 is Grayed (dimmed)."
bkt
Main Topics
Browse All TopicsI need some help. Never did this before with a check box. Can some please show me how to pass the value of "1" to SQL if checked and "0" if not checked.
I am able to do it with textboxes:
If Not IsNull(txtEntryPerson.Text
rsData.Fields("EntryPerson
Else
rsData.Fields("EntryPerson
End If
but not sure about checkboxes.
Thanks
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Check boxes .VALUE property store 0, 1, 2. Radio boxes store TRUE/FALSE
SQL Server and most other database that use a bit flag store 0 for false (or off/no) and 1 for true (or on/yes)
I normally solve this by these two methods (1 for check boxes and 2 for radio buttons)
1) mydatabasefield = abs(mycheckbox.value <> 0)
2) mydatabasefield = abs(myradiobutton.value)
ABS will force the TRUE/FALSE value to be 0 or 1
I also use this when dealing with the registry because I don't want TRUE or FALSE in my registry.
>>I specifically asked to send a value of 1 if check and 0 if not, and I got nothing related. FDS_FATBOY, how does rsData.Fields("myBoolean")
Well I'm sorry! I was quite busy working. I just misread.
If you are using a BIT (or boolean or Yes/No depending on the RDBMS) type field in your SQL table - as you should, a true or false = 1 or 0. So my solution would work.
If you are using an INT or other numeric, you are storing a boolean value in the wrong data type.
schworak's answer is good, but if (as I suspect) you don't use greyed boxes then this is the most efficient:
rsData.Fields("myBoolean")
What data type are you storing them in?
>>The answer I gave does return 1 if checked 0 if not checked. So what is the problem?
Nothing - please read what I wrote:
>> schworak's answer is good, but if (as I suspect) you don't use greyed boxes then this is the most efficient:
What I meant was - he already has the value. performing a function on it to get the same value out is (obviously) not as efficient as using the original value. i.e. not performing that function.
Ah. Now I see what you mean.
I used the function to be more generic and to demonstrate that it also works on radio buttons the ABS function call is super effecient because it simply turns off the negative bit in of the inner value
Another thing about using the ABS function in that way in case no one noticed, you aren't limited to checkboxes or radio buttons. You can use it any place you want a 1 or 0 (zero) returned.
So instead of say using an IF THEN ELSE block you can put your logic in the ABS function.
For example (and way beyond this question but good for theory)
IF somevariable > somevalue THEN
datafield = 1
ELSE
datafield = 0
ELSE
using the ABS function it would look like this.
datafield = ABS(somevariable > somevalue)
ABS is very effecient because it simply clears the minus bit of the inner value.
Enjoy!
In a general sense, boolean values in SQL Server 2000 are represented as bits, numeric 0 or 1. When I am building a SQL INSERT or UPDATE statement, I need a TRUE value to be represented as "1" and a FALSE value to be represented as "0". Easiest way to do it in one line is : dim strBoolean as String = IIF(MyBoolean,"1","0") and then concatenate strBoolean into the SQL string.
Business Accounts
Answer for Membership
by: ryancysPosted on 2005-01-07 at 07:44:37ID: 12984289
try:
= IIF(myCheckbox.Checked = 1, True, False)
...
rsData.Fields("myBoolean")
...
Where if checked means the boolean value is True for above condition.
Hope this helps