View Single Post
 
Old 03-31-2022, 11:32 AM
grNadpa grNadpa is offline Windows 10 Office 2016
Advanced Beginner
 
Join Date: Mar 2022
Posts: 46
grNadpa is on a distinguished road
Default how do I handle user input not in combobox

Fundamental question, I know. But I cannot find what I expect is a very simple answer.
I load the form in my combobox from an excel spreadsheet with no problem. And I populate my other textboxes when the user SELECTS from that list.
Code:
Private Sub ComboBoxNames_Change()
    sheetRow = ComboBoxNames.ListIndex + 2
    '   listIndex is base 0; first data in sheet is row 2
    With Sheets(sheetName)
        TextBoxName.Text = .Cells(sheetRow, 1).Value
        TextBoxAddress.Text = .Cells(sheetRow, 2).Value
        TextBoxCity.Text = .Cells(sheetRow, 3).Value
        If .Cells(sheetRow, 4).Value = isActive Then
            OptionButtonActive.Enabled = True
        Else
            OptionButtonInactive.Enabled = True
        End If
            
    End With
    CommandButtonAction.Caption = updateAction
    CommandButtonAction.Enabled = True
End Sub
I know that the ComboBoxNames.Listindex is 0 if I type something not in the list, but that doesn't help. I've tried substituting
Code:
ComboBoxNames_Exit() ...
but that doesn't populate my TextBoxes.
Reply With Quote