Sub forms

Hi EE

I am having problems requery Sub forms. I have tried Forms![Form]![FormSub].Requery
Not sure what I am missing
Any help appreciated

chestera
chesteraAsked:
Who is Participating?

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

x
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.

IrogSintaCommented:
Where are you running the code that does the requery.  If it's in the subform itself, you would use:
Me.Requery

If it's in the main form that holds the subform, you would use:
Me.NameOfSubformControl.Form.Requery  

If it running on another form or module, you would use:
Forms!NameOfMainForm!NameOfSubformControl.Form.Requery

Ron

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
chesteraAuthor Commented:
IrogSinta

The main form holds the sub form

Me.frmLoanAdjustmentSubControl.form.Requery

When I run I get the message "Method or Data member not found". Do I some how have to link the two forms

Alan
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
Be SURE you are using the Name of the Sub Form Control on the Main form, not the name of the actual Form that is being used as a subform. This applies when the Source Object (actual Form object being used as the subform) ... and the Name property on the Subform Control are different.  Use what is in the Name Property.  By default they are the same, BUT ... that may not be the case here.

mx
IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

chesteraAuthor Commented:
DatabaseMX

The situation is I have the main form frmLoanAdjust and on that form a Sub form frmLoanAdjustSub
I have code behind a button on the main form which makes changes to the table linked to the subform. After making changes I would like the sub form to reflect those changes by a Requery. I am a bit confused between name of the subform control and the actual subform name.

Alan
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
In the image below, I have a Subform CONTROL named "sfDetails" on my main form. That Subform control is showing a form named "fOrderDetails", but if I want to refer to it from my main form, I'd use this syntax:

Me.sfDetails.Form.SomeControl

Note that when I have the focus on my Subform CONTROL, the Property Sheet box is showing the value "Subform/Subreport". This is critical to getting the right value for that control name.

Remember that a Subform CONTROL is just like any other control on a form, and you must first refer to that control before you can access any of it's properties, methods, etc.

Subform Control
Hamed NasrRetired IT ProfessionalCommented:
Alan,
I am a bit confused between name of the subform control and the actual subform name.

Assume you have 2 forms, named in navigation pane as:  mForm, and sForm

If you drage sForm into mForm, while open in design mode, you notice a control with it's type is SubFrom/SubReport with a name sForm.  This is the name of the actual subform, but access, by default names the control with the dragged from, which happens to be sForm.

You may change this name to any other name.
Looking into the properties sheet of the sForm Subform control Data Tab > Source Object: sForm

From here comes the confusion of using the same name.

The name of the actual subform is not used in referencing objects. The name you see is the name given to the SubForm object.
mForm is referred to as: Forms!mForm
sForm is referred to as: Forms!mForm!sForm.Form

Here sForm is the name of the Subform control that holds the actual form. The actual form name is not directly written, it is referred to by adding .Form

If you change the Subform control name after dragging sForm to main form, and rename it to mySubForm
Then:
sForm is referred to as: Forms!mForm!mySubForm.Form

Only .Form refers to the actual sForm in the navigation pane.

Hope that helps clearing confusion.
The actual subform name as it appears in navigation pane is not used in referring to actual subform or its controls, only .Form is added to the Subform control to allow access to the actual form and its controls.
chesteraAuthor Commented:
hnasr

Thank you very much that clears that problem up I now fully understand

Alan
chesteraAuthor Commented:
Scott McDaniel

Thank you Scott Excellent explanation

Alan
chesteraAuthor Commented:
Thank you every one for all your help
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
Seems to me the correct answer and syntax was the first post by Ron ... and some credit s/b given as such :-)
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Seems to me the correct answer and syntax was the first post by Ron ... and some credit s/b given as such :-)
Agreed.
chesteraAuthor Commented:
Scott McDaniel

Totaly agree my error can I rectify this

Alan
chesteraAuthor Commented:
irogsinta

My apologies for not giving you points or even thanking you for you support.
Bottom line I now have it working and have a better understanding of Sub forms

Alan
IrogSintaCommented:
No worries.  The other experts gave you detailed explanations that ultimately helped you work out your problem.  We're all here to help.

Ron
chesteraAuthor Commented:
IrogSinta

Thank you for your understanding Ron. I will be more careful in future

Alan
chesteraAuthor Commented:
Hi

I have been asked to close the question I thought I already did this by awarding points  but here goes again :)

Alan
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.