Good afternoon,
I have a saved Access 2010 query that I use in a report. The query has one parameter entered in the criteria section:
[Township]
There are multiple townships that I need to gather in a list box (i.e. "Bloom" OR "Bremen" OR "West")
I wrote a VBA procedure to gather the townships from the list box into a string with these values, no problem.
Question: How do I get the string value with the multiple townships into the Saved Query in Access so my report can print with those parameters?
I have researched this for days and this is my first post on dBforums. Any help would be greatly appreciated.
Here is the code I have so far. I took out my lame attempts at passing the form's parameter to the criteria in the query.
It does reference the query before the report prints, but the query still asks for [Township] to be manually entered by end-user.
Private Sub Command12_Click()
Dim varItem As Variant
Dim strSelected As String
For Each varItem In Me!TownshipCriteria.ItemsSelected
If strSelected <> "" Then
strSelected = strSelected & " OR "
End If
strSelected = strSelected & "'" & Me!TownshipCriteria.ItemData(varItem) & "'"
Next varItem
Debug.Print strSelected
DoCmd.OpenReport "rpt-AOandBOR Results", acViewPreview, "qry-ASSESSOR_BOARD-DATA"
End Sub
Thank you in advance for any help.
Fondly,
Tanya S.:)
I have a saved Access 2010 query that I use in a report. The query has one parameter entered in the criteria section:
[Township]
There are multiple townships that I need to gather in a list box (i.e. "Bloom" OR "Bremen" OR "West")
I wrote a VBA procedure to gather the townships from the list box into a string with these values, no problem.
Question: How do I get the string value with the multiple townships into the Saved Query in Access so my report can print with those parameters?
I have researched this for days and this is my first post on dBforums. Any help would be greatly appreciated.
Here is the code I have so far. I took out my lame attempts at passing the form's parameter to the criteria in the query.
It does reference the query before the report prints, but the query still asks for [Township] to be manually entered by end-user.
Private Sub Command12_Click()
Dim varItem As Variant
Dim strSelected As String
For Each varItem In Me!TownshipCriteria.ItemsSelected
If strSelected <> "" Then
strSelected = strSelected & " OR "
End If
strSelected = strSelected & "'" & Me!TownshipCriteria.ItemData(varItem) & "'"
Next varItem
Debug.Print strSelected
DoCmd.OpenReport "rpt-AOandBOR Results", acViewPreview, "qry-ASSESSOR_BOARD-DATA"
End Sub
Thank you in advance for any help.
Fondly,
Tanya S.:)