Thanks for the response pbaldy. Much appreciated. I have put the following in my code. The only issue I face now is how to open the query with a "where" statement. See my code below:
Code:
Private Sub cmdOpenQuery_Click()
Dim strWhere As String
Dim ctl As Control
Dim varItem As Variant
'make sure a selection has been made
If Me.Location2.ItemsSelected.Count = 0 Then
MsgBox "Must select at least 1 machine location"
Exit Sub
End If
'add selected values to string
Set ctl = Me.Location2
For Each varItem In ctl.ItemsSelected
strWhere = strWhere & ctl.ItemData(varItem) & ","
'Use this line if your value is text
'strWhere = strWhere & "'" & ctl.ItemData(varItem) & "',"
Next varItem
'trim trailing comma
strWhere = Left(strWhere, Len(strWhere) - 1)
'open the report, restricted to the selected items
DoCmd.OpenQuery "aaDailyProductionComparison", acViewNormal, "Bay IN(" & strWhere & ")"
Exit_cmdOpenQuery_Click:
Exit Sub
Err_cmdOpenQuery_Click:
MsgBox Err.Description
Resume Exit_cmdOpenQuery_Click
End Sub
I believe my command to open the query is wrong. Everytime I try to run this code, I get the error, "Run-time error '13':" If I simply command the query to open, it obviously opens the query without any results.