I just want to ask how can I add two additional multiselect listbox from the code below...
right now I only have "lsService" on this code and I want to add "lsCampus" & "lsCategory".
any help will be greatly appreciated... Jim
Dim MyDB As DAO.Database
Dim qdf As DAO.QueryDef
Dim i As Integer, strSQL As String
Dim strWhere As String, strIN As String
Dim flgAll As Boolean
Set MyDB = CurrentDb()
strSQL = "SELECT * FROM tblQtyPsychotropics"
For i = 0 To lsService.ListCount - 1
If lsService.Selected(i) Then
If lsService.Column(0, i) = "All" Then
flgAll = True
End If
strIN = strIN & "'" & lsService.Column(0, i) & "',"
End If
Next i
strWhere = " WHERE [service] in (" & Left(strIN, Len(strIN) - 1) & ")"
If Not flgAll Then
strSQL = strSQL & strWhere
End If
MyDB.QueryDefs.Delete "qryQuarterlyPsychotropics"
Set qdf = MyDB.CreateQueryDef("qryQuarterlyPsychotropics", strSQL)
DoCmd.OpenReport "qryQuarterlyPsychotropics", acPreview
right now I only have "lsService" on this code and I want to add "lsCampus" & "lsCategory".
any help will be greatly appreciated... Jim
Dim MyDB As DAO.Database
Dim qdf As DAO.QueryDef
Dim i As Integer, strSQL As String
Dim strWhere As String, strIN As String
Dim flgAll As Boolean
Set MyDB = CurrentDb()
strSQL = "SELECT * FROM tblQtyPsychotropics"
For i = 0 To lsService.ListCount - 1
If lsService.Selected(i) Then
If lsService.Column(0, i) = "All" Then
flgAll = True
End If
strIN = strIN & "'" & lsService.Column(0, i) & "',"
End If
Next i
strWhere = " WHERE [service] in (" & Left(strIN, Len(strIN) - 1) & ")"
If Not flgAll Then
strSQL = strSQL & strWhere
End If
MyDB.QueryDefs.Delete "qryQuarterlyPsychotropics"
Set qdf = MyDB.CreateQueryDef("qryQuarterlyPsychotropics", strSQL)
DoCmd.OpenReport "qryQuarterlyPsychotropics", acPreview