将表单字段值分配给子表单中的所有记录 [英] Assign form field value to all records in subform

查看:48
本文介绍了将表单字段值分配给子表单中的所有记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Access来说还很陌生,因此这对于某些人来说可能非常容易或显而易见,或者根本无法完成.我已经搜索了该站点,但是甚至可能没有使用适当的关键字.到目前为止,我还没有发现任何可以帮助我完成自己想做的事情的事情.

I'm pretty new to Access, so this may be very easy or obvious to some, or maybe it can't be done at all. I have searched this site, but I may not even be using the proper keywords. So far, I haven't found anything that helps me do what I am trying to do.

我有一个带有连续子窗体的窗体.我在名为txtPO_num的主要表单上有一个未绑定的txt字段.在此表单中,我运行一个查询,该查询在连续子表单中显示满足指定条件的所有记录.我在子窗体PO_Num中也有一个控件.我的问题是,如何获取txtPO_num中的主表单字段值以仅在子表单中显示的记录中填充PO_Num控件?

I have a form with a continuous subform in it. I have an unbound txt field on the main form called txtPO_num. In this form I run a query that displays all records that meet specified criteria in the continuous subform. I also have a control in the subform called PO_Num. My question is, how do I get the main form field value in txtPO_num to populate the PO_Num control in only the records displayed in the subform?

如果还有另一种方法可以做到这一点,我也很想知道这一点.

If there is another way to accomplish this I would be interested in knowing that too.

推荐答案

执行UPDATE语句,该语句的目标是包含在子表单中的相同记录.

Execute an UPDATE statement which targets the same records which are included in the subform.

您有一个带有WHERE子句的SELECT查询,该子句标识了子窗体的记录集中包含的记录.使用相同的WHERE子句构建UPDATE语句.例如,如果SELECT是...

You have a SELECT query with a WHERE clause which identifies the records included in the subform's recordset. Build an UPDATE statement using the same WHERE clause. For example, if the SELECT were ...

SELECT field1, field2
FROM YourTable
WHERE field2 = 'foo';

... UPDATE可能是...

... the UPDATE could be ...

UPDATE YourTable
SET field1 = 'new value'
WHERE field2 = 'foo';

使用DAO数据库对象的.Execute方法执行UPDATE语句.

Execute the UPDATE statement using the DAO database object's .Execute method.

这篇关于将表单字段值分配给子表单中的所有记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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