Sub forms

chestera
chestera used Ask the Experts™
on
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
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
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

Author

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 / Application Developer
Top Expert 2007

Commented:
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
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

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
Most Valuable Expert 2012
Top Expert 2014
Commented:
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 Professional

Commented:
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.

Author

Commented:
hnasr

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

Alan

Author

Commented:
Scott McDaniel

Thank you Scott Excellent explanation

Alan

Author

Commented:
Thank you every one for all your help
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Application Developer
Top Expert 2007
Commented:
Seems to me the correct answer and syntax was the first post by Ron ... and some credit s/b given as such :-)
Most Valuable Expert 2012
Top Expert 2014

Commented:
Seems to me the correct answer and syntax was the first post by Ron ... and some credit s/b given as such :-)
Agreed.

Author

Commented:
Scott McDaniel

Totaly agree my error can I rectify this

Alan

Author

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
No worries.  The other experts gave you detailed explanations that ultimately helped you work out your problem.  We're all here to help.

Ron

Author

Commented:
IrogSinta

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

Alan

Author

Commented:
Hi

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

Alan

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial