Results 1 to 3 of 3

Thread: Simple Checkbox question

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 1999
    Posts
    11

    Wink

    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 codeBLUSH)

    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

  2. #2
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,539
    check for value
    Code:
    if check1(idx).value = 0 then
       'send the word FALSE into db
    else
       'send word TRUE into db
    end if

  3. #3
    Lively Member
    Join Date
    Oct 2000
    Location
    Leicestershire; ENGLAND
    Posts
    71
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width