Combobox Not Populating With RowSource Set in The Control's Properties

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,564
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Would anyone be able to help isolate the possible cause of a particular problem I am having populating a combobox control on my userform?

1. From userform test_mr, the user clicks on an entry in listbox miss_nr
Rich (BB code):
Private Sub miss_rn_Click()

    Debug.Print Me.Name, ".miss_rn_Click() called"
    
    With miss_rn
        Debug.Print Me.Name, ".miss_rn_Click() ListIndex: " & .ListIndex & " (" & .List(.ListIndex) & ")"
        group_1.Show
    End With
    mbEvents = True
End Sub

2. This in turn opens up userform group_1

Rich (BB code):
Public Sub UserForm_Initialize()

    Dim l_mr As Long

    mbEvents = False
    Debug.Print df1
    
    l_mr = ws_vh.Range("B2") 'missing rental count in current schedule        'l_mr = 1
    Debug.Print l_mr
    Debug.Print agf
    
    'parking location of userform on desktop
    'group_1.Top = 300
    'group_1.Left = 500
    
    ws_vh.Range("A7:D7") = "" 'advanced filter criteria
    
    With TextBox1
        .Locked = False
        .BackColor = RGB(255, 255, 255)
        .Value = Format(0, "000000") 'new rental
        .SetFocus
        .SelStart = 0
        .SelLength = Len(.Text)
    End With
    If l_mr <> 1 Then uf2_eliminate.Visible = False
    If df1 < 4 Then uf2_eliminate.Visible = True
    Label34.Caption = "   Please enter valid permit number."
    proceed1.Enabled = True
    'uf2_eliminate.Visible = False
    submit1.Enabled = False
    delete1.Enabled = False
    edit1.Enabled = False
    amm_no.Value = 0
    amm_no.Locked = True
    date1.Value = Format(Date, "dd-mmm")
    date1.Locked = True
    ai_type.Value = ""
    ai_type.BackColor = RGB(0, 126, 167) 'celadon blue
    ai_function.BackColor = RGB(255, 255, 255)
    ai_function.Value = ""
    ai_function.Enabled = False
    ai_league.Value = ""
    ai_league.Enabled = False
    ai_calibre.Value = ""
    ai_calibre.Enabled = False
    ai_division.Value = ""
    ai_division.Enabled = False
    ai_event.Value = ""
    ai_event.Enabled = False
    
    MultiPage1.Value = 1
    MultiPage1.Visible = False
    MultiPage2.Value = 0
    Frame8.Visible = False
        
    group_1.Height = 124.5
    With TextBox1
        .BackColor = RGB(255, 255, 255)
        If l_mr > 0 Then 'this has come in from module 21 reporting missing rentals prior to workorder prep
            .Value = Format(test_mr.miss_rn.Value, "######")
            .BackColor = RGB(0, 168, 232)
            'ws_lists.Activate      'this made no difference
        Else
            .Value = Format(0, "######") 'new rental
        End If
        .SetFocus
        .SelStart = 0
        .SelLength = Len(.Text)
    End With
    mbEvents = True
End Sub

3. Since group_1 was referred to and opened from userform test_mr, a portion of group_1's fields are auto populated (textbox1). The user is then encouraged to press the "Process" commandbutton to proceed with additional data entry with group_1. (proceed1.click)

Rich (BB code):
Private Sub proceed1_Click()
    
    Dim ty As Boolean
    Dim rng_pn As Range
    Dim rnl As Long
    Dim pn As Long
    Dim pn_exist As Boolean
    Dim lrow As Long
    
    
    Set rng_pn = ws_rd.Range("A:A")
    
    'check if numeric
    ty = IsNumeric(TextBox1.Value)
    If ty = False Then 'not a number
        Me.Label34.Caption = "    Permit numbers are 5 or 6 digit numeric values."
        Me.Label34.BorderColor = vbRed
        With TextBox1
            .Value = Format(0, "000000")
            .SelStart = 0
            .SelLength = Len(.Text)
            .SetFocus
        End With
        Exit Sub
    End If
    
    'check length
    rnl = Len(TextBox1.Value)
    If rnl < 5 Or rnl > 6 Then
        Me.Label34.Caption = "    Permit numbers are 5 or 6 digit numeric values."
        Me.Label34.BorderColor = vbRed
        With TextBox1
            .Value = Format(0, "000000")
            .SetFocus
            .SelStart = 0
            .SelLength = Len(.Text)
        End With
        Exit Sub
    End If
    
    'check value is valid
    If TextBox1.Value < 68000 Then
        Me.Label34.Caption = "    Invalid permit range."
        Me.Label34.BorderColor = vbRed
        With TextBox1
            .Value = Format(0, "000000")
            .SelStart = 0
            .SelLength = Len(.Text)
            .SetFocus
        End With
        Exit Sub
    End If
    
    'Valid permit number
    pn = TextBox1.Value
    Me.Label34.Caption = "    Valid permit number."
    Me.Label34.BorderColor = RGB(50, 205, 50)
        
    Me.TextBox1.Locked = True
    Me.proceed1.Enabled = False
    Me.date1.Locked = False
    Me.ai_type.SetFocus
    
    'check if rental exists in database
    pn_exist = WorksheetFunction.CountIf(rng_pn, pn) > 0
    
    'rental not in database

    If pn_exist = False Then
        TextBox1.BackColor = RGB(0, 126, 167)
        Me.Label34.Caption = "    Entry does not exist in database."
        Me.Label34.BorderColor = vbRed
        new_group pn
        
    'rental is in database
    Else
        lrow = Application.Match(pn, rng_pn, 0)
        mbEvents = False
        With Me
            .Caption = "USER GROUP     [E" & lrow & "]"
            .TextBox1.BackColor = RGB(50, 205, 50)
            .TextBox1.Locked = True
            .Label34.Caption = "    Rental already exists in the database."
            .Label34.BorderColor = RGB(50, 205, 50)
            'If Not mbEvents Then Exit Sub
            'mbEvents = False
            .Frame8.Visible = True
            .amm_no.Value = ws_rd.Range("B" & lrow).Value
            .amm_no.Locked = False
            '.amm_no.Locked = True
            .date1.Value = Format(ws_rd.Range("AO" & lrow), "DD-MMM")
            .date1.Locked = True
            .ai_type.Value = ws_rd.Range("C" & lrow)
            .ai_type.Locked = True
         
            .Height = 745
            .Top = 25
        
            .edit1.Enabled = True
            .delete1.Enabled = True
            
        End With
    End If
    'mbEvents = True

End Sub

4. Since pn_exist is false, procedure new_group (Blue code) is executed.

Rich (BB code):
Sub new_group(ByRef pn As Long)
    Dim lrow_rd As Long
    Dim nrow_rd As Long

    lrow_rd = ws_rd.Cells(Rows.count, 1).End(xlUp).Row
    nrow_rd = lrow_rd + 1
    ws_vh.Range("E3") = 1
    With group_1
        .Top = 50
        .Caption = "USER GROUP     [N" & nrow_rd & "]"
        .Height = 252
        .ai_type.Locked = False
        Debug.Print ws_lists.Name
    End With
End Sub

5. With group_1 showing, textbox1 populated, the user is to select a value from combobox ai_type. The rowsource is coded into the control properties LISTS!A2:A10 . LISTS is a worksheet in the master workbook Sports17.xlsm. It is declared as a public worksheet ws_lists, and set = workbooks("Sports17.xlsm").worksheets("LISTS"). The debug line relates to the proper worksheet.

The combobox will not populate with the values in LISTS!A2:A10. It's just blank. If I use userform group_1 independent of steps 1 through 4 to enter new information (pn_exists=false), I have no problem with ai_type populating.

At this point in my project, the master workbook (Sports17.xlsm) is open, a source workbook (schedule.csv) is open and hidden, and a target workbook (Aug 11 2017 Data.xlsx) is also open.

Thank you all in advance for taking time to sort through this mess in an effort to help me.
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

Forum statistics

Threads
1,223,236
Messages
6,170,917
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top