简体   繁体   English

如何访问子窗体上的文本框控件的值,其中子窗体本身只是主窗体的另一个子窗体上的控件

[英]How do I access the value of a textbox control on a subform where the subform itself is just a control on another subform of the main form

I've just assumed responsibility for a database written ages ago in MS Access and I need to make some changes but unfortunately, even though I used to be a very experienced Access developer some time ago, I haven't really used it to an advanced level for about 15 years and I just can't work out how to do what I need. 我刚刚承担了使用MS Access编写的数据库的职责,但是我需要进行一些更改,但是不幸的是,即使我曾经是一位非常有经验的Access开发人员,但实际上我并没有真正使用它。水平大约15年,我只是想不出如何做我需要的东西。

Specifically, I have a main form called frmOrders. 具体来说,我有一个名为frmOrders的主要形式。 On that form I have a subform called frmJobCard. 在该表格上,我有一个名为frmJobCard的子表格。 But frmJobCard is itself a form with a subform called frmSFJCOrders. 但是frmJobCard本身是带有子窗体frmSFJCOrders的窗体。 So, when someone clicks a particular button on frmOrders, I need to be able to read the value of a textbox on frmSFJCOrders and take action based on that value. 因此,当有人单击frmOrders上的特定按钮时,我需要能够读取frmSFJCOrders上的文本框的值,并根据该值采取措施。

I've so far read through dozens of posts (both on StackOverflow and other techy sources) all of which touch upon different aspects of reading from controls on subforms and I've spent over a day trying to get this right but it never actually works so I'd be grateful if someone could tell me how I just read this value. 到目前为止,我已经阅读了数十篇文章(都来自StackOverflow和其他技术来源),所有这些文章都涉及到从子表单控件中读取内容的不同方面,并且我花了整整一天的时间来尝试解决此问题,但实际上从未奏效因此,如果有人能告诉我如何读取此值,我将不胜感激。

I think I need something along the lines of... 我想我需要一些...

If Forms.frmOrders.frmJobCard.Form.frmSFJCOrders.[Estimate QTY] = 0 Then 如果Forms.frmOrders.frmJobCard.Form.frmSFJCOrders。[Estimate QTY] = 0然后

...but I just can't make it work. ...但是我只是无法使其正常工作。

I would expect the code above to evaluate to 0 then take the actions below but it just always fails on the evaluation with 我希望上面的代码评估为0,然后采取以下措施,但是对于

Run-time error '2465': Application-defined or object-defined error 运行时错误“ 2465”:应用程序定义或对象定义的错误

Any help is greatly appreciated - thanks in advance :) 任何帮助都将不胜感激-预先感谢:)

Consider this Access MVPs resource which I bookmarked in my early Access programming days. 考虑一下我在早期Access编程天中加入书签的Access MVPs资源 Specifically you need ! 具体来说,您需要! to delineate within objects and . 对象和物体描绘. to delineate between parent/child objects with Form. 使用Form. 父/子对象之间划定Form. qualifier for every form object. 每个表单对象的限定符。

If Forms!frmOrders!frmJobCard.Form!frmSFJCOrders![Estimate QTY] = 0 Then

Alternatively, use a functional version: 或者,使用功能版本:

If Forms("frmOrders").Controls("frmJobCard") _
                     .Controls("frmSFJCOrders") _
                     .Controls("[Estimate QTY]") = 0 Then

It should be close to this: 它应该接近:

If Me!frmJobCard.Form!frmSFJCOrders.Form![Estimate QTY].Value = 0 Then

Note that frmJobCard and frmSFJCOrders must be names of the subform controls which may differ from the names of the forms. 请注意,frmJobCard和frmSFJCOrders必须是子窗体控件的名称,该名称可能与窗体的名称不同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM