[英]Edit all controls in an Access 2013 continuous form
I have a button on my main form that marks all controls in a continuous subform as "Yes", however it only changes the first record in the continuous form. 我在主窗体上有一个按钮,用于将连续子窗体中的所有控件标记为“是”,但是它仅更改连续窗体中的第一条记录。 The second, third, etc. records will not change.
第二,第三等记录不会更改。 I found an answer using DAO recordsets but the comboboxes I'm using are unbound.
我使用DAO记录集找到了答案,但我使用的组合框未绑定。
This is the code I have. 这是我的代码。 It modifies all comboboxes in the first record in the subform.
它修改子窗体的第一个记录中的所有组合框。
For Each ctl In Me![SubformName].Controls
If ctl.ControlType = acComboBox Then
If ctl.Name <> "Yes" Then
ctl.Value = "Yes"
End If
End If
Next ctl
What do I change in my code to allow me to modify records past the first? 我应该在代码中进行哪些更改,以允许我修改第一个记录之后的记录? Is there a way to directly refer to continuous form records?
有没有办法直接引用连续表单记录?
Edited to add: 编辑添加:
I still can't get it working for unbound comboboxes, but the following does work for bound ones. 我仍然无法使它适用于未绑定的组合框,但以下内容确实适用于绑定的组合框。
Set rst = Me.SubformName.Form.RecordsetClone
rst.MoveFirst
Do While rst.EOF = False
rst.Edit
rst!FieldName = "Yes"
rst.Update
rst.MoveNext
Loop
Open the RecordsetClone of the subform control. 打开子窗体控件的RecordsetClone 。
Loop through this, and for each record set the value of the fields which are bound to a combobox to True. 循环遍历,对于每个记录,将绑定到组合框的字段的值设置为True。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.