Link to home
Create AccountLog in
Avatar of chestera
chestera

asked on

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
ASKER CERTIFIED SOLUTION
Avatar of IrogSinta
IrogSinta
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of chestera
chestera

ASKER

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
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
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
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
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.
hnasr

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

Alan
Scott McDaniel

Thank you Scott Excellent explanation

Alan
Thank you every one for all your help
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Seems to me the correct answer and syntax was the first post by Ron ... and some credit s/b given as such :-)
Agreed.
Scott McDaniel

Totaly agree my error can I rectify this

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

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

Alan
Hi

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

Alan