Public Sub ClearAllControls(frmForm As Form)
Dim ctlControl As Object ' Initialize all controls that can be initialized ' Any control with a text property or a list-index property On Error Resume Next For Each ctlControl In frmForm.Controls ctlControl.Text = "" ctlControl.ListIndex = -1 DoEvents Next ctlControl End Sub 'Just call this procedure from your code like this: Call ClearAllControls(Me) Sometimes you want to clear all the fields and combo boxes on a data-entry form. If your form contains many controls, this could become tedious and error prone. The following subroutine clears the contents of such fields on your form automatically: |