Updating a query result in subform

  • Thread starter Thread starter John Doe
  • Start date Start date
J

John Doe

Hi All,

Using Access 2003 - I have a subform which is based on a query. The main
form contains a text field in which the user can enter search words. When
the user clicks on the 'Search' cmd button, an array is created containing
the search words and an SQL statement is constructed in which the WHERE
portion is a series of LIKE statements separated by OR. Each search word in
the array creates a new LIKE statement. Finally, the query upon which the
subform is based is deleted and recreated with the new SQL statement.

It all works fine and the new query works as expected when the main
form/subform is closed and reopened or when it is changed from Form View to
Design View and back to Form View again.

The problem is that I can't figure out how to get the subform to reload the
query upon which it is based after recreating the query (ie. at the end of
the OnClick event for the cmdSearch button). I've tried several versions
and combinations of 'Requery' but none seem to do the job, including a
simple DoCmd.Requery which (I thought) was supposed to reload the query.

Thank you very much for your help.

Penn
 
Got an answer if anyone is interested.

"After updating the recordsource with new SQL or query, try:
Me!Subform.Form.RecordSource = Me!Subform.Form.RecordSource"

This works perfectly.

Penn
 
Back
Top