Full Version: Requery/refresh A Subform On A Form, When Close Another Form
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
jgaskell
Hello,
I am struggling to refresh a subform.

I have a main form that is a popup, called frmBOC. I click a button on frmBOC to open another data entry form that fills in data on a subform (frmsubBOC), on frmBOC. This is also a popup form, called frmADD.
When I close frmADD I would like the subform to requery or refresh to show the new line.

I have tried all sorts of variations in the on activate, and on get focus events of frmBOC and none of them work. All I can do is use F5 or F9 to update the subform.

Thanks for any advice.



Alan_G
Hi

If you're closing frmADD from a command button then you can use the button's click event, or you could use the form's close event but wherever you want to run the code from it would be

CODE
Forms!frmBOC!frmsubBOC.Form.Requery


frmsubBOC in the code above would need to be the name of the subform control which may or may not be the same name as the form you're using as a subform
jgaskell
Thanks, that worked perfectly - I just didn't have the syntax quite right - I'm a bit rusty I'm afraid.
Great to have such a speedy answer.
Alan_G
yw.gif - glad you got it working. For future reference here's a link for the syntax for referring to subforms/reports
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.