Results 1 to 2 of 2
  1. #1
    BorisGomel is offline Competent Performer
    Windows Vista Access 2003
    Join Date
    Apr 2011
    Posts
    101

    Filter Report By list box

    Hi ,
    I have a report and listbox which I use to filter the report .The code is
    The porblem is that the report is opened up , but it doesn't show the Client Name..iT Says "error" on the report .I have checked everything and it seems everything correct , but it doesn't work .Please, look at the code,may be you point out something that I have overlloked.
    Thank you ,

    Regards


    Private Sub SumByClients_Click()
    Dim stDocName As String
    Dim Criteria As String
    Dim i As Variant
    stDocName = "SUMCHECKSPTINTEDQB2011"


    Criteria = ""
    For Each i In Me![List27].ItemsSelected
    If Criteria <> "" Then
    Criteria = Criteria & " OR "
    End If
    Criteria = Criteria & "[ClientName]='" _
    & Me![List27].ItemData(i) & "'"
    Next i

    DoCmd.OpenReport stDocName, acPreview, , Criteria
    Me.Filter = Criteria
    Me.FilterOn = True

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Add this line right before the OpenReport line:

    Debug.Print Criteria

    and run the code. That will print the finished criteria out to the VBA Immediate window. If you don't see the problem, post the result here. I assume the report opens normally if you open it directly from the database window?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Filter List box using text box
    By oakoen in forum Forms
    Replies: 3
    Last Post: 12-13-2010, 05:00 PM
  2. Filter available values in a drop down list
    By petitmorsalin in forum Access
    Replies: 1
    Last Post: 12-13-2010, 09:39 AM
  3. Replies: 1
    Last Post: 11-23-2010, 01:30 PM
  4. How to Filter Report
    By mikel in forum Reports
    Replies: 2
    Last Post: 08-28-2009, 10:11 AM
  5. Replies: 1
    Last Post: 03-01-2009, 09:53 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums