Filter a report

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Joelle
    New Member
    • Mar 2008
    • 6

    Filter a report

    Hi everyone,
    i am really stack!i need help
    I have this report:"Require mentObjects_Rep ort",i have also a multiselect listbox whicg contains a list of products.what i want to do is to filter the above report based on the products that i have selected.
    here is my code but it seems that my filter does not work properly and get the entire report back(Requiremen tObjects_Report )

    [CODE=vb]Private Sub GenerateReport_ Click()
    Dim var As Variant
    Dim strF As String 'holds report filter

    If Me.ProductList. ItemsSelected.C ount <> 0 Then
    For Each var In Me.ProductList. ItemsSelected
    strF = Me.ProductList. Column(0)
    Next var
    'now call the report with filter

    DoCmd.OpenRepor t "RequirementObj ects_Report", acViewPreview, strF

    Else
    MsgBox "Please select some items from listbox."
    End If

    On Error GoTo Err_GenerateRep ort_Click

    Err_GenerateRep ort_Click:
    MsgBox ("blabla")

    End Sub[/CODE]

    Could someone give me some idea about it!
    Do i need a sql statement??(tho ugh i think it is not needed since i am using strF as a filter)
  • Scott Price
    Recognized Expert Top Contributor
    • Jul 2007
    • 1384

    #2
    One thing that stands out is that you have provided for only one condition in your strF. Every time the For Each ... Next statement cycles, you are changing the value it contains without storing the value first. This will mean that your filter will only contain the last condition selected from your list-box.

    This link gives an example of how to capture the values from a multi-select list box.

    Regards,
    Scott

    Comment

    Working...