Update query results

victorh

Registered User.
Local time
Tomorrow, 00:56
Joined
Dec 14, 2005
Messages
14
Hello,

my problem is, I have a form with a sub-form that displays results of a certain query. Now, on the main form I have buttons that manipulate this query.

What I want is, after the SQL of this query has been changed, the sub-form to show updated query results based on the changed SQL. When I close and re-open the form, the sub-form shows the most recent query results, but I want this without having to close and re-open the form, how?

In the VBA code, I already the "Requery" method of the sub-form but I guess I need to do something with the querydef object, too....

Thanks in advance!

Victor
 
Hi Victor -

You should be able to modify the recordsource for the subform and then use the requery method. E.g.
Code:
   strSQL = "SELECT * FROM tblData WHERE ( <some conditions>) "
   Me.frmsubSubform.Form.RecordSource = strSQL 
   Me.frmsubSubform.Form.Requery

I have had problems in the past when there is an existing Parent/Child relationship between the form and subform. If you are manipulating the subform source, I suggest that you delete any Parent/Child relationship and see if that helps.

- g
 
Thanks,

as it looks now, that solved my problem!
 

Users who are viewing this thread

Back
Top Bottom