G
Guest
Hi There
Have used following code kindly supplied by "xRoachx" and it works a treat,
but need it to work with AfterUpate and not Exit, can't do this with (Cancel
As Integer) and if I remove (Cancel As Integer) the code dosen't work.
Any clues what I am doing wrong?
Private Sub ListBoxName_Exit(Cancel As Integer)
Dim strList as String
Dim intLen as Integer
Dim varSelectedRecord as Variant
If Me.ListBoxName.ItemsSelected.Count > 0 Then
For Each varSelectedRecord In ListBoxName.ItemsSelected
strList = strList + ListBoxName.Column(1, varSelectedRecord) & ","
Next varSelectedRecord
intLen = Len(strList)
[FieldName] = Left(strList, intLen - 1)
strList = ""
End If
End Sub
ListBoxName = The name of your list box
FieldName = The name of the field where you want to store the information
This code builds a string, seperated by commas. For example, say the list
box contains the words one, two, three, four, five and only one, two are
selected. "one, two" (without quotes) would be stored in the field.
Cheers Ross
Have used following code kindly supplied by "xRoachx" and it works a treat,
but need it to work with AfterUpate and not Exit, can't do this with (Cancel
As Integer) and if I remove (Cancel As Integer) the code dosen't work.
Any clues what I am doing wrong?
Private Sub ListBoxName_Exit(Cancel As Integer)
Dim strList as String
Dim intLen as Integer
Dim varSelectedRecord as Variant
If Me.ListBoxName.ItemsSelected.Count > 0 Then
For Each varSelectedRecord In ListBoxName.ItemsSelected
strList = strList + ListBoxName.Column(1, varSelectedRecord) & ","
Next varSelectedRecord
intLen = Len(strList)
[FieldName] = Left(strList, intLen - 1)
strList = ""
End If
End Sub
ListBoxName = The name of your list box
FieldName = The name of the field where you want to store the information
This code builds a string, seperated by commas. For example, say the list
box contains the words one, two, three, four, five and only one, two are
selected. "one, two" (without quotes) would be stored in the field.
Cheers Ross