从另一个子窗体,问题重新查询子窗体 [英] Requery subform from another subform, problems

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

问题描述

我有2子窗体的主要形式。 Sub_2显示详细信息选择在sub_1的项目,在列表中。对于这两个窗体,我用的是不断的形式,他们一定到2 querys,有一个共同的领域,说'身份证'。

I have 2 subforms on the main form. Sub_2 displays the details for the item chosen in sub_1, in a list. For both subform, I use the continue form, and they are bounded to 2 querys, with one field in common, say 'id'.

我所做的是增加code在D单击事件上sub_1设置像

What I have done is adding code in the DClick event on sub_1 to set the sub_2's filter like

Me.Parent.sub_2.Form.Filter = "id=" & "'" & Me.Recordset!id & "'"

然后重新查询

Then a requery

Me.Parent.sub_2.Form.Requery

但没有运气,当我双击sub_1的记录,在sub_2没有变化。我已经对相关问题一看,我认为这应该工作...

But no luck, when I double click the record in sub_1, no change in sub_2. I have had a look on relevant questions, I think this should work...

有什么建议?也许我应该用其他的方法来做到这一点?

Any suggestions? Maybe I should use other approach to do this?

PS:我敢肯定, Me.Parent.sub_2.Filter 被改变,但是重新查询不能正常工作

PS: I'm sure Me.Parent.sub_2.Filter is changed, but requery doesn't work.

编辑:

感谢您的回答。我觉得这个问题,那就是'身份证'字段的查询,但它不是子窗体上显示的,所以也许Access不能使用它。

Thanks for answers. I find the problem, that is, the 'id' field is in the query, but it's not displayed on the subform, so maybe Access cannot use it.

和当过滤器发生变化时,访问会自动重新查询。

And when the filter is changed, Access does a requery automatically.

推荐答案

您应该不需要做的筛选器属性什么。

You should not need to do anything with the filter property.

在首体,设置链接主字段和链接子字段属性,你会为一个表单上有规律的,单一的子窗体控件。

On the first subform, set the Link Master Fields and Link Child Fields properties as you would for a regular, single subform control on a form.

对于第二个窗体,还设置了链接子字段属性,你会为一个常规的,单一的子控件。链接主字段属性将引用第一子窗体的控件名称:![1窗体控件名称]字段名

For the second subform, also set the Link Child Fields property as you would for a regular, single subform control. The Link Master Fields property will reference the control name of the first subform: [Subform 1 Control Name]!FieldName.

在第一子窗体控件的成为当前事件,添加VBA code以下行:

In the OnCurrent event of the first subform control, add the following line of VBA code:

Me.Parent.Controls![Subform 2 Control Name].Requery

运行方式。当您单击首体一排,第二子窗体将重新查询,显示该子行的第一子窗体选择的行。

Run the form. When you click a row in the first subform, the second subform will requery to display the child rows for the row selected in the first subform.

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

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