Assuming that you can't relate the Subform to the parent through the sub form Property Sheet, Data tab, Link Child Fields and Link Master Fields properties, then you will have to requery the specific instance of the subform. Please note that a subform may be open on one or more instances of a single parent form or even a variety of different parent forms so it is not enough to specify a requery of the form that is placed as a subform. You must specify the specific instance of the subform that needs to be requeried. Using a single saved querydef is not practical in an environment where the form may be open on more than one place at one time. You would then be better off to directly set the RecordSource sql string (2nd syntax below).
Assume the source object form is named 'frmSales' and the name you have given the subform control on a parent form is 'sfrmSales', you can requery the subform with code from the parent with the following syntax:
Me.sfrmSales.Form.Requery
Generally speaking, assigning the recordsource property will also force a requery. An alternate syntax would be:
Me.sfrmSales.Form.RecordSource = CurrentDb.QueryDefs("showsales").SQL = strsql
or
Me.sfrmSales.Form.RecordSource = strsql
or
Me.sfrmSales.Form.RecordSource = "showsales"
where 'showsales' is the name of the querydef
Ciao
Jürgen Welz
Edmonton AB Canada
[email protected]