Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populate combobox with array issue...

Status
Not open for further replies.

fiat2

Programmer
Nov 26, 2002
104
US
Using XL 2002

I'm populating the first combobox w/o any problems using an array.
Here is my prob:
When the first combobox is changed, I want to call a function. That function will determine which product description was selected. Based on that product description, I want to populate the second combo box.

I have a total of 30 comboboxes.

You can look at it as:
1a-1b
2a-2b

I want the change() of 1a to trigger population of 1b. The same goes for 2a....15a.

I am receiving Run-time error '381': Could not set the list propery. Invalid property array index.

How can I set the cboComp1 combobox by the returned value from the sub routine. This returned value would actually be an array?

Thanks



Code:
Private Sub Worksheet_Activate()
        
         'Define product families array
         pfam1 = Array("", "Comp1", _
                    "Comp2", _
                    "Comp3", _
                    "Comp4")
                    
         pfam2 = Array("", "Comp5", _
                    "Comp6", _
                    "Comp7", _
                    "Comp8")
                    
         pfam3 = Array("", "Comp9", _
                    "Comp10", _
                    "Comp11", _
                    "Comp12")
                    
         pfam4 = Array("", "Comp13", _
                    "Comp14", _
                    "Comp15", _
                    "Comp16")

    'Populate first combobox
    prodFam = Array("", "AI", "AI-3", "EZ-1", "C-I-28" )
    Sheet1.cboProdFam1.List = prodFam
    
End Sub

Public Sub cboProdFam1_Change()
        
        selectProdFam = cboProdFam1.Value
       
        determinePFSelection selectProdFam   
    'Error 381 - Invalid property array index             
        cboComp1.List = selectProdFam
            
End Sub

Public Sub cboProdFam2_Change()
        
        selectProdFam = cboProdFam2.Value
       
        determinePFSelection selectProdFam        
        cboComp2.List =  selectProdFam
            
End Sub
.
.
.'I have 15 different cboProdFamX combos
.

Public Sub determinePFSelection(x)

    Select Case x
                Case "AI"
                    y = pfam1 
                Case "AI-3"
                    y = pfam2 
                Case "EZ-1"
                    y = pfam3 
                Case "C-I-28"
                    y = pfam4                 
                Case Else
                    y = pfam1                 
            End Select
End Sub
 
selectProdFam isn't an array !

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Ok. good point.

Do you see what I am trying to do?

If so, can you provide information/guidance?
 
Perhaps you wanted to replace this:
cboComp1.List = selectProdFam
with this ?
cboComp1.List = y

Assumptions:
pfam1, .., pfam4, y are global variables.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
well, same error when assigning y to the combo control.

here is my variables declarations:
Code:
Option Explicit
        Dim y() As Variant
        Dim selectProdFam As Variant
        Dim pfam1() As Variant
        Dim pfam2() As Variant
        Dim pfam3() As Variant
        Dim pfam4() As Variant
In the code below, would the following code be the same
cboComp1.List = y
cboComp1.List = pfam1

if y = pfam1?

Code:
Public Sub cboProdFam1_Change()
        
        selectProdFam = cboProdFam1.Value
       
        determinePFSelection selectProdFam   
    'Error 381 - Invalid property array index             
        cboComp1.List = selectProdFam
            
End Sub

Public Sub determinePFSelection(x)

    Select Case x
                Case "AI"
                    y = pfam1 
.
.
.
End Sub

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top