• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 330
  • Last Modified:

Control Reference in a Subform from another Subform

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
HSdba
Asked:
HSdba
  • 4
  • 2
1 Solution
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
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
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
Can you upload the db  and explain exactly how to reproduce the problem ?

mx
0
 
Gustav BrockCIOCommented:
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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
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
 
HSdbaAuthor Commented:
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
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
Has this question been resolved?  Can we close the question ?

thx.mx
0
 
HSdbaAuthor Commented:
I resolved this on my own as stated.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now