Filter SubForm

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zivon
    New Member
    • Aug 2007
    • 59

    Filter SubForm

    I have two forms:
    clients
    orders

    when they both open, when I change clients it automaticly filter the orders for that client.

    now I created a form which includes 2 sub forms inside it... (clients and orders)

    and it doesn't filter since there is no such form open...
    Forms![orders].Filter = "[CustomerID] = " & Me.[CustomerID]


    how do I filter a sub form ?
  • FishVal
    Recognized Expert Specialist
    • Jun 2007
    • 2656

    #2
    Originally posted by zivon
    I have two forms:
    clients
    orders

    when they both open, when I change clients it automaticly filter the orders for that client.

    now I created a form which includes 2 sub forms inside it... (clients and orders)

    and it doesn't filter since there is no such form open...
    Forms![orders].Filter = "[CustomerID] = " & Me.[CustomerID]


    how do I filter a sub form ?
    Hi, zivon.

    Subform form object could be referenced in the following way.
    [code=vb]
    Forms![MainForm]![orders].Filter = "[CustomerID] = " & Me.[CustomerID]
    [/code]

    Comment

    • questionit
      Contributor
      • Feb 2007
      • 553

      #3
      Hi Zivon

      The subform does not have to be open when you want to filter it.
      See an example how you can reference the subform from main form:

      [code=vb]
      Me![SubForm].Form.Filter = "[CustomerID] = " & Me.[CustomerID]
      [/code]

      If you are note in these forms:
      [code=vb]
      Forms![MainForm]![SubForm].Form.Filter = "[CustomerID] = " & Me.[CustomerID]
      [/code]

      This webpage would be of further help to you:
      http://www.mvps.org/access/forms/frm0031.htm

      Regards
      Qi


      Originally posted by zivon
      I have two forms:
      clients
      orders

      when they both open, when I change clients it automaticly filter the orders for that client.

      now I created a form which includes 2 sub forms inside it... (clients and orders)

      and it doesn't filter since there is no such form open...
      Forms![orders].Filter = "[CustomerID] = " & Me.[CustomerID]


      how do I filter a sub form ?

      Comment

      • zivon
        New Member
        • Aug 2007
        • 59

        #4
        thank you : )
        that worked perfect.

        Comment

        Working...