FIlter form and subform an open form event

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • patriciashoe
    New Member
    • Feb 2008
    • 41

    #1

    FIlter form and subform an open form event

    Greeting All

    I have several public variables which I use to build a filter string that I would like to use when I open a form and several associated sub forms. I have set the value of the combo box on one of the subforms with this variable. I have not yet figured a way to have the update event code on the combo box run automatically, so I put the following code in the open statement of the main subform. Here is some current code:

    Me.Filter = "[trYear]='" & Me![Combo46] & "'"
    Me.FilterOn = True
    This code works and populates subform teacherresource s1

    Forms!schools1! enrollmentsub.F orm.Filter = "[year]='" & Me![Combo46] & "'"
    Forms![schools1]![enrollmentsub].Form.FilterOn = True



    This code which is pulled from the update event of the of the combo box located on the teacherresource s1 form and now placed in the open event of teacherresource s1 fails with the following message:
    Error 2455 invalid reference to the property form

    My question is how to get the combo box to run as the form opens so that all forms are filtered as if I had made the selection from the combo box manually. Thanks for any insight here.

    Patti
    Tags: ms, access, 2003
    Last edited by patriciashoe; Mar 20 '08, 06:36 PM. Reason: typos
  • patriciashoe
    New Member
    • Feb 2008
    • 41

    #2
    Sorry. my head uis turnig to mush today. Here is another example of the code that I misstated.

    Forms!schools1! enrollmentsub.F orm.Filter = "[year]='" & Me![Combo46] & "'"
    Forms![schools1]![enrollmentsub].Form.FilterOn = True


    The public variable has been placed in the combo box with the following code:

    Me![Combo46].Value = get_holdvar()

    Thanks
    Last edited by patriciashoe; Mar 20 '08, 07:30 PM. Reason: dupplicate

    Comment

    • patriciashoe
      New Member
      • Feb 2008
      • 41

      #3
      Finally got this to work by duplicating the code I had in the update event of the combo box to the got focus event of the same combo box. When I open the form and navigate to the subform the got focus event kicks in.

      Patti

      Comment

      Working...