Results 1 to 7 of 7
  1. #1
    blueraincoat is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Mar 2011
    Location
    Shanghai,CHN
    Posts
    99

    Filter by comboBox value

    Hi all, I'm working a form with filter by comboBox, my purpose is that after the comboBox updated, the form will show related data. See attached picutre, the code i wrote is

    Private Sub Combo9_AfterUpdate()


    Form.filter = "RepairID = '" & Me.Combo9.Value & "'"
    Form.FilterOn = True

    End Sub

    There's something wrong, the filter did not work...
    Could somebody give me some suggestion?
    Thanks in advance

  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,640
    Is that on the same form or a subform? This

    Form.filter

    either needs to be

    Me.Filter

    or a reference to the subform's filter:

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

  3. #3
    blueraincoat is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Mar 2011
    Location
    Shanghai,CHN
    Posts
    99
    Thank you Paul.
    But it still did not work. The ComboBox is on the page header of the form.
    I upload a sample db,could you take a look and help find what's wrong?

  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,640
    The after update event is running an embedded macro, not the code. You may need to rebuild the form; it got corrupted on me when I tried to change it to the code.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    blueraincoat is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Mar 2011
    Location
    Shanghai,CHN
    Posts
    99
    Yes you are correct, it works after i change the property of the after update event.
    I don't when i changed that property...
    Thank you Paul.

  6. #6
    blueraincoat is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Mar 2011
    Location
    Shanghai,CHN
    Posts
    99
    I found the root cause, when I added the ComboBox, ACCESS let me make a decision, and that made the afterupdate event of the comboBox run a embeded marco.

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Glad we got it sorted out.
    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: 29
    Last Post: 08-16-2011, 05:52 PM
  2. Combobox to filter report
    By Sharkun in forum Reports
    Replies: 25
    Last Post: 02-03-2011, 05:05 PM
  3. Replies: 0
    Last Post: 08-24-2010, 06:38 PM
  4. Replies: 0
    Last Post: 12-16-2009, 01:14 PM
  5. Form Combobox filter
    By westcoastbmx in forum Forms
    Replies: 0
    Last Post: 10-20-2009, 11:27 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