且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何创建一个新的空白记录而不显示先前记录中的先前数据?

更新时间:2023-01-27 13:39:00

根据您是否具有绑定形式,Kefash的答案可能有效. 但是,如果您有未绑定的表单,则不会.

Depending on whether or not you have a bound form, Kefash' answer could work. If you have an unbound form however, it will not.

如果确实有未绑定的表单,最简单的方法是只遍历所有控件并将它们清空. 例如:

If you do have an unbound form, the simplest way is to just loop through all the controls and empty them. For example:

Private Sub save_Click()
Dim ctl As Control
    For Each ctl In Me.Controls
    Select Case ctl.ControlType
    Case acListBox
        If Len(ctl.ControlSource) = 0 Then
            ctl.Value = Null
        End If
    Case acCheckBox
        ctl.Value = 0
    Case acTextBox
        ctl.value = ""
    End Select
Next
End Sub