The below code works as I want. However, sometimes the users input leading apostrophes in the merchante names and I need to clean these out of each name as the code loops through the listbox and addng to the where clause. That is, if the strArray(i) is the name *'Merhcanet'*, I need to get the of the two ' before using it in the where clause.
Private Function WhereLikeString() As String
'If there is more than one item in the listbox, then need to create like strings for each item
'in the list box as a parameter to the sql statement
Dim i As Integer
Dim strWhere As String
Dim strArray() As String
For i = 0 To lstMerchants.ListCount - 1
ReDim Preserve strArray(i)
strArray(i) = lstMerchants.ItemData(i)
strWhere = strWhere & "GLMerchant Like '" & strArray(i) & "' OR "
WhereLikeString = " AND " & Left(strWhere, Len(strWhere) - 4)