清空窗體中各欄位資料

字號:

Public Sub ClearD(frm As Form)
    Dim ctl As Control
    For Each ctlControl In frm.Controls
    If Typeof ctl is acTextBox Or Typeof ctl is acComboBox Then
    ctl = ""
    DoEvents
    End If
    Next
    End Sub
    此程序稍一修改便可達到更多的功能如鎖定或解鎖各欄位
    Public Sub LockControls(frm As Form, blnSta As Boolean)
    Dim ctl As Control
    For Each ctl In frm.Controls
    If TypeOf ctl Is acTextBox Or TypeOf ctl Is acComboBox Then
    ctl.Enabled = blnSta
    DoEvents
    End If
    Next
    End Sub