从另一个子窗体设置子窗体的RecordSource [英] Setting RecordSource of Subform from another Subform

查看:130
本文介绍了从另一个子窗体设置子窗体的RecordSource的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我知道该怎么做,但那显然是行不通的.我发誓我以前做过.无论我如何更改代码,我都会不断得到您输入的表达式对属性Form/Report的引用无效"

我正在尝试在SAME主窗体上的另一个子窗体的OnCurrent事件期间设置一个子窗体的RecordSource.

主要形式:frmMain
子窗体1:frmSub1(采用此窗体的OnCurrent事件)
Subform2:frmSub2(为此设置源)

在frmSub1的OnCurrent事件中:

Okay, I know how to do this but it''s just plain not working. I swear I''ve done this before. No matter how I vary the code I keep getting "you entered an expression that has an invalid reference to the property Form/Report"

I''m trying to set the RecordSource of one subform during the OnCurrent event of another subform on the SAME main form.

Main form: frmMain
Subform1: frmSub1 (in this form''s OnCurrent event)
Subform2: frmSub2 (setting the source for this one)

in frmSub1''s OnCurrent event:

Me.Parent!frmSub2.Form.RecordSource = "blah blah blah..."
'OR
Forms!frmMain!frmSub2.Form.RecordSource = "blah blah blah..."



如果我在调试窗口中执行此操作:



If I do this in debug window:

?Forms!frmMain!frmSub2.Name



我得到了我期望的结果.但是,如果我在调试窗口中执行此操作:



I get the result I expect. But if I do this in the debug window:

?Forms!frmMain!frmSub2.Form.RecordSource



我收到上面提到的错误.当然,该错误与我用来设置RecordSource的SQL字符串无关.错误是说这很简单,不喜欢我的表单引用.我的眼睛开始对此发疯.谁能看到问题所在?

请注意,这些子表单不是嵌套的.它们是在同一主窗体上并排的独立子窗体.



I get the error noted above. Of course the error has nothing to do with the SQL string that I''m using to set the RecordSource. The error is saying it just plain doesn''t like my form references. My eyes are starting to go nuts on this one. Can anyone see where the problem is?

Note that these subforms are NOT nested. They are separate subforms side by side on the same main form.

Thanks!

推荐答案

要绑定MainForm和SubForm的数据,您需要定义一个相关字段.

请参考这些小孔:
http://office.microsoft.com/en-us/access- help/create-a-subform-HP005187803.aspx [ ^ ]
http://access.mvps.org/access/forms/frm0031.htm [ ^ ]
http://www.fmsinc.com/microsoftaccess/forms/synchronize/linkedsubforms.asp [ ^ ]
To bind data of MainForm and SubForm you need to define a related field.

Please, refer these atricles:
http://office.microsoft.com/en-us/access-help/create-a-form-that-contains-a-subform-a-one-to-many-form-HA010098674.aspx[^]
http://office.microsoft.com/en-us/access-help/create-a-subform-HP005187803.aspx[^]
http://access.mvps.org/access/forms/frm0031.htm[^]
http://www.fmsinc.com/microsoftaccess/forms/synchronize/linkedsubforms.asp[^]


这篇关于从另一个子窗体设置子窗体的RecordSource的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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