Page 1 of 3 123 LastLast
Results 1 to 15 of 31
  1. #1
    Join Date
    Feb 2009
    Posts
    3

    Unanswered: Filter a subform from a main form combobox

    Hi,

    I'm trying to filter a subform datasheet based on a combobox in the mainform, however I cannot get it to work.

    After 2 days of trying, I thought I found a solution on the internet (http://allenbrowne.com/ser-28.html). I made a database exacly as in this example (as attached), however the result is not correct.

    Does anyone know a different way how to do this? Basically, the "filter subform" should just work as a normal filter on the subform.

    Thanks,
    Francis
    Attached Files Attached Files
    Last edited by Sceppi; 02-11-09 at 09:08.

  2. #2
    Join Date
    Apr 2004
    Location
    Kingsland, Georgia
    Posts
    231
    How about just putting this in the Afterupdate event of the combo box?
    I renamed the subform "Supplier" from "tblProductSupplier Subform"

    Code:
    Supplier.Form.Filter = "[SupplierID]= '" & cboShowSup & "'"
            Supplier.Form.FilterOn = True
    Should work for you.

  3. #3
    Join Date
    Feb 2009
    Posts
    3
    Hi,

    Thanks for the suggestion, however that gives me the error "object required". I think it doesn't work specifying the subform directly. I also tried referencing the subform by mentioning the main form first ...but that didn't work either. Any idea?

  4. #4
    Join Date
    Apr 2004
    Location
    Kingsland, Georgia
    Posts
    231
    Specifying the subform directly does work. Something's just missing. See the attached database.
    Attached Files Attached Files

  5. #5
    Join Date
    Feb 2009
    Posts
    3
    Indeed you are correct. Thanks man! Appreciate your help

  6. #6
    Join Date
    Nov 2011
    Posts
    5
    I have downloaded the example attached in the post above, which works. But I can't follow where "tblProductSupplier" has been renamed to "Supplier" every reference I can see, except in the code, lists the subform as "tblProductSupplier".
    Can anyone explain?

    Ian
    Newbie

    Quote Originally Posted by jmahaffie View Post
    How about just putting this in the Afterupdate event of the combo box?
    I renamed the subform "Supplier" from "tblProductSupplier Subform"

    Code:
    Supplier.Form.Filter = "[SupplierID]= '" & cboShowSup & "'"
            Supplier.Form.FilterOn = True
    Should work for you.

  7. #7
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Check that the name of the SubForm control, not the name of the Form object used as subform, is indeed "Supplier". The name of the control can be different from the name of the (sub)form itself. In such a case you must use the name of the control:
    Code:
    SubFormControlName.Form. etc...
    Have a nice day!

  8. #8
    Join Date
    Nov 2011
    Posts
    5
    Quote Originally Posted by Sinndho View Post
    Check that the name of the SubForm control, not the name of the Form object used as subform, is indeed "Supplier". The name of the control can be different from the name of the (sub)form itself. In such a case you must use the name of the control:
    Code:
    SubFormControlName.Form. etc...
    Thanks for your prompt reply, I have found it now, as you guessed, I was looking at the subform properties and not the control.

    Ian

  9. #9
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    You're welcome!
    Have a nice day!

  10. #10
    Join Date
    Jan 2013
    Posts
    4
    Quote Originally Posted by Sinndho View Post
    You're welcome!
    hi I'm trying to follow same steps as above but I'm having the following error
    compile error: "Invalid use of property"

    Private Sub cboShowSup_AfterUpdate()
    Project List.Form.Filter = "[PPM ID]= '" & cboShowSup & "'"
    Project List.Form.FilterOn = True
    End Sub
    Last edited by guzmanad; 01-22-13 at 13:59.

  11. #11
    Join Date
    Jan 2013
    Posts
    4
    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

  12. #12
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    What's Project List?
    Have a nice day!

  13. #13
    Join Date
    Jan 2013
    Posts
    4
    is the name of the control.

    I've attached the DB for your reference
    Attached Files Attached Files

  14. #14
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    The only procedure more or less similar to the one you previously posted is (in Form_Main):
    Code:
    Private Sub ComboProject_AfterUpdate()
        Projectdata.Form.Filter = "[PPM ID]= '" & ComboProject & "'"
        Projectdata.Form.FilterOn = True
    End Sub
    No cboShowSup: the name of the combo is ComboProject, no Project List: the name of the SubForm/SubReport control is ProjectData.

    There is no other reference to the Filter or FilterOn property anywhere in the database you posted.
    Have a nice day!

  15. #15
    Join Date
    Jan 2013
    Posts
    4
    is correct I changed the names in the expression from project list to project data en the name of the combo
    but is not working

    If you downloaded the file, you will see that the filter is not working

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •