There is function which clears all controls on form.
Create commandbutton on your form (e.g. <cmdClear>) Copy following code in procedure On Click:
private cmdClear_OnClick()
call UpdateToNull(me)
end sub
Sub UpdateToNull(frm As Form, _
Optional blnOnlyUbound As Boolean = True, _
Optional blnIncludeSubForms As Boolean = False) 'This recursive function updates all form's
'textboxes and comboboxes to Null value.
'If parameter <blnIncludeSubForms> is set True then
'all textboxes and comboboxes of all subforms will update
'If parameter <blnOnlyUbound> is set false then
'all all textboxes and comboboxes will update
'otherwise only unbound controls will update.
Dim ctl As Control
On Error Resume Next
For Each ctl In frm.Controls
Select Case ctl.Properties("ControlType"
Case acTextBox, acComboBox
If ctl.Properties("ControlSource" <> "" Then
If Not blnOnlyUbound Then
GoTo NextControl
End If
End If
ctl = Null
Case acSubform
If blnIncludeSubForms Then
Call UpdateToNull(frm, blnIncludeSubForms)
End If
End Select
NextControl:
Next ctl
End Sub
Try it!
You may sub program UpdateToNull() copy into any module.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.