简体   繁体   中英

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. The subform shows the query result and allow to filter the content with few comboBox in the father form. 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

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...

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:

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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