?
Solved

Control Reference in a Subform from another Subform

Posted on 2011-02-26
7
Medium Priority
?
310 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 52

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
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Suggested Courses

839 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