Results 1 to 6 of 6
  1. #1
    Naded is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2018
    Posts
    5

    Filtering based on selection

    I will like to bypass the step of right clicking an item in a report to choose a text filter.

    I will like to filter a report by just clicking once on an item in the report and the report filters based on that selected item.


    Any help will be appreciated. Thx

  2. #2
    Naded is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2018
    Posts
    5
    This is what I have tried so far but have not to been successful.

    Private Sub Text123_Click()

    Dim prFilter As String
    prFilter = "[X]='Me.Text123.Value'"
    Me.Filter = prFilter

    DoCmd.OpenReport "ReportName", acViewReport
    Me.FilterOn = True
    End Sub

  3. #3
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    What type of filtering ? Something like filter by current selection ?

    I would use the OnClick property of the report control.
    To do it properly would need a function if you wanted it to work on any column on the report, without you coding each column individually.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  4. #4
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Try:
    Code:
    
    Dim prFilter As String
    prFilter = "[X]=""" & Me.Text123 &"""
    Me.Filter = prFilter
    
    
    DoCmd.OpenReport "ReportName", acViewReport
    Me.FilterOn = True
    And using a function as Minty suggested would be a very good idea, just think about how you want it to work; only apply the current selection filter vs. cumulative filtering. Also, you should probably add code to the double-click event of the controls to remove/reset the filter.

    Cheers,
    Vlad

  5. #5
    Naded is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2018
    Posts
    5
    Thanks. this is exactly what I was trying to achieve. I will take you recommendation to add a double-click to reset filter. Thanks again

  6. #6
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    You're welcome! Good luck with your project!
    Vlad

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

Similar Threads

  1. Replies: 8
    Last Post: 02-19-2016, 10:59 AM
  2. Replies: 2
    Last Post: 08-22-2014, 01:20 PM
  3. Replies: 24
    Last Post: 02-11-2014, 06:41 AM
  4. Replies: 8
    Last Post: 02-07-2013, 09:01 PM
  5. Filtering/Querying Records using Selection Screen
    By Jonny333 in forum Programming
    Replies: 1
    Last Post: 12-22-2011, 08:56 PM

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