twoolls
03-12-2012, 06:20 AM
I have created a userform that has a multi-select listbox which is linked to a text form field. When the text field is selected the userform opens and shows the list but no matter what I do I can't seem to get the selected results to populate to the text form field.
The code for the userform/listbox is:
Private Sub UserForm_Initialize()
With List1
.AddItem "Allergic Reaction"
.AddItem "Amputation"
.AddItem "Anxiety-Stress"
.AddItem "Ballistic Injury"
.AddItem "Bites-Stings"
.AddItem "Bruising"
.AddItem "Crushing Injury"
.AddItem "Cuts"
.AddItem "Dehydration"
.AddItem "Dislocation"
.AddItem "Explosive Injury"
.AddItem "Fatality"
.AddItem "Fatigue"
.AddItem "Fracture"
.AddItem "High Pressure Injury"
.AddItem "Impact Injury"
.AddItem "Needlestick"
.AddItem "Over Pressure Injury"
.AddItem "Puncture Wound"
.AddItem "Sprain"
.AddItem "Strain"
.AddItem "Unconsciousness"
.AddItem "Whiplash"
End With
End Sub
Private Sub CmdMovetoRight_Click()
Dim i As Integer
If List1.ListIndex = -1 Then
Exit Sub
For i = List1.ListCount - 1 To 0 Step -1
If List1.Selected(i) = True Then
List2.AddItem List1.List(i)
List1.RemoveItem I
End If
Next i
End Sub
Private Sub CmdMoveToLeft_Click()
Dim i As Integer
If List2.ListIndex = -1 Then
Exit Sub
For i = List2.ListCount - 1 To 0 Step -1
If List2.Selected(i) = True Then
List1.AddItem List2.List(i)
List2.RemoveItem I
End If
Next i
End Sub
Private Sub CommandButton1_Click()
Unload Me
End Sub
No matter what I try to do to get the results from List2 in to the text form field it doesn't seem to work.
Can anyone please help me?
Thanks
The code for the userform/listbox is:
Private Sub UserForm_Initialize()
With List1
.AddItem "Allergic Reaction"
.AddItem "Amputation"
.AddItem "Anxiety-Stress"
.AddItem "Ballistic Injury"
.AddItem "Bites-Stings"
.AddItem "Bruising"
.AddItem "Crushing Injury"
.AddItem "Cuts"
.AddItem "Dehydration"
.AddItem "Dislocation"
.AddItem "Explosive Injury"
.AddItem "Fatality"
.AddItem "Fatigue"
.AddItem "Fracture"
.AddItem "High Pressure Injury"
.AddItem "Impact Injury"
.AddItem "Needlestick"
.AddItem "Over Pressure Injury"
.AddItem "Puncture Wound"
.AddItem "Sprain"
.AddItem "Strain"
.AddItem "Unconsciousness"
.AddItem "Whiplash"
End With
End Sub
Private Sub CmdMovetoRight_Click()
Dim i As Integer
If List1.ListIndex = -1 Then
Exit Sub
For i = List1.ListCount - 1 To 0 Step -1
If List1.Selected(i) = True Then
List2.AddItem List1.List(i)
List1.RemoveItem I
End If
Next i
End Sub
Private Sub CmdMoveToLeft_Click()
Dim i As Integer
If List2.ListIndex = -1 Then
Exit Sub
For i = List2.ListCount - 1 To 0 Step -1
If List2.Selected(i) = True Then
List1.AddItem List2.List(i)
List2.RemoveItem I
End If
Next i
End Sub
Private Sub CommandButton1_Click()
Unload Me
End Sub
No matter what I try to do to get the results from List2 in to the text form field it doesn't seem to work.
Can anyone please help me?
Thanks