G
Guest
Hello All,
I am having some severe difficulties trying to code a listbox. What I am
attempting to do is use a listbox to search a text field in a table. The
problem is that the listbox is looking for a numeric value in the field, and
not a text value. I need to have the code work so it will return a text
value. Below is part of the code that is giving me the problem. I know that
I have to insert two comas (') in the code but I always get syntax errors.
Any help would be greatly appreciated. Here is the code:
Private Function IncludeEmployeeName()
On Error GoTo ProcError
Dim varEmployee As Variant
Dim strTemp As String
For Each varEmployee In Me!lboEmployeeToInclude.ItemsSelected()
strTemp = strTemp & "[strEmpName] = " & _
Me!lboEmployeeToInclude.ItemData(varEmployee ) & " Or "
Next
If Len(strTemp ) > 0 Then
IncludeEmployeeName = "(" & Left$(strTemp , Len(strTemp ) - 4) & ")"
Else
IncludeEmployeeName = ""
End If
ExitProc:
Exit Function
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in IncludeEmployeeName Function..."
Resume ExitProc
End Function
Regards
I am having some severe difficulties trying to code a listbox. What I am
attempting to do is use a listbox to search a text field in a table. The
problem is that the listbox is looking for a numeric value in the field, and
not a text value. I need to have the code work so it will return a text
value. Below is part of the code that is giving me the problem. I know that
I have to insert two comas (') in the code but I always get syntax errors.
Any help would be greatly appreciated. Here is the code:
Private Function IncludeEmployeeName()
On Error GoTo ProcError
Dim varEmployee As Variant
Dim strTemp As String
For Each varEmployee In Me!lboEmployeeToInclude.ItemsSelected()
strTemp = strTemp & "[strEmpName] = " & _
Me!lboEmployeeToInclude.ItemData(varEmployee ) & " Or "
Next
If Len(strTemp ) > 0 Then
IncludeEmployeeName = "(" & Left$(strTemp , Len(strTemp ) - 4) & ")"
Else
IncludeEmployeeName = ""
End If
ExitProc:
Exit Function
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in IncludeEmployeeName Function..."
Resume ExitProc
End Function
Regards