Multy select list box - syntax error

lcook1974

Registered User.
Local time
Today, 17:23
Joined
Dec 21, 2007
Messages
330
hi everyone!
Could you help me find where the syntax error? it's like needle in a haystack for me...

Code:
 Dim stDocName As String
    Dim varItem As Variant
    Dim strWhere As String
    For Each varItem In Me![lstEmployee].ItemsSelected
      strWhere = strWhere & "EmployeeID = '" _
      & Chr(39) & Me![lstEmployee].Column(0, varItem) & Chr(39) & "' Or "
    Next varItem
    strWhere = Left(strWhere, Len(strWhere) - 4) 'Remove the last " Or "
    DoCmd.OpenReport "rptOSR_Template", acViewPreview, , strWhere

Larry
 
Paul...your code is the best! :)

is there a way to have the query export to excel using the "IN()" where statement. I have no problems exporting the "entire" query to excel but I need the selected people to be able to export. The internal department needs excel to import into their DB.
 

Users who are viewing this thread

Back
Top Bottom