Results 1 to 4 of 4
  1. #1
    alsoto is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2009
    Posts
    67

    Filtering An Already Filtered Form

    Hello,

    I am opening a form using a combo box to filter it:

    DoCmd.OpenForm "frmListProcDefaults", acNormal, , "ProcName = '" & Me.ProcName & "'"



    This works fine.

    I added the following on frmListProcDefaults to only show supplies starting with a particular letter entered in a text box (named Only):

    Private Sub Only_AfterUpdate()
    If IsNull(Me.Only) Then
    Me.FilterOn = False
    Else
    Me.Filter = "[Supplies] Like """ & Me.Only & "*" & """"
    Me.FilterOn = True
    End If
    End Sub

    It does only show supplies starting with the letter entered in the text box, but I lose the previous filter applied when form initially opened ("ProcName = '" & Me.ProcName & "'").

    I tried combining the 2 like this:

    Private Sub Only_AfterUpdate()
    If IsNull(Me.Only) Then
    Me.FilterOn = False
    Else
    Me.Filter = "[Supplies] Like """ & Me.Only & "*" & """" And "ProcName = '" & Me.ProcName & "'"
    Me.FilterOn = True
    End If
    End Sub

    but I get run-time error 13 Type mismatch.

    How do I filter a filtered form without losing original filter? Is the problem with this line:

    Me.Filter = "[Supplies] Like """ & Me.Only & "*" & """" And "ProcName = '" & Me.ProcName & "'"

    Please help.

    Thanks,
    Al

  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,652
    Yes, that line is wrong. If you don't have values with an apostrophe in them, this will be simpler:

    Me.Filter = "[Supplies] Like '" & Me.Only & "*' And ProcName = '" & Me.ProcName & "'"
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    alsoto is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2009
    Posts
    67

    Thank you

    Paul, As always, THANK YOU!!! Al

  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,652
    Happy to help Al!
    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. Report based of filtered data from a form
    By Fabdav in forum Reports
    Replies: 1
    Last Post: 09-15-2011, 05:28 AM
  2. Sorting a filtered form
    By mikeal_a@yahoo.com in forum Forms
    Replies: 1
    Last Post: 07-26-2011, 08:30 AM
  3. Sub form filtered by listbox
    By BorisGomel in forum Forms
    Replies: 3
    Last Post: 05-04-2011, 09:20 AM
  4. update query fon a filtered form HELP!
    By campanellisj in forum Queries
    Replies: 0
    Last Post: 11-12-2010, 09:08 AM
  5. Open form to filtered records
    By ducecoop in forum Access
    Replies: 3
    Last Post: 10-22-2010, 10:53 AM

Tags for this Thread

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