I have a table that lists Departments and Passwords in SQL Server. I am creating a Userform UI so that users are able to view list, amend an entry or delete an entry.
I have made it look like this:
I managed to set up the ADODB connection when a user opens the form, it would automatically load the list using:
Private Sub Userform_Activate()
My rational is that I want a user to select from the list box, it would display the Department and Password in textbox1 and textbox2, respectively.
The user then can either Update the record or Delete the record. This would be a very straight-forward SQL operation.
What I am hitting a road block with at the moment is actually getting the data displayed in Textbox1 and Textbox2.
Code
Private Sub Select_Click()
If Me.ListBox1.Selected(i) Then
Me.TextBox1 = Me.ListBox1.List(i, 0)
Me.TextBox2 = Me.ListBox1.List(i, 1)
End If
End Sub
Any advise would be appreciated.
Furthermore, is my logic sound? Or is there a better way of doing things?
I know this is 2-in-1 question, but thanks!

Private Sub Select_Click()this looks like a separate procedure that you wrote. Tie the code to the on click event of the actual listbox. SoPrivate Sub Listbox1_Click()