If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Works, But Doesn't Filter
I have this code from Allen Browne It shows all of the records and won't
filter. This is for filtering a report from a Multi-Select List Box. The field is a text field. Any help appreciated. Thanks DS Private Sub Command5_Click() On Error GoTo Err_Handler Dim varItem As Variant Dim strWhere As String Dim strDescrip As String Dim lngLen As Long Dim strDelim As String Dim strDoc As String strDelim = """" . strDoc = "rptDeliveryByStreet" With Me.ListStreets For Each varItem In .ItemsSelected If Not IsNull(varItem) Then strWhere = strWhere & strDelim & .ItemData(varItem) & strDelim & "" strDescrip = strDescrip & """" & .Column(0, varItem) & """" End If Next End With If CurrentProject.AllReports(strDoc).IsLoaded Then DoCmd.Close acReport, strDoc End If DoCmd.OpenReport strDoc, acViewPreview, WhereCondition:=strWhere, OpenArgs:=strDescrip Exit_Handler: Exit Sub Err_Handler: If Err.Number 2501 Then 'Ignore "Report cancelled" error. MsgBox "Error " & Err.Number & " - " & Err.Description, , "cmdPreview_Click" End If Resume Exit_Handler End Sub |
#2
|
|||
|
|||
Works, But Doesn't Filter
You missed a bunch of his code from http://www.allenbrowne.com/ser-50.html.
This includes the comma separation between items and the lines that reference the field to compare against the selected items. -- Duane Hookom Microsoft Access MVP "DS" wrote: I have this code from Allen Browne It shows all of the records and won't filter. This is for filtering a report from a Multi-Select List Box. The field is a text field. Any help appreciated. Thanks DS Private Sub Command5_Click() On Error GoTo Err_Handler Dim varItem As Variant Dim strWhere As String Dim strDescrip As String Dim lngLen As Long Dim strDelim As String Dim strDoc As String strDelim = """" . strDoc = "rptDeliveryByStreet" With Me.ListStreets For Each varItem In .ItemsSelected If Not IsNull(varItem) Then strWhere = strWhere & strDelim & .ItemData(varItem) & strDelim & "" strDescrip = strDescrip & """" & .Column(0, varItem) & """" End If Next End With If CurrentProject.AllReports(strDoc).IsLoaded Then DoCmd.Close acReport, strDoc End If DoCmd.OpenReport strDoc, acViewPreview, WhereCondition:=strWhere, OpenArgs:=strDescrip Exit_Handler: Exit Sub Err_Handler: If Err.Number 2501 Then 'Ignore "Report cancelled" error. MsgBox "Error " & Err.Number & " - " & Err.Description, , "cmdPreview_Click" End If Resume Exit_Handler End Sub |
Thread Tools | |
Display Modes | |
|
|