refresh a control from an external form

On my app I have a form/subform that running Ok but, for the click of a button I need to open another form that adds new records to the table to which the subform  is bound.
It does dos, but the form/subform does not reflect the new entered records when I enter them. To do so, I must close and reopen the form/subform.

But I want to immediately update the subform. I have tried  the .repaint, .requery and .refresh methods but they o not work (repaint dose not repaint and requery/refresh do completely reload the form which is absolutely inconvenient. How can I just "refresh" the subform control from this external form?
João serras-pereiraAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Anders Ebro (Microsoft MVP)Microsoft DeveloperCommented:
In order for new records to appear, you MUST do a requery. But if it is only the subform, that has new records, you can choose to just requery that subform control.
If the code is being called from the master form itself it could be:

Open in new window

If its is being done from a completely different form:

Open in new window

Now if its a form in a form in a form...the syntax can quickly become quite cumbersome, and might stop working, if you later redesign.

Often times it is simpler to open the popup form in dialog mode (because this will halt the calling code) and then do the requery when the popup is closed (calling code resumes)
For example, on the main form
Public Sub cmd_add_record_click
  Docmd.Openform "addRecords",,,,,acDialog 'Code pauses here until dialog is closed
End Sub

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Gustav BrockCIOCommented:
Instead of running an append query, you may be able to open the RecordsetClone  of the subform, and directly add the new record:

Set rs = Forms!OtherForm!NameOfSubformControl.Form.RecordsetClone
    ' set field values

Open in new window

That should update the subform automatically.
Dale FyeOwner, Developing Solutions LLCCommented:
Anders missed the Form reference:





and in his second code snippet:



João serras-pereiraAuthor Commented:
Thanks! It immediately worked. I just had to leave the project for 3 hours, so could not respond quicker. Now I am stuck on other part of the form/subform arrangement... will come back to EE...
João serras-pereiraAuthor Commented:
oops... sorry I messed all other comments...
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.