Results 1 to 8 of 8

Thread: [RESOLVED] Option Button

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2007
    Posts
    76

    Resolved [RESOLVED] Option Button

    HI i have a question

    So i have 4 option( opt1, opt2, opt3, opt4) button each represent a option inside my database. and i'm reading these option into a recordset. So when i run the program, if the user chose a record the option button would be set to TRUE or False base on value in my databse.
    here is my code:
    Code:
    Private Sub ListView1_DblClick()
        If ListView1.ListItems.count > 0 Then
            varFillCombo.MoveFirst
            x = ListView1.SelectedItem.Index
            varFillCombo.Move (x - 1)
            If varFillCombo!Chamber = "CH1" Then
                optCH1WP.Value = varFillCombo!Warn_Page
                optCH1WE.Value = varFillCombo!Warn_Email
                optCH1HP.Value = varFillCombo!Halt_Page
                optCH1HE.Value = varFillCombo!Halt_Email
            End If
                
            'If Not IsNull(varFillCombo!Warn_Page) Then  = varFillCombo!Name
        End If
        
            
        
    End Sub
    Now when i'm stepping through the program n checking the GUI, the op1 one would set to true, then if opt2 was true, opt1 would be reset back to false, and opt2 set to true. But if opt3 was false then op2 would still be true. Then if opt4 was true then opt2 was reset back to false.

    Does anyone know why it does this?

    thank
    Does anyone know y it does this?
    Last edited by phimtau123; Jun 27th, 2007 at 01:39 PM.

  2. #2
    Frenzied Member
    Join Date
    Jun 2006
    Posts
    1,098

    Re: Option Button

    Option buttons are used to present choices where only one item from a group may be chosen. Use checkboxes instead.

  3. #3
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657

    Re: Option Button

    Use checkboxes rather than option buttons. With option buttons, the "true one" is exclusive within the group the contains the option buttons, which is why when one is set to true, all others in the group are set to false.
    "It's cold gin time again ..."

    Check out my website here.

  4. #4

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jun 2007
    Posts
    76

    Re: Option Button

    i am doing this in vb6.
    If i use the checked box, the value for check is 1, and the reference value i have in the database is either true or false. How would i go about setting this up?
    vb Code:
    1. Private Sub ListView1_DblClick()
    2.     If ListView1.ListItems.Count > 0 Then
    3.         varFillCombo.MoveFirst
    4.         x = ListView1.SelectedItem.Index
    5.         varFillCombo.Move (x - 1)
    6.         If varFillCombo!Chamber = "CH1" Then
    7.             If varFillCombo!warn_page = "True" Then
    8.                 chkopt1.Value = 1
    9.             Else
    10.                 chkopt1.Value = 0
    11.         End If
    12.            
    13.        
    14.     End If
    15. End Sub

    something like that for each of the box?

  6. #6

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Jun 2007
    Posts
    76

    Re: Option Button

    Thank you for the help

  8. #8
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: [Resolve] Option Button

    If we've helped you and you now have your answer, you can help us by pulling down the Thread Tools menu and clicking the Mark Thread Resolved button which will let everyone know that you have your answer.

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