子表单引用引发错误2455:您输入的表达式对属性Form/Report的引用无效 [英] Subform reference throws Error 2455: You entered an expression that has an invalid reference to the property Form/Report

查看:491
本文介绍了子表单引用引发错误2455:您输入的表达式对属性Form/Report的引用无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

昨天,一个对我很长时间有效的表单/子表单突然开始抛出Error 2455: You entered an expression that has an invalid reference to the property Form/Report.

Yesterday, a form/subform that worked well for me for a long time suddenly started throwing Error 2455: You entered an expression that has an invalid reference to the property Form/Report.

以下是我对问题的诊断.感觉像个虫子.

Below is my diagnosis of the problem. It feels like a bug.

我的问题是:你们中有没有人见过这个?如果您有兴趣,可以尝试重现问题,让我知道您的发现吗?

My question is: Have any of you ever seen this? If you are interested, could you try to duplicate the problem, and let me know what you find?

问题:

  • 我有一个完全独立运行的表单,为每个子表单设置记录源
  • 但是将表单放入子表单控件时失败,尝试设置SubForm.Form.RecordSource属性时,每个子表单都会引发错误2455(但同样,仅当表单本身是子窗体)
  • I had a form that worked perfectly standalone, setting recordsources for each of its subforms
  • But the form failed when it was put in a subform control, throwing error 2455 for every subform when trying to set the SubForm.Form.RecordSource property (but again, only when the form itself was a subform)

经过大量实验,我将其范围缩小至:

After lots of experimentation, I narrowed it down to this:

  1. SubForm控件太短,无法显示表单的详细信息"部分.只有标题是可见的.
  2. 由于表单的详细信息不可见,因此,默默访问禁用表单下的所有子表单!
  1. The SubForm control was too short to show the form's Detail section. Only the Header was visible.
  2. Since the form's detail was not visible, Access silently disabled all of the subforms under the form!!!

我的解决方法:始终确保在SubForm控件中至少可以看到表单的详细信息"部分的一部分.要么

My Workaround: Always ensure that at least part of the form's Detail section is visible in the SubForm control. Either:

  • 增加SubForm控件的高度
  • 将控件从表格标题移到详细信息,并使标题更短或不可见,因此仅显示详细信息.

您可以重复此操作吗?,这很奇怪,所以我想对此问题进行一些独立确认.因此,如果您有空的话,请尝试以下步骤:

Can you duplicate this? This is weird, so I would like some independent confirmation of this problem. So, please, if you have a little time, try these steps:

  1. 通过以下方式进行表单:
    • 拥有孙子表单的子表单控件
    • 标头部分,高度为0.5英寸
  1. Make a form with:
    • A subform control that holds a grandchild form
    • A header section, height 0.5 inches
  • 将父级的子窗体高度设置为.6英寸,以便可见子级的详细信息部分
  • 在代码中,请参见子级的subform.Form.RecordSource属性(孙级).
  • 期望:没有错误
  • Set the parent's subform height to .6 inches, so the child's detail section is visible
  • In code, refer to the child's subform.Form.RecordSource property (the grandchild).
  • Expectation: no error
  • 现在,将父子窗体的高度设置为.4英寸,这样就看不到细节了
  • 重新运行与孩子的subform.Form.RecordSource属性相关的代码.
  • 期望:运行时错误2455
  • Now, set the parent subform height to .4 inches, so the detail is NOT visible
  • Rerun the code that touches the child's subform.Form.RecordSource property.
  • Expectation: Runtime Error 2455

我的孙子"表单在加载时没有RecordSource.记录源是在加载父/子表单后在代码中设置的.

My 'grandchild' forms have no RecordSource when loaded. The recordsource is set in code after the parent/child forms load.

请指出您正在运行的Access版本以及获得的结果.我正在运行Access版本14.0.7128.5000,它似乎是最新的.

Please, indicate the version of Access you are running, and what results you get. I'm running Access Version 14.0.7128.5000, which seems pretty up-to-date.

推荐答案

即使这是一个老话题,而且OP的答案肯定是其他东西,但我也希望与大家分享一下,希望它能为有经验的人提供一些帮助. 错误2455:您输入的表达式对属性Form/Report的引用无效".这可能会造成混乱,并且与错误的实际原因相去甚远.

Even though this is an old thread and the answer for OP was most certainly something else, I share this in hope it will help shed some light for others who have stumbeld on the "Error 2455: You entered an expression that has an invalid reference to the property Form/Report". Which may be pretty confusing and occure quite far from the actual cause of the error.

今天在Access 2016上发生在我身上.在对项目进行一些更改时,其中一个表单开始突然在其Form_Load()事件中引发错误2455,其中包含一行代码:

Happened to me today on Access 2016. While making some changes to a project, one of the forms started suddenly throwing Error 2455 in its Form_Load() event containing a single line of code:

Private Sub Form_Load()
    Set mevtReferenceToSubform = Me.frmASubform.Form
End Sub

stackoverflow.com/questions中指出/5023631/... 在对该问题的评论中:

As pointed out in stackoverflow.com/questions/5023631/... in the comments to the question:

没有记录时,不会加载绑定到父表单(包括具有LinkChild/LinkMaster属性的子表单)的记录源的控件."

"Controls bound to the recordsource of the parent form (including subforms with LinkChild/LinkMaster properties) do not load when there are no records."

显然,未绑定的子表单也是如此.如果父窗体的RecordSource查询未返回任何记录,则子窗体的".Form"属性将无法从其父窗体中访问!

Apparently the same goes for an unbound subform aswell. The subforms '.Form' property will not be accessible from its parent form if the parent form's RecordSource query does not return any records!

在我的案例中,罪魁祸首是一个TempVar声明,我用另一个解决方案替换了该声明,该解决方案在代码中的其他位置.但是没有注意到已删除的TempVar甚至被当前失败的父窗体的查询所使用,该查询未返回任何结果...

In my case the culprit turned out to be a TempVar declaration which I had replaced with another solution, elswhere in the code. But had failed to notice that the removed TempVar was even used by the now failing parent form's query, which didn't return any results...

这篇关于子表单引用引发错误2455:您输入的表达式对属性Form/Report的引用无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆