Results 1 to 9 of 9
  1. #1
    Super Moderator WebGenii's Avatar
    Join Date
    Jan 2001
    Location
    Redcliff, Alberta, Canada
    Posts
    4,066
    Thanks
    2
    Thanked 5 Times in 5 Posts

    Updating Combo Boxes on the Fly (Word 2000/2002)

    I am creating a Userform with 3 combo boxes. I wish the contents of the 2nd and 3rd combo boxes to update in response to the selection made in combo box 1. I have used the initialize event to load the selections for Combo Box 1, but am not finding the contents of Combo Box 2 updating when I use the Change or Click events to load selections.

    Any suggestions?
    [b]Catharine Richardson (WebGenii)
    WebGenii Home Page
    Moderator: Spreadsheets, Other MS Apps, Presentation Apps, Visual Basic for Apps, Windows Mobile

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Updating Combo Boxes on the Fly (Word 2000/2002)

    Use the AfterUpdate event of Combo Box 1 to populate Combo Box 2, and the AfterUpdate event of Combo Box 2 to populate Combo Box 3.

    If that doesn't help, could you be more specific? (A code snippet, for example)

  3. #3
    Super Moderator WebGenii's Avatar
    Join Date
    Jan 2001
    Location
    Redcliff, Alberta, Canada
    Posts
    4,066
    Thanks
    2
    Thanked 5 Times in 5 Posts

    Re: Updating Combo Boxes on the Fly (Word 2000/2002)

    I think my problem is occurring earlier, here is a snippet of my initialize code
    <pre>Private Sub UserForm_Initialize()
    comboSOPType.ColumnCount = 2
    comboSOPType.BoundColumn = 2
    comboSOPType.AddItem "Commonly Used Reagent Protocols"
    comboSOPType.List(0, 1) = 1
    comboSOPType.AddItem "Instrument Uses"
    comboSOPType.List(1, 1) = 2
    comboSOPType.AddItem "Lab Protocols"
    comboSOPType.List(2, 1) = 3
    </pre>

    I'm now suspecting I'm confusing my bound columns.....
    [b]Catharine Richardson (WebGenii)
    WebGenii Home Page
    Moderator: Spreadsheets, Other MS Apps, Presentation Apps, Visual Basic for Apps, Windows Mobile

  4. #4
    Super Moderator WebGenii's Avatar
    Join Date
    Jan 2001
    Location
    Redcliff, Alberta, Canada
    Posts
    4,066
    Thanks
    2
    Thanked 5 Times in 5 Posts

    Re: Updating Combo Boxes on the Fly (Word 2000/2002)

    Yup, that was the problem...
    [b]Catharine Richardson (WebGenii)
    WebGenii Home Page
    Moderator: Spreadsheets, Other MS Apps, Presentation Apps, Visual Basic for Apps, Windows Mobile

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Updating Combo Boxes on the Fly (Word 2000/2002)

    Why would you set ColumnCount and BoundColumn in code? You might as well do that in design mode.

    I'm afraid this doesn't tell me how the combo boxes relate to each other.

  6. #6
    Super Moderator WebGenii's Avatar
    Join Date
    Jan 2001
    Location
    Redcliff, Alberta, Canada
    Posts
    4,066
    Thanks
    2
    Thanked 5 Times in 5 Posts

    Re: Updating Combo Boxes on the Fly (Word 2000/2002)

    "You might as well do that in design mode." True, and that is what I'm doing now.

    this is what I have now, and it seems to work just fine.
    <pre>Private Sub UserForm_Initialize()
    Dim arrSOPType(3, 1)
    Dim i As Integer
    For i = 0 To 3
    arrSOPType(i, 0) = i + 1
    Next i

    arrSOPType(0, 1) = "Commonly Used Reagent Protocols"
    arrSOPType(1, 1) = "Instruments"
    arrSOPType(2, 1) = "Lab Protocols"
    arrSOPType(3, 1) = "Animal Care Protocols"
    comboSOPType.List() = arrSOPType

    End Sub
    Private Sub comboSOPType_Change()
    Dim arrSOPSubType As Variant
    Dim i As Integer
    Select Case comboSOPType.Value
    Case 1 'Commonly Used Reagent Protocols
    ReDim arrSOPSubType(4, 1)
    For i = 0 To 4
    arrSOPSubType(i, 0) = i + 1
    Next i
    arrSOPSubType(0, 1) = "Basic Solutions"
    arrSOPSubType(1, 1) = "General Buffers"
    arrSOPSubType(2, 1) = "Electrophoresis Buffers"
    arrSOPSubType(3, 1) = "Tissue Culture Medium"
    arrSOPSubType(4, 1) = "Decontamination Solutions"
    'load array
    comboSOPSubType.List() = arrSOPSubType

    Case 2 'Instruments
    ReDim arrSOPSubType(9, 1)
    For i = 0 To 9
    arrSOPSubType(i, 0) = i + 1
    Next i
    arrSOPSubType(0, 1) = "pH Meter"
    arrSOPSubType(1, 1) = "Phosphoimager"
    arrSOPSubType(2, 1) = "Microarray Chip Reader"
    arrSOPSubType(3, 1) = "Nanopure Water Polisher"
    arrSOPSubType(4, 1) = "J2 Centrifuge"
    arrSOPSubType(5, 1) = "Scintillation Counter"
    arrSOPSubType(6, 1) = "Gross Balance"
    arrSOPSubType(7, 1) = "Microbalance"
    arrSOPSubType(8, 1) = "HPLC"
    arrSOPSubType(9, 1) = "Phase Microscope"
    'load array
    comboSOPSubType.List() = arrSOPSubType

    Case 3 'Lab Protocols
    ReDim arrSOPSubType(4, 1)
    For i = 0 To 4
    arrSOPSubType(i, 0) = i + 1
    Next i
    arrSOPSubType(0, 1) = "Molecular Biology"
    arrSOPSubType(1, 1) = "Tissue Culture"
    arrSOPSubType(2, 1) = "Microscopy"
    arrSOPSubType(3, 1) = "Decontamination"
    arrSOPSubType(4, 1) = "Assays"
    'load array
    comboSOPSubType.List() = arrSOPSubType
    End Select

    End Sub
    </pre>

    [b]Catharine Richardson (WebGenii)
    WebGenii Home Page
    Moderator: Spreadsheets, Other MS Apps, Presentation Apps, Visual Basic for Apps, Windows Mobile

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Updating Combo Boxes on the Fly (Word 2000/2002)

    I'm glad you solved the problem.

  8. #8
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,853
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Updating Combo Boxes on the Fly (Word 2000/2002)

    If your code is working fine then is is no real cause to change it but I can't see why you need two columns of data in these combo boxes.

    You could simplify your code considerably by using a single column to populate your combo boxes and then using the combobox.ListIndex property to return the number (to a base 0) of the item selected in the list.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  9. #9
    Super Moderator WebGenii's Avatar
    Join Date
    Jan 2001
    Location
    Redcliff, Alberta, Canada
    Posts
    4,066
    Thanks
    2
    Thanked 5 Times in 5 Posts

    Re: Updating Combo Boxes on the Fly (Word 2000/2002)

    True - but ultimately, I'm using the numbers to "build" a Procedure number and having the numbers in from the beginning was a useful crutch.

    Cheers
    [b]Catharine Richardson (WebGenii)
    WebGenii Home Page
    Moderator: Spreadsheets, Other MS Apps, Presentation Apps, Visual Basic for Apps, Windows Mobile

Posting Permissions

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