Pre-populate TextBox with targeted cell entries for each active row RRS feed

  • Question

  • Hi everyone,

    I have the following code:

    Private Sub CommandButton1_Click()
    Dim RowCount As Long
    Dim ctl As Control
        If Me.ComboBox1.Value = "" Then
            MsgBox "Please Select Employee Status.", vbExclamation, "Entry Form"
        End If
        If Me.ComboBox2.Value = "" Then
            MsgBox "Please Select Licensed Rep Status.", vbExclamation, "Entry Form"
        End If
        If Me.ComboBox3.Value = "" Then
            MsgBox "Please Select Language Preference.", vbExclamation, "Entry Form"
        End If
        If Me.ComboBox4.Value = "" Then
            MsgBox "Please Select Current Role Experience.", vbExclamation, "Entry Form"
        End If
        If Me.TextBox3.Value = "" Then
            MsgBox "Please Enter Post #.", vbExclamation, "Entry Form"
        End If
        If Me.TextBox4.Value = "" Then
            MsgBox "Please Enter Portfolio #.", vbExclamation, "Entry Form"
        End If
            RowCount = Worksheets("Info Request").Range("G" & Rows.Count).End(3)(2).Row
            With Worksheets("Info Request")
                .Cells(RowCount, 7).Value = Me.ComboBox4.Value
                .Cells(RowCount, 8).Value = Me.ComboBox1.Value
                .Cells(RowCount, 9).Value = Me.ComboBox2.Value
                .Cells(RowCount, 10).Value = Me.TextBox3.Value
                .Cells(RowCount, 11).Value = Me.TextBox4.Value
                .Cells(RowCount, 12).Value = Me.TextBox5.Value
                .Cells(RowCount, 13).Value = Me.ComboBox3.Value
            End With
        For Each ctl In Me.Controls
            If TypeName(ctl) = "TextBox" Or TypeName(ctl) = "ComboBox" Then
                ctl.Value = ""
            ElseIf TypeName(ctl) = "CheckBox" Then
                ctl.Value = False
            End If
        Next ctl
    End Sub
    Private Sub CommandButton2_Click()
        Unload Me
    End Sub
    Private Sub Userform_Initialize()
    Dim ActiveR As Long
    ActiveR = Worksheets("Info Request").Range("G" & Rows.Count).End(3)(2).Row
    With Worksheets("Info Request")
        TextBox1.Value = Cells(ActiveR, 1).Value
        TextBox2.Value = Cells(ActiveR, 2).Value
    End With
    With ComboBox1
        .AddItem "Full Time"
        .AddItem "Part Time"
    End With
    With ComboBox2
        .AddItem "MFDA"
        .AddItem "MFDA < 90 Days"
        .AddItem "IIROC"
    End With
    With ComboBox3
        .AddItem "English"
        .AddItem "French"
    End With
    With ComboBox4
        .AddItem "<3 Months"
        .AddItem "3 Months - 1 Year"
        .AddItem "1 Year - 4 Years"
        .AddItem "Over 4 Years"
    End With
    End Sub

    What I'm trying to get the userform "UnitEntryform" to do is populate TextBox1 and TextBox2 with the results in columns A and B of the template for each active row. Right now, the first entry the user makes is pre-populated with the corresponding results found in columns A and B in the appropriate TextBoxes. However, when the user press Save Employee so that they move to the next row, the TextBox1 and 2 does not show the results in A and B in the active row.

    Anyway I can have the results in columns A and B populated in TextBox 1 and 2 for the appropriate row? Thanks everyone!!
    Thursday, September 18, 2014 8:01 PM

All replies

  • Hi,

    Based on the code and description, we are not sure about the data of your workbook and how to troubleshoot. Would you mind sharing your sample *.xlsm file through OneDrive to help us understand and troubleshooting. You can remove all the private information from the file.

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, September 19, 2014 9:00 AM