gpt4 book ai didi

ms-access - Access VBA : Editing a RecordSet in a continuous subform

转载 作者:行者123 更新时间:2023-12-02 20:41:34 25 4
gpt4 key购买 nike

我正在尝试编写一个函数来循环遍历连续子表单中的记录,并清除每个记录的特定字段(Entity_Under_Consideration,这是由子表单上的组合框表示的查找字段)中的值。

以下内容无效。它也不会抛出任何错误。谁能看出我哪里出了问题吗?

Public Function clearEUCData(subform As Control)

'take a clone of the subform's recordset
Dim entityRecSet As Recordset
Set entityRecSet = subform.Form.Recordset.Clone()

'if there are any records in the subform...
If entityRecSet.RecordCount > 0 Then

'start with the first record
entityRecSet.MoveFirst

'iterate through each row, clearing the data in the EUC field
Do Until entityRecSet.EOF

With entityRecSet
.Edit
Entity_Under_Consideration = 0
.Update
End With

entityRecSet.MoveNext
Loop

End If

'close and purge the cloned recordset
entityRecSet.Close
Set entityRecSet = Nothing

End Function

最佳答案

你必须更明确:

With entityRecSet
.Edit
.Fields("Entity_Under_Consideration").Value = 0
.Update
End With

关于ms-access - Access VBA : Editing a RecordSet in a continuous subform,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45998185/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com