小编Dre*_*ven的帖子

访问 VBA:在连续子窗体中编辑 RecordSet

我正在尝试编写一个函数来循环遍历连续子表单中的记录并清除每个记录的特定字段(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 …
Run Code Online (Sandbox Code Playgroud)

ms-access vba recordset

2
推荐指数
1
解决办法
1022
查看次数

标签 统计

ms-access ×1

recordset ×1

vba ×1