Results 1 to 6 of 6
  1. #1
    Thomasso is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Nov 2016
    Location
    Czech Republic
    Posts
    250

    Question Need to filter a subform using a checkbox

    Hi,

    I am trying to filter my continuous subform using a checkbox (which is also placed within this subform).

    This works great when using the form alone, but it does not when I work with the subform within its parent form.
    Code:
    Private Sub checkFiltr_AfterUpdate()
        If Me.checkFiltr.Value = -1 Then
            DoCmd.ApplyFilter , "[PoptavkyAktivni]>0"
        Else
            Me.FilterOn = False
        End If
    End Sub
    What do I need to change in order for this to work?



    The main form is called frmTrychtyrNew and the subform is called frmTrychtyrNewFirmy.

    I should also mention that the main form has multiple tabs and in each tab, there is a subform.

    Thanks in advance!

    Best regards,
    Tomas

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Perhaps:
    Code:
    Private Sub checkFiltr_AfterUpdate()
        If Me.frmTrychtyrNew.frmTrychtyrNewFirmy.Form.checkFiltr.Value = -1 Then
            DoCmd.ApplyFilter , "[PoptavkyAktivni]>0"
        Else
            Me.FilterOn = False
        End If
    End Sub
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    Thomasso is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Nov 2016
    Location
    Czech Republic
    Posts
    250
    Actually, the condition is not the issue, it goes through correctly (confirmed by using MsgBox in both If and Else).

    The issue I have is with the [PoptavkyAktivni]>0... When the program runs, I get prompted to enter the parameter "PoptavkyAktivni" value. But only when working with the subform. If I open the subform alone, it works flawlessly.

  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,803
    "[PoptavkyAktivni]>0" is the name of a filter you have created? If not, then don't use that method because that's what it's for. Use
    Me.Filter = "filter here that is like WHERE condition but without WHERE"
    Me.FilterOn

    If that's it, I cannot explain why it would work one way and not the other because the apply filter method is for invoking an actual filter, which is usually a saved query. It shouldn't work at all IMO.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Have you tried to replace DoCmd.ApplyFilter , "[PoptavkyAktivni]>0" with

    Code:
    Me.Filter = "[PoptavkyAktivni]>0" 
    Me.FilterOn = True
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  6. #6
    Thomasso is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Nov 2016
    Location
    Czech Republic
    Posts
    250
    Thank you guys, that did the trick!

    Tomas

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

Similar Threads

  1. Replies: 2
    Last Post: 10-02-2018, 07:13 AM
  2. Use checkbox to filter data
    By acm007 in forum Access
    Replies: 5
    Last Post: 06-15-2018, 07:29 AM
  3. Checkbox filter
    By cbende2 in forum Access
    Replies: 2
    Last Post: 05-27-2015, 07:20 AM
  4. Checkbox Filter?
    By 82280zx in forum Forms
    Replies: 7
    Last Post: 03-14-2014, 10:35 AM
  5. Checkbox filter on a form
    By aletrindade in forum Access
    Replies: 1
    Last Post: 12-02-2009, 06:22 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