Error 2455

J

John Jewell

You entered an expression that has an invalid reference to the
property Form/Report...is the error I'm getting.

Basically, I have a form with two subforms. On the OnCurrent event of
one of the subforms, I have code, which is attempting to reference a
control on the other subform in this manner:

Me.Parent.form("frmBody").controls("txtBody").filename

I have also tried:
Forms![frmMain]![frmBody].Form![txtBody].FileName
Me.Parent.frmBody.Form.txtBody.FileName

....and I get the same error.

At any rate, that is the error I'm getting, all help is appreciated.
 
D

Dirk Goldgar

John Jewell said:
You entered an expression that has an invalid reference to the
property Form/Report...is the error I'm getting.

Basically, I have a form with two subforms. On the OnCurrent event of
one of the subforms, I have code, which is attempting to reference a
control on the other subform in this manner:

Me.Parent.form("frmBody").controls("txtBody").filename

I have also tried:
Forms![frmMain]![frmBody].Form![txtBody].FileName
Me.Parent.frmBody.Form.txtBody.FileName

...and I get the same error.

At any rate, that is the error I'm getting, all help is appreciated.


Is "frmBody" the name of the subform control (on the main form) that is
displaying the subform you want to reference?

Suppose you have three form objects, as displayed on the Forms tab of
the database window: frmMain, frmSub1, and frmSub2. Now suppose that
frmMain has two subform controls, one displaying frmSub1 and one
displaying frmSub2. Those subform controls *may* be named the same as
the forms they display (their Source Objects), or they may have
completely different names; for example, "Child1" and "Child2". If you
are writing code that will run on frmSub1, and you want to refer to the
control named "FileName" on frmSub2, you can only get to that by way of
a reference to the subform control that is displaying frmSub2. So that
reference must use the name of the subform control.

Suppose for example that the subform control has the same name as its
Source Object. Then you can refer to FileName like this:

Me.Parent!frmSub2.Form!FileName

or this:

Me.Parent!frmSub2.Form.Controls("FileName")

or even (I think) this:

Me.Parent!frmSub2!FileName

On the other hand, if the subform control has a different name -- say,
"Child2" -- then possible references would be:

Me.Parent!Child2.Form!FileName
Me.Parent!Child2.Form.Controls("FileName")
Me.Parent!Child2!FileName
 
V

Van T. Dinh

The normal syntax is:

Forms!MainForm!SubformControl2.Form.Control
("ControlOnSubform2")

Note that the SubformControl2 name may be different from
the name of the Form being used as the Subform2 (more
technically correct, being used as the SourceObject of the
SubformControl2).

There is another problem you may experience with your set-
up. We don't control how Subforms are being loaded so
Subform1 can possibly be loaded first and if your code is
executed before Subform2 is loaded, you may get some sort
of run-time errors.

HTH
Van T. Dinh
MVP (Access)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top