Consulting

Results 1 to 12 of 12

Thread: Solved: ComboBox Query

  1. #1
    VBAX Regular
    Joined
    Oct 2005
    Posts
    33
    Location

    Solved: ComboBox Query

    Derek here for your help again.

    I have a checkbox for "yes" and one for "No" answers. If the answer is yes, then there are further variables to be selected from a combobox. If the answer is no then the result must read "None", which is the first option in the list in the same ComboBox. How can I get the ComboBox to read "None" automatically if the "NO" checkbox is ticked?

    Derek

  2. #2
    VBAX Master Killian's Avatar
    Joined
    Nov 2004
    Location
    London
    Posts
    1,132
    Location
    use the checkbox_change event to set the index value for the combobox[VBA]If CheckBox1.Value = True Then
    ComboBox1.ListIndex = 0
    End If[/VBA]You might also want to set its Enabled property to False as well so users can't change it while No is ticked.
    K :-)

  3. #3
    VBAX Regular
    Joined
    Oct 2005
    Posts
    33
    Location
    Killian
    i know I will be proven to be doing something really stupid here but this is what I have used and it does not work. What adjustments should I make?

    Private Sub Checkbox11_Click()
    If CheckBox10.Value = True Then
    ComboBox1.ListIndex = 1
    End If
    End sub
    Thanks

    D

  4. #4
    VBAX Mentor ALe's Avatar
    Joined
    Aug 2005
    Location
    Milan
    Posts
    383
    Location
    hi derek,

    as far as i know the value of listindex of the first row of a list is 0.

  5. #5
    VBAX Mentor ALe's Avatar
    Joined
    Aug 2005
    Location
    Milan
    Posts
    383
    Location
    sorry I missed the code. It sholud be:

    [VBA] Private Sub Checkbox11_Click()
    If CheckBox10.Value = True Then
    ComboBox1.ListIndex = 1
    End If
    End sub [/VBA]

  6. #6
    VBAX Mentor ALe's Avatar
    Joined
    Aug 2005
    Location
    Milan
    Posts
    383
    Location
    sorry I missed the code. It sholud be:

    [VBA] Private Sub Checkbox11_Click()
    If CheckBox10.Value = True Then
    ComboBox1.ListIndex = 0
    End If
    End sub [/VBA]

  7. #7
    VBAX Regular
    Joined
    Oct 2005
    Posts
    33
    Location
    Ale/Killian
    This is not working. The answer I want is a the top of the list and is linked to cell A54. Is there an option to amend the list fill range to be just that cell if the "No" checkbox is ticked?

    Derek

  8. #8
    VBAX Mentor ALe's Avatar
    Joined
    Aug 2005
    Location
    Milan
    Posts
    383
    Location
    can you post a sample file?

  9. #9
    VBAX Regular
    Joined
    Oct 2005
    Posts
    33
    Location
    Here is the actual file. The comboBox is at the bottom of the page. I wish the display to return "None" when no is clicked to the question "Are you due Insurance Commission?"

  10. #10
    VBAX Mentor ALe's Avatar
    Joined
    Aug 2005
    Location
    Milan
    Posts
    383
    Location
    change the checkbox event this way
    [VBA] Private Sub Checkbox10_Click()
    Dim RgList As Range
    If CheckBox10.Value = True Then
    CheckBox9.Value = False
    Set RgList = Range(ComboBox1.ListFillRange)
    ComboBox1.Value = RgList.Cells(1).Value
    Set RgList = Nothing
    End If
    End Sub [/VBA]

  11. #11
    VBAX Regular
    Joined
    Oct 2005
    Posts
    33
    Location
    Superb, Ale. Thank You.

  12. #12
    VBAX Mentor ALe's Avatar
    Joined
    Aug 2005
    Location
    Milan
    Posts
    383
    Location
    Good. I'm happy to help. Bye

Posting Permissions

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