469,344 Members | 6,268 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,344 developers. It's quick & easy.

Filter a report

Hi everyone,
i am really stack!i need help
I have this report:"RequirementObjects_Report",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(RequirementObjects_Report)

Expand|Select|Wrap|Line Numbers
  1. Private Sub GenerateReport_Click()
  2. Dim var As Variant
  3. Dim strF As String 'holds report filter
  5.  If Me.ProductList.ItemsSelected.Count <> 0 Then
  6.          For Each var In Me.ProductList.ItemsSelected
  7.   strF = Me.ProductList.Column(0)
  8.    Next var
  9.   'now call the report with filter
  11. DoCmd.OpenReport "RequirementObjects_Report", acViewPreview, strF
  13. Else
  14. MsgBox "Please select some items from listbox."
  15. End If
  17. On Error GoTo Err_GenerateReport_Click
  19. Err_GenerateReport_Click:
  20.     MsgBox ("blabla")
  22. End Sub
Could someone give me some idea about it!
Do i need a sql statement??(though i think it is not needed since i am using strF as a filter)
Mar 12 '08 #1
1 1134
Scott Price
1,384 Expert 1GB
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.

Mar 12 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by CSDunn | last post: by
8 posts views Thread by dick | last post: by
1 post views Thread by lorirobn | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.