简体   繁体   English

vba Access 2010更新已过滤的子窗体

[英]vba access 2010 update a filtered subform

I have a form with subform. 我有一个带有子窗体的窗体。 The subform has the recordsource in a query named my_subform_query. 子表单在名为my_subform_query的查询中具有记录源。 The subform shows the query result and allow to filter the content with few comboBox in the father form. 子窗体显示查询结果,并允许在父窗体中用很少的comboBox过滤内容。 The query source is a LEFT Join. 查询源是左联接。 I need to update all records shown in subform but no the rest shown by the query. 我需要更新子窗体中显示的所有记录,但查询不显示其余记录。

How can I do this if the me.recordsource is the query my_subform_query 如果me.recordsource是查询my_subform_query我该怎么做

thanks in advance 提前致谢

edit: Sorry I want to mean to execute a update query with CurrentDb.Execute "UPDATE table..." to update a True/false field... 编辑:对不起,我想表示要使用CurrentDb执行更新查询。执行“ UPDATE table ...”以更新True / false字段...

From the parent form call: 从父窗体调用:

Me!NameOfYourSubformControl.Form.Requery

From/in the subform itself call: 从子窗体本身调用/在子窗体中调用:

Me.Requery

To update, you would use the RecordsetClone of the subform: 要更新,您将使用子窗体的RecordsetClone:

Dim rs As DAO.Recordset

Set rs = Me!NameOfYourSubformControl.Form.RecordsetClone

While Not rs.EOF
    rs.Edit
        rs!YourTrueFalseFieldName.Value = True  ' or = False
    rs.Update
    rs.MoveNext
Wend

Set rs = Nothing

No requery of the subform will be needed. 不需要重新查询子表单。

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

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