I've created a Userform to enter (new) employee information, such as name, department, title, salary, etc. etc.
It contains a number of ComboBoxes and TextBoxes. All ComboBoxes contain lists of data from ranges.
My question: I want to be able to edit an existing employee's information using the same form, and have each Combo and Textbox show the information belonging to the employee when I select that name in the first ComboBox, for whom data was previously entered.
All data entered in this form is stored in a database (Table) in a separate sheet.
Other people have suggested I replace all other comboboxes with textboxes, but I don't want to do that. Using the Comboboxes helps guide the user and ensures consistency in data entry.
See below the code for the UserForm (called Admin). I think all it needs is some Caption statements for each ComboBox which then pulls the matching entry to the name selected from the cbonewemployee ComboBox.
![]()
Private Sub UserForm_Activate() txtStartDate.Value = Format(Date, "ddd d mmm yyyy") End Sub Private Sub SpinButton3_Change() txtStartDate.Value = Format(Date + SpinButton3.Value, "ddd d mmm yyyy") Label32.Caption = SpinButton3.Value & " day(s) from now" End Sub Private Sub SpinButton4_Change() txtCap.Value = SpinButton4.Value End Sub Private Sub cmdCancel1_Click() Unload Me End Sub Private Sub cmdOK1_Click() ActiveWorkbook.Sheets("Employees").Activate Range("A1").Select Do If IsEmpty(ActiveCell) = False Then ActiveCell.Offset(1, 0).Select End If Loop Until IsEmpty(ActiveCell) = True ActiveCell.Value = cbonewemployee.Value ActiveCell.Offset(0, 1).Value = cboDepartment.Value ActiveCell.Offset(0, 2).Value = cboReportto.Value ActiveCell.Offset(0, 14).Value = cboLevels.Value ActiveCell.Offset(0, 3).Value = txtStartDate.Value ActiveCell.Offset(0, 4).Value = txtExitDate.Value ActiveCell.Offset(0, 5).Value = cboTitles.Value ActiveCell.Offset(0, 9).Value = txtCap.Value ActiveCell.Offset(0, 10).Value = txtSal.Value ActiveCell.Offset(0, 12).Value = txtOTime.Value ActiveCell.Offset(0, 16).Value = cboAdmin.Value ActiveCell.Offset(0, 18).Value = TextBox4.Value If chkFull = True Then ActiveCell.Offset(0, 6).Value = "Yes" Else ActiveCell.Offset(0, 6).Value = "No" End If If chkPart = True Then ActiveCell.Offset(0, 7).Value = "Yes" Else ActiveCell.Offset(0, 7).Value = "No" If chkCons = True Then ActiveCell.Offset(0, 7).Value = "Yes" End If End If Range("A1").Select End Sub Private Sub fraLevel_Click() End Sub Private Sub UserForm_Initialize() With Worksheets("ADMIN") cboDepartment.List = .Range("F4", .Range("F" & Rows.Count).End(xlUp)).Value End With With Worksheets("Employees") cboAdmin.List = .Range("A2", .Range("A" & Rows.Count).End(xlUp)).Value End With With Worksheets("Employees") cboReportto.List = .Range("A2", .Range("A" & Rows.Count).End(xlUp)).Value End With With Worksheets("ADMIN") cboTitles.List = .Range("J4", .Range("J" & Rows.Count).End(xlUp)).Value End With With Worksheets("ADMIN") cboLevels.List = .Range("K4", .Range("K" & Rows.Count).End(xlUp)).Value End With With Worksheets("Employees") cbonewemployee.List = .Range("A2", .Range("A" & Rows.Count).End(xlUp)).Value End With End Sub Private Sub Frame2_Click() End Sub Private Sub cmdClearForm1_Click() Call UserForm_Initialize End Sub











LinkBack URL
About LinkBacks
Register To Reply
Bookmarks