Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2002

    Unanswered: how to filter a subform?

    HI, thank you for paying attention to my question. I just started to learn access. Many questions came to me, here is one of them.

    I was trying to apply a filter to a subform, but i failed.

    the main form is for order taking in a restaurant. the subform is to display menu items to waiters. Menu items include drink, appetizer, main course and dessert.

    I just want the subform display one of the above four categories at a time, so i applied filter to the subform.....

    when i opened the subform individually, it was fine. but after i integrated the subform into the main form, the filter always filter the main form, not the subform anymore.

    anybody could help out> I appreciate any feedback!

  2. #2
    Join Date
    Feb 2002
    A subform is linked to the form by child property. Use the child to link to your form, or search help for child

  3. #3
    Join Date
    Apr 2002
    Norwalk, CT
    I presume you have a "Category" field in your main form and a "Category" field in the subform. Code like:

    Private Sub Category_Exit
    Me.SubformName.Form.Filter = "Category = '" & Me.Category & "'"
    Me.SubformName.Form.FilterOn = true
    end sub

    In the Category field of the main form should do the trick. (This would be an event procedure in the OnExit event of the Category control.)


  4. #4
    Join Date
    Jul 2002
    Columbia, SC
    Here is some information found at

    Forms: Cannot ApplyFilter on SubForm

    (Q) I'm trying to restrict the records displayed in a subform by using ApplyFilter on it, but it doesn't work. What's the right way to do it?

    (A) The proper way is to change the Recordsource of the subform itself. Using ApplyFilter on the subform will change the main form itself.

    So either generate the SQL statement dynamically and assign that to the Recordsource of the subform using a syntax like

    strSQL="Select * from sometable where"
    strSQL=strSQL & " someID=" & me!IDonMainForm

    or use predefined queries and swap the assigned names using the same syntax as described above.

Posting Permissions

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