Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2011

    Question Unanswered: At wit's end - trouble with ListBox

    I have inserted 4 ActiveX controls onto a worksheet - 2 OptionButtons and 2 ListBoxes. I've also written code so that when OptionButton1 is chosen, only ListBox1 is visible (and enabled) and when OptionButton2 is chosen, only ListBox2 is visible (and enabled). The ListBoxes appear and disappear as they should when using the OptionButtons, but I'm running into the following problem:

    1.ListBox1 works
    2.I click OptionButton2
    3.ListBox1 goes away and ListBox2 appears
    4.ListBox2 works
    5.I click OptionButton1
    6.ListBox2 goes away and ListBox1 appears
    7.ListBox1 now doesn't work
    8.I click OptionButton2
    9.ListBox1 goes away and ListBox2 appears
    10.Now ListBox2 doesn't work (I originally thought it was just a problem with ListBox1, but it was a problem with both)
    11.I click OptionButton1 and ListBoxes change again
    12.we're back to step 1, with ListBox1 working again.

    Here's the code behind it:

    Private Sub OptionButton1_Change()
         If OptionButton1.Value = True Then
              With ActiveSheet
                   .ListBox2.Visible = False
                   .ListBox2.Enabled = False
                   .ListBox1.Visible = True
                   .ListBox1.Enabled = True
                   .ListBox1.ListIndex = 0
              End With
                   With ActiveSheet
                        .ListBox1.Visible = False
                        .ListBox1.Enabled = False
                        .ListBox2.Visible = True
                        .ListBox2.Enabled = True
                        .ListBox2.ListIndex = 0
                   End With
         End If
    End Sub

    Private Sub ListBox1_Change()
         Select Case ListBox1.ListIndex
              Case 3
                   ActiveSheet.ComboBox2.Visible = True
                   ActiveSheet.ComboBox2.Enabled = True
                   If ActiveSheet.Range("O2").Value <> ActiveSheet.Range("O3").Value Then
                        Call LoadClients
                   End If
              Case Else
                   ActiveSheet.ComboBox2.Visible = False
                   ActiveSheet.ComboBox2.Enabled = False
         End Select
    End Sub
    Can anyone help me out? I (obviously) have no clue why this is happening.

  2. #2
    Join Date
    Feb 2011
    I did some further testing (using message boxes to show what had focus) and found the following:

    1.Clicked on OptionButton2 (with ListBox1 working) - ListBox1 lost focus and OptionButton2 got focus
    2.Clicked on OptionButton1 - OptionButton2 lost focus and OptionButton1 got it
    3.Clicked on ListBox1 - OptionButton1 lost focus, but ListBox1 didn't get it
    4.Clicked on OptionButton2 - OptionButton2 got focus, but nothing lost it
    Any thoughts?

Posting Permissions

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