Subform requery vs. refresh

Dear experts,
I have a subform that I am trying to requery in the current event of another subform (at the same 'level') on the same form.

The requery works fine, however there is a calculated field on the other subform which is not updating. So I added a 'refresh' command, which seems to work, however NOT the first time the event fires.

The error I get is:
Error 2455: you entered an expression that has an invalid reference to the property Form/Report.

Code is below. I confirmed that it is the REFRESH line that invokes the error.

Any ideas?

Thanks!
If Me.Parent.sf1.SourceObject = "Vendor_QuickView" Then
    Me.Parent.sf2.requery
    Me.Parent.sf2.Form.Refresh
End If

Open in new window

terpsichoreAsked:
Who is Participating?
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.

crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
when you say the first time, do you mean when the form loads?

perhaps before the refresh, add:
On Error Resume Next

Open in new window

0
terpsichoreAuthor Commented:
I think that will work, just want to: a) understand why this happens; and b) see if that is the best workaround. thanks -
0
crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
when the form loads, the second subform probably isn't loaded yet when the first one runs the current event
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

terpsichoreAuthor Commented:
ok, but I'm wondering why the requery line immediately above it does not generate an error?
0
crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
Refresh gets all changes from other processes and users, in addition to showing changes to calculations  -- perhaps it just cannot do that yet.  I believe it also saves the record. Requery forces the form to reload.

I suspect the only time the error happens on refresh is when the form is first loaded ... this is common.
0

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
terpsichoreAuthor Commented:
ok - we will leave it at that - thank you!
0
Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
I'm big on Access letting it do it's own thing rather than trying to control things, So a trick to synching multiple subforms:

1. Place a hidden control on the main form.
2. Use this hidden control as part of the master link on the second subform control.
3. In the  OnCurrent event of the first subform, set the hidden control on the parent.

 This let's it all be automatic.   Main form changes, first subform changes, hidden control gets set, and second subform changes.

Jim.
0
terpsichoreAuthor Commented:
Great thinking.
0
crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
nice tip, Jim ~ I do that as well.  Nothing was mentioned about how the forms were synchronized -- perhaps I should have asked.

thank you and you're welcome, terpsichore
0
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.