Possible to set filter on subform from parent form before subform data loads

Posted by tbone on Stack Overflow See other posts from Stack Overflow or by tbone
Published on 2010-06-12T13:07:02Z Indexed on 2010/06/12 13:12 UTC
Read the original article Hit count: 220

Filed under:

I have frmParentForm with multiple controls used to build a filter for frmSubForm.

On frmParentForm_Load, I am doing (simplified example):

Me.sbfInvoice_List.Form.filter = "[created_on] >= #" & Me.RecentOrderDateCutoff & "#"
Me.sbfInvoice_List.Form.FilterOn = True

The problem is, on initial load, it seems the subform load is occurring first, so the entire table is loaded.

Is there a way (in a different event perhaps) to properly set the subform filter from the parent form so it is applied before the subform does its initial data load? (The subform can exist on its own, or as a child of many different parent forms (sometimes filtered, sometimes not), so I'd rather not put some complicated hack in the subform itself to accomplish this.)

© Stack Overflow or respective owner

Related posts about ms-access