HI Guys! I really really need your help here and will really appreciate any answers.
I got a listbox in a form in MS Access that is set to simple for selecting multiple criterias.
I run a function, GetCriteria in the module. I want to call GetCriteria function in an sql query. In this function, GetNumber() is another function in the module which I called in GetCriteria().
Currently, these codes does not call the query outputFunction2 for the selected items. It only calls the item of the listbox regardless of if it being selected or not. I know I am able to replace GetNumber()-1 with varItem in GetCriteria Function. However,this will cause the last selected item to override the output of the getCriteria function for the other selected items and it will only run one query.
GetNumber() on the other hand, does not take into consideration the selected items..
I really dont know what to do.
Thank you.
Function GetCriteria()
With [Forms]![csrsrs]![ClientsList]
For Each VarItem In .ItemsSelected
If Not IsNull(VarItem) Then
StrWhere = .ItemData(GetNumber() - 1)
End If
Next VarItem
End With
GetCriteria = StrWhere
End Function
Function GetNumber()
GetNumber = LoopCounter
End Function
Public Sub Alpha()
LoopCounter = 1
While LoopCounter <= [Forms]![csrsrs]![ClientsList].ItemsSelected.Count
DoCmd.OpenQuery ("outputFunction2")
LoopCounter = LoopCounter + 1
Wend
End Sub