Jim,
Don't know what your query looks like now, but I'll assume that you have a
criteria in the Query that uses a syntax similar to:
SELECT Field1, field2, field3
FROM yourTable
WHERE field3 = forms!formname.comboName
What I usually do when I want the user to be able to make multiple
selections is change the query to drop the WHERE clause (or at least that
portion that refers to the combo box).
I then use a listbox instead of a combo box, and pass the OpenReport method
a Where clause that I develop in code associated with a command button, which
might look like:
Private Sub cmd_Preview
dim varItem as Variant
dim strCriteria as string
'Instead of this, you could assume that if no items are
'selected, you want the entire report
if me.lst_YourListName.ItemsSelected.Count = 0 then
msgbox "Select an item from the list"
exit sub
endif
'This assumes the field you want to use to limit the result set is numeric
'and is the first column in the list.
For each varItem in me.lst_YourListName.ItemsSelected
strCriteria = "," & me.lst_YourListName.column(0, varItem)
Next
'strip off the leading character
strCriteria = mid(strCriteria, 2)
'Determine how many values in the list
Select Case Len(strCriteria) - Replace(strCriteria, ",", "")
Case 1
strCriteria = "[FieldName] = " & strCriteria
Case Else
strCriteria = "[FieldName] IN (" & strCriteria & ")"
End Select
docmd.OpenReport "reportname", acViewPreview,,strCriteria
End Sub
If the field you want to evaluate to limit the result set for your report is
a string, then you would need to wrap the value from your list in quotes, in
addition to adding the comma. It would look something like:
strCriteria = ",""" & me.lst_YourListName.column(0, varItem) & """"
----
HTH
Dale
JimP said:
I have report based upon a query that uses criteria selected from a combo box
drop-down of an unbound form. This works great but know I have a need to
allow multiple selections for the criteria sort of an "And/Or" situation.
Can it be done? Where do I start?
Thanks