What is the code line I need to add to the code behind a Save button to make
all of the fields on a form blank after I save?
Is this form bound to a recordsource (you can scroll through records with the
navigation buttons)? If so, you can use this line of code to move to a new
record:
DoCmd.GoToRecord , , acNewRec
If your form is unbound (controls are filled with code and values are saved to
table with code) you will need to go through the controls collection and set
each control to "Null" (or "", depending on what your code is looking for):
(Copy this sub to a standard module - a global module, not a module behind a
form or report.)
'*******EXAMPLE START
Public Sub subClearForm(strForm As String)
' Comments : Clears form's data controls
' Parameters: strForm - the form's Name
' Created : 11/06/03 10:47 Bruce M. Thompson
' Modified :
'
' --------------------------------------------------
'Ignore errors
On Error Resume Next
Dim ctl As Control
'Cycle through form's control collection and
' clear data controls
For Each ctl In Forms(strForm).Controls
ctl.Value = Null
Next
End Sub
'*******EXAMPLE END
Call as follows:
subClearForm (Me.Name)