Solved

Control Reference in a Subform from another Subform

Posted on 2011-02-26
7
272 Views
Last Modified: 2012-05-11
I have a Main Form with 2 Subforms (not nested) and from code in 1st subform I'm trying to reference a control in the 2nd subform in this manner:

Me.Parent!fsubForm2.Form!ctlText.Visible = False

I get a Runtime Error '2465' with a message stating can't find field.

Can Anyone Help Me ?

0
Comment
Question by:HSdba
  • 4
  • 2
7 Comments
 
LVL 75
ID: 34989979
The syntax is correct ...  but you can try this minor variation:


Me.Parent.fsubForm2.Form.ctlText.Visible = False

Are you *sure* that   ctlText  and fsubForm2 are the correct Names of these objects ?

mx
0
 
LVL 75
ID: 34989992
Can you upload the db  and explain exactly how to reproduce the problem ?

mx
0
 
LVL 49

Expert Comment

by:Gustav Brock
ID: 34990653
It may be because fsubForm2 is the name of your subform where it should be the name of the control on the parent form holding that subform.

/gustav
0
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
LVL 75
ID: 34991858
Actually, as long as they are the same  (which is the default), then it is still ok.  Only if they are different - does that matter ... which may be the case.

mx
0
 

Accepted Solution

by:
HSdba earned 0 total points
ID: 35000918
I guess I should have specified the form event where this error occured: The Error occurs in the Form_Current event of the continous subform when the 1st subform opens. I see now it's because the 2nd subform isn't open until the Main Form Is fully loaded.
I used the Form_Open event in 2nd sub-form to initialize my controls and trapped error in the  Form_Current event of 1st subform.
There is no Error in Form_Current event of 1st subform when changing  records in continous subform and I'm able to reference controls and do what ever I wanted.
0
 
LVL 75
ID: 35871352
Has this question been resolved?  Can we close the question ?

thx.mx
0
 

Author Closing Comment

by:HSdba
ID: 36472135
I resolved this on my own as stated.
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question