PDA

Click to See Complete Forum and Search --> : Simple Checkbox question


Delta34
Nov 2nd, 2000, 10:00 AM
I'm fairly new to VB and decided I wanted to experiment with the checkbox control. Problem, I have three check box’s in a control array. I want to select one (checkbox1(X%).value = 1) and have the other two
checkbox(X%).value = 0 . This part works OK, it could be better, however the real problem is getting the
1 or 0 into the database. I’m using a simple DAO control and can’t get it to work. I get a type mis-match.

Here’s my code:(BLUSH)

Private Sub Check1_Click(Index As Integer)
For X% = 0 To 2
Y% = X% + 1
If Y% = 3 Then Y% = 0
Z% = Y% + 1
If Z% = 3 Then Z% = 0
If Check1(X%).Value = 1 Then Check1(Y%).Value = 0
If Check1(X%).Value = 1 Then Check1(Z%).Value = 0
Next X%
Data1.Refresh
Data1.Recordset.AddNew
End Sub

kovan
Nov 2nd, 2000, 10:16 AM
check for value

if check1(idx).value = 0 then
'send the word FALSE into db
else
'send word TRUE into db
end if

Orpheus
Nov 2nd, 2000, 10:21 AM
You really ought to be using radio buttons for this. They will automatically ensure that only one of the buttons is selected at any given time.
If you need more than one group of radio buttons, enclose each group in a frame of its own for independance.

You can then sequence through each of the buttons in a loop, setting the appropriate field n the database table to TRUE or FALSE as submitted by kovan.