Good evening folk
This one has me completely stumped,,, hopefully someone can help........
Userform is used to input new staff member... no issues
When the staff information has been entered the amount of training required is automatically allocated and an entry number allocated for each training, this entry number comes from the maximum already in the database. +1 etc.... i.e.,, if the current high number in database is 125 and if the job for the new staff requires 6 items of training then the first item number will be 126,, second 127 etc.
All the information is then copied to the bottom of the database
To update the training,,,, second Userform is opened,,,, select the staff member and all their current training is shown in a list box
Up to this Point there is no issues......... all the information is correct..........
To update the training,,, I double click on the required information and its moved to a range of textboxes and combo boxes.... this is where it is randomly going wrong
Sometimes the 'entry number is wrong,,,, it is not always he same entry,,, it is random,,, but when one is wrong,,, then the others that are wrong match the same number.....
e.g..... entry 2 when double clicked will the show as entry 25 in the textbox,,, entry number 5 will also show 25 and of course entry 25..... shows 25,,, however all the other textboxes and empty....
Next time I try it,,, it might be entry number 1 showing 135,,, entry 11 shows 135 etc. and entry 2, 5 and 25 are showing correctly
All the information on the spreadsheet is correct, the information in the list box is correct,, I have ensured the range is formatted to txt,,, but not matter how it is formatted,,, it’s the same....
Many thanks
JT
Private Sub lstLookup_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
'declare the variables
Dim ID As String
Dim i As Integer
Dim findvalue
framerecords.Visible = False: frameupdate.Visible = True
'get the select value from the listbox
For i = 0 To lstLookup.ListCount - 1
If lstLookup.Selected(i) = True Then
'set the listbox column
ID = lstLookup.List(i, 9)
End If
Next i
'finds the value in the range
Set findvalue = Sheet2.Range("L:L").Find(What:=ID, LookIn:=xlValues).Offset(0, -9)
'adds the values to the userform boxes
cNum = 10
For X = 1 To cNum
Me.Controls("update" & X).Value = findvalue.Offset(, X - 1).Text
Next
'disable the controls to make the user select an option
'error block
On Error GoTo 0
Exit Sub
End Sub
Bookmarks