Query parameters are not powerful enough to do that.
Instead use a text box on a form where the user can enter their list, and
use code to build the Filter for the form (or the WhereCondition for
OpenReport of whatever result you need to see.)
The code will use Split() to parse the items from the text box, and build a
WHERE string from the results.
This example applies to muliple keywords (or partial keywords) entered into
a text box, and matched to a field named Notes. Adapt it to your needs:
Private Sub txtKeywords_AfterUpdate()
Dim strWhere As String
Dim strWord As String
Dim varKeywords As Variant 'Array of keywords.
Dim i As Integer
Dim lngLen As Long
If Me.Dirty Then 'Save first.
Me.Dirty = False
End If
If IsNull(Me.txtKeywords) Then 'Show all if blank.
If Me.FilterOn Then
Me.FilterOn = False
End If
Else
varKeywords = Split(Me.txtKeywords, " ")
If UBound(varKeywords) >= 99 Then '99 words max.
MsgBox "Too many words."
Else
'Build up the Where string from the array.
For i = LBound(varKeywords) To UBound(varKeywords)
strWord = Trim$(varKeywords(i))
If strWord <> vbNullString Then
strWhere = strWhere & "([Notes] Like ""*" & strWord &
"*"") OR "
End If
Next
lngLen = Len(strWhere) - 4 'Without trailing " OR ".
If lngLen > 0 Then
Me.Filter = Left(strWhere, lngLen)
Me.FilterOn = True
Else
Me.FilterOn = False
End If
End If
End If
End Sub
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Reply to group, rather than allenbrowne at mvps dot org.
dapetrella said:
I want to search my db using a parameter query that will accept one or more
zip codes. A combo list is too cumbersome and I know the zip codes before
hand so I just need to input and search.
Thanks.