Report Filtering

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • williamson1979
    New Member
    • Feb 2019
    • 174

    Report Filtering

    Currently I have a report created from a query with a filter based on a single unbound listbox which is working. I tried to add a second unbound listbox for additional filtering but it is not functioning - no errors just literally seems to do nothing. The code that does nothing is a replica of the posted working code with exception of the control names. Any suggestions would be appreciated. Thanks
    Code:
    'Private Sub listbox_AfterUpdate()
    '      If listbox= "ChoiceA" Then
    '        DoCmd.SetFilter WhereCondition:="[txtcontrolname] Like ""ChoiceA*"""
    '      ElseIf listbox= "ChoiceB" Then
    '        DoCmd.SetFilter WhereCondition:="[txtcontrolname] Like ""ChoiceB*"""
    '      ElseIf listbox= "ChoiceC" Then
    '        DoCmd.SetFilter WhereCondition:="[txtcontrolname] Like ""ChoiceC*"""
    '      ElseIf listbox= "ChoiceD" Then
    '        DoCmd.SetFilter WhereCondition:="[txtcontrolname] Like ""ChoiceD*"""
    '      Else
    '        DoCmd.SetFilter WhereCondition:="[txtcontrolname] Like ""*"""
    '    End If
    'End Sub
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32645

    #2
    Two tips :
    1. Instead of using the DoCmd.SetFilter to set the filtering of your Report, use the .Filter & .FilterOn properties of the Report itself.
    2. If you want the Report to recognise two separate controls for filtering then you should create a string value that does that and then allpy it. In very rough format that would look like :
      Code:
      ([FieldA]='Value A') AND ([FieldB]='Value B')
      You'd obviously need to build up the string based on the values of your filtering Controls.

    Comment

    Working...