I am having a few issues with a userform attached. I would first like to thank Roy UK for the link to the VB and website http://www.excel-it.com/vba_examples.htm this has helped me out no end but I have a few issues that I have tried to solve but have come up against walls all over the place.
1. ListBox1 – if there is any more then 1 record found then I keep getting errors unless I have remove .TextBox10.Value = ListBox1.List(R, 9) upwards.
Private Sub ListBox1_Click()
If Me.ListBox1.ListIndex = -1 Then 'not selected
MsgBox " No selection made"
ElseIf Me.ListBox1.ListIndex >= 1 Then 'User has selected
R = Me.ListBox1.ListIndex
With Me
.TextBox1.Value = ListBox1.List(R, 0)
.TextBox2.Value = ListBox1.List(R, 1)
.TextBox3.Value = ListBox1.List(R, 2)
.TextBox4.Value = ListBox1.List(R, 3)
.TextBox5.Value = ListBox1.List(R, 4)
.TextBox6.Value = ListBox1.List(R, 5)
.TextBox7.Value = ListBox1.List(R, 6)
.TextBox8.Value = ListBox1.List(R, 7)
.TextBox9.Value = ListBox1.List(R, 8)
.TextBox10.Value = ListBox1.List(R, 9)
.TextBox11.Value = ListBox1.List(R, 10)
.TextBox12.Value = ListBox1.List(R, 11)
.TextBox13.Value = ListBox1.List(R, 12)
.cmbDelete.Enabled = True 'allow record deletion
.cmbAdd.Enabled = False 'don't want duplicate
End With
End If
End Sub
2. After removing .TextBox10.Value = ListBox1.List(R, 9) upwards I then get the following issues.
a. It only deletes the record at the top of the list and not the one that is selected
b. How to make the ListBox columns narrower.
c. What code is needed to clear the ListBox.
I would appreciate all the help that anyone can give me.
Bookmarks