I have a code, that is giving me a "Compile Error: Variable not defined". And it's highlighting "itm" in the code. I'm not familiar with VB, can someone tell me what I need to change?
Function NameList() As String
NameList = "("
For Each Itm In lstNames.ItemsSelected
NameList = ListNames & Chr(34) & lstNames.ItemData(Itm) & Chr(34) & ", "
Next
NameList = Left(NameList, Len(NameList) - 2) & ""
If Len(NameList) = 2 Then
NameList = ""
Else
NameList = "Employee_Name In " & NameList
End If
End Function
Thanks for your help.
CindiN
Function NameList() As String
NameList = "("
For Each Itm In lstNames.ItemsSelected
NameList = ListNames & Chr(34) & lstNames.ItemData(Itm) & Chr(34) & ", "
Next
NameList = Left(NameList, Len(NameList) - 2) & ""
If Len(NameList) = 2 Then
NameList = ""
Else
NameList = "Employee_Name In " & NameList
End If
End Function
Thanks for your help.
CindiN