Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update a subform based on a query

Status
Not open for further replies.

honeypot3

Instructor
Feb 8, 2005
77
GB
Hi there

I have a main form which which contains two subforms which are driven from tables. I also have another subform on the main form showing the results of a query which calculates the difference between values on the two tables. How can I make the subform based on the query automatically update when a value in one of the subform is changed rather than having to press SHIFT F9 all the time or close the form and re-open.

Thanks
 
You may play with the Requery method of the query based subform in the AfterUpdate event procedures of the 2 subforms.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi PHV

I have tried the requery option via macros (as my VB is not good) but when this is run it says it cannot find a field called the name of the query which operates the subform I need updating. How do you get requery to reference the actual query rather than a control?

Sandra
 
can u briefly explain how you did this as i am having basically the same trouble

thanks
 
Hi Neodj

I went into the AfterUpdate event for the subform that provided the data for the subform run from the query and then wrote the code:

Private Sub Form_AfterUpdate()
[Forms]![Name of main form]![Name of subform needing updating].Form.Requery
End Sub

Hope this helps, Sandra
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top