Referencing subform 2 (1 Viewer)

Dumferling

Member
Local time
Today, 12:23
Joined
Apr 28, 2020
Messages
102
I know there are multiple (thousands) of sites that deal with this issue but I can't get any of them to actually work. No matter how I reference a subform 2 I get an error.

Basically I have a main form (frmCContractBrowser), a subform (frmAmendmentsListsubfrm) and a sub-sub form of frmAmendmentsListsubfrm called frmCAmendmentssub. I am trying to get the sub subform to scroll to a selected record using Seltop when I click on a item in a list box in the subform. The issue I have right now (never used Seltop before so I am sure there are other issues I haven't got to yet) is to reference the sub sub form when I select an item from the listbox in the sub form. The code (about the 10th version) is:

Forms!frmCContractBrowser!frmCAmendmentsListsubfrm.Form!frmCAmendmentssub.Form!SelTop = 5

Access says it can't find the sub sub form "frmCAmendmentssub" . I understood that putting the .Form means it should read it as a form and not as a control. What am I doing wrong here.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 18:23
Joined
May 7, 2009
Messages
19,175
maybe try:

Forms!frmCContractBrowser!frmCAmendmentsListsubfrm!frmCAmendmentssub.Form.SelTop = 5
 

Dumferling

Member
Local time
Today, 12:23
Joined
Apr 28, 2020
Messages
102
maybe try:

Forms!frmCContractBrowser!frmCAmendmentsListsubfrm!frmCAmendmentssub.Form.SelTop = 5
Nope. Now looking for frmCAmendmentssub as a field.
 

cheekybuddha

AWF VIP
Local time
Today, 10:23
Joined
Jul 21, 2014
Messages
2,237
Basically I have a main form (frmCContractBrowser), a subform (frmAmendmentsListsubfrm) and a sub-sub form of frmAmendmentsListsubfrm called frmCAmendmentssub.

First, which form's code module are you running the code from?

Second, beware that you must refer to the subform control which, depending on how you added the subform, may be named differently (eg: 'Child0') from the form it uses as its SourceObject.

To find the name of the subform control click on its very edge in design view. Then check if there is a SourceObject property in the 'Data' tab of the properties sheet. If yes, and it contains the name of the form you're interested in, then check the Name property in the 'Other' tab. this is the name you will use in your code:

Code:
Forms.frmCContractBrowser.SubFormControlName1.Form.SubFormControlName2.Form.SelTop = 5

EDIT:
Oops! Took too long replying!
 

Users who are viewing this thread

Top Bottom