Results 1 to 6 of 6
  1. #1
    Carloj is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2018
    Posts
    24

    Open formB and filter the suform on formB with formA

    I want to open a form with a filtered subform.

    The main form is called: FormMagazijnMenu
    The form with subform is called: FormMagazijn


    And the subform is called: SubFormMagazijn

    It needs to filter field "Magazijn_Stelling" in the subform to the value "61"

    I got this code so far but it's not working or giving any error.

    Code:
    Private Sub Bijschrift572_Click()
    
        DoCmd.OpenForm "FormMagazijn"
        
        With Forms(SubFormMagazijn)
        Me.Filter = "Magazijn_stelling = '61'"
          Me.FilterOn = True
        End With
    End Sub

  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
    "Me" always refers to the object containing the code, in this case presumably FormMagazijnMenu. Use the full reference to the subform:

    Forms Refer to Form and Subform properties and controls
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Carloj is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2018
    Posts
    24
    Im sorry, but im not understanding those i always get the error it can't find the field.

    Code:
    Private Sub Bijschrift572_Click()
    
        DoCmd.OpenForm "FormMagazijn"
        
        With Forms(SubFormMagazijn)
        Me.FormMagazijn!SubFormMagazijn.Filter = "Magazijn_stelling = '61'"
          Me.FormMagazijn!SubFormMagazijn.FilterOn = True
        End With
    End Sub

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You're still using Me. More like:

    Forms!FormMagazijn!SubFormMagazijn.Form.Filter = "Magazijn_stelling = '61'"
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Carloj is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2018
    Posts
    24
    Ahh now i get it. Thanks alot!
    This code works for me:

    Code:
        DoCmd.OpenForm "FormMagazijn"    
        With Forms(SubFormMagazijn)
            Forms!FormMagazijn!Sub848.Form.Filter = "Magazijn_stelling = '1'"
            Forms!FormMagazijn!Sub848.Form.FilterOn = True
        End With

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Happy to help!
    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. Replies: 3
    Last Post: 01-20-2014, 04:55 PM
  2. Replies: 17
    Last Post: 08-22-2013, 08:22 AM
  3. Filter form on open
    By Xarkath in forum Forms
    Replies: 8
    Last Post: 07-17-2013, 10:51 AM
  4. Open Form and filter subform
    By gg80 in forum Programming
    Replies: 3
    Last Post: 09-04-2011, 05:05 PM
  5. filter when i open form
    By Balen in forum Forms
    Replies: 0
    Last Post: 08-12-2010, 02:31 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