By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,187 Members | 1,594 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,187 IT Pros & Developers. It's quick & easy.

Filter a report

P: 6
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
Share this Question
Share on Google+
1 Reply

Scott Price
Expert 100+
P: 1,384
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.