I'm at my wits end. I'm trying to get query results to match user selected in a multi select list box.
Here is what I have:
The list box is a list of statuses... (Below is an example)
A
B
C
D
E
The function
When A, B and D are selected, the debug output gives me: "A" Or "B" Or "D" (exactly what I want)
The criteria in the Query is: fun_ARStatus()
I have also tried: =fun_ARStatus()
When the query is run, I get NOTHING. If I put: "A" Or "B" Or "D" into the criteria MANUALLY, I get the correct query output!
What am I missing?!?! I have successfully used this method with other queries. The only difference here is I am using multiple selections.
Thanx in advance!
Joe
Here is what I have:
The list box is a list of statuses... (Below is an example)
A
B
C
D
E
The function
Code:
Function fun_ARStatus()
Dim frm As Form, ctl As Control
Dim varItm As Variant
Set frm = Forms!GenAlphaRoster
Set ctl = frm!ARStatus
PassARStatus = ""
'Load the selected items into a string
For Each varItm In ctl.ItemsSelected
PassARStatus = PassARStatus & """" & ctl.ItemData(varItm) & """" & " Or "
Next varItm
'Get rid of trailing " Or "
ARSLen = Len(PassARStatus)
PassARStatus = Left(PassARStatus, ARSLen - 4)
'Pass the final string to the query
fun_ARStatus = PassARStatus
Debug.Print fun_ARStatus
End Function
The criteria in the Query is: fun_ARStatus()
I have also tried: =fun_ARStatus()
When the query is run, I get NOTHING. If I put: "A" Or "B" Or "D" into the criteria MANUALLY, I get the correct query output!
What am I missing?!?! I have successfully used this method with other queries. The only difference here is I am using multiple selections.
Thanx in advance!
Joe